forked from uncloud/uncloud
Implement first part of the form
This commit is contained in:
parent
1e69722f4b
commit
e910556952
5 changed files with 40 additions and 38 deletions
|
@ -47,9 +47,10 @@ machine. Use `kubectl get nodes` to verify minikube is up and running.
|
||||||
* Link to ProductOrderForm [done]
|
* Link to ProductOrderForm [done]
|
||||||
* Find suitable timeframes for a product [done]
|
* Find suitable timeframes for a product [done]
|
||||||
* Continue to resources / add resources
|
* Continue to resources / add resources
|
||||||
* Need to list resources
|
* Need to list resources [done]
|
||||||
* Need to create manytomany relations for each resource resolutling
|
* Need to create manytomany relations for each resource resoluting
|
||||||
in ResourceOrders
|
in ResourceOrders1
|
||||||
|
* Need to pass in the price for the selected timeframe
|
||||||
* On submit
|
* On submit
|
||||||
* List of
|
* List of
|
||||||
* resources + values
|
* resources + values
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
<h1>{{ object.name }}</h1>
|
<h1>{{ object.name }}</h1>
|
||||||
|
|
||||||
|
(description to be added here)
|
||||||
<form method="post" >
|
|
||||||
{% csrf_token %}
|
|
||||||
{{ form.as_p }}
|
|
||||||
<input type="submit" value="Buy">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for tf in timeframes %}
|
{% for tf in timeframes %}
|
||||||
<li><a href="{% url 'product-order-tf' object.slug tf.slug %}">{{ tf }}</a>
|
<li><a href="{% url 'product-order-tf' object.slug tf.slug %}">Buy
|
||||||
|
{{ object.name }}
|
||||||
|
for {{ tf }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
HERE we show a link to <a href="{{ productorder }}">order</a>.
|
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
<h1>Select Product</h1>
|
<h1>Select Product</h1>
|
||||||
|
|
||||||
<h2>Product Order</h2>
|
|
||||||
<ul>
|
|
||||||
{% for product in object_list %}
|
|
||||||
{% if product.slug %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ product.get_absolute_url }}">{{ product.name }}</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
<h2>Product List</h2>
|
<h2>Product List</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for product in object_list %}
|
{% for product in object_list %}
|
||||||
|
|
|
@ -1,23 +1,31 @@
|
||||||
Ordering a {{ product }} instance for {{ timeframe }}
|
<h2>Ordering a {{ product }} instance for {{ timeframe }}</h2>
|
||||||
|
|
||||||
we are here?!
|
|
||||||
|
|
||||||
|
TODO: catch invalid timeframe
|
||||||
|
|
||||||
<form method="post" >
|
<form method="post" >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
<div class="form-group">
|
||||||
{% for res in product.resources.all %}
|
<label for="product">Product</label>
|
||||||
<li>
|
<input type="text" class="form-control"
|
||||||
{% if res.minimum_units and res.maximum_units %}
|
id="product" value={{product.slug}} readonly>
|
||||||
<input type="range" id="{{res.slug}}" name="{{res.slug}}"
|
</div>
|
||||||
min="{{ res.minimum_units }}" max="{{ res.maximum_units
|
<div class="form-group">
|
||||||
}}">
|
<label for="timeframe">Timeframe</label>
|
||||||
{% else %}
|
<input type="text" class="form-control"
|
||||||
<input type="text" id="{{res.slug}}" name="{{res.slug}}">
|
id="timeframe" value="{{timeframe.slug}}" readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% for res,price,currency in res_price %}
|
||||||
</li>
|
<div class="form-group">
|
||||||
|
<label for="{{res.slug}}">{{res.name}} {{res.unit}}
|
||||||
|
{{ price }}{{ currency.short_name }}/unit/{{ timeframe}}
|
||||||
|
{% if res.minimum_units %} (Min: {{res.minimum_units}}) {%endif%}
|
||||||
|
{% if res.maximum_units %} (Max: {{res.maximum_units}}) {%endif%}
|
||||||
|
</label>
|
||||||
|
<input type="text" class="form-control"
|
||||||
|
id="{{res.slug}}">
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<input type="submit" value="Next">
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -17,6 +17,15 @@ class ProductOrderView(CreateView):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['product'] = get_object_or_404(Product, slug=self.kwargs['product'])
|
context['product'] = get_object_or_404(Product, slug=self.kwargs['product'])
|
||||||
context['timeframe'] = get_object_or_404(TimeFrame, slug=self.kwargs['timeframe'])
|
context['timeframe'] = get_object_or_404(TimeFrame, slug=self.kwargs['timeframe'])
|
||||||
|
|
||||||
|
res_price = []
|
||||||
|
for res in context['product'].resources.all():
|
||||||
|
price = res.price_per_time.filter(timeframe=context['timeframe'])[0].price
|
||||||
|
currency = res.price_per_time.filter(timeframe=context['timeframe'])[0].currency
|
||||||
|
|
||||||
|
res_price.append((res, price, currency))
|
||||||
|
context['res_price'] = res_price
|
||||||
|
|
||||||
print(context)
|
print(context)
|
||||||
print(self.kwargs)
|
print(self.kwargs)
|
||||||
return context
|
return context
|
||||||
|
|
Loading…
Reference in a new issue