delete total of order in profile view
This commit is contained in:
parent
2704848368
commit
51c5affa85
|
@ -23,18 +23,14 @@
|
||||||
<th scope="col">ID</th>
|
<th scope="col">ID</th>
|
||||||
<th scope="col">DATE</th>
|
<th scope="col">DATE</th>
|
||||||
<th scope="col">STATUS</th>
|
<th scope="col">STATUS</th>
|
||||||
<th scope="col">ITEMS</th>
|
|
||||||
<th scope="col">PRICE</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% for order, order_positions_count, total, currency_name in order_list_zip %}
|
{% for order, order_positions_count in order_list_zip %}
|
||||||
<tr class="table_content">
|
<tr class="table_content">
|
||||||
<td scope="col">{{ order.id }}</td>
|
<td scope="col">{{ order.id }}</td>
|
||||||
<td scope="col">{{ order.date }}</td>
|
<td scope="col">{{ order.date }}</td>
|
||||||
<td scope="col">
|
<td scope="col">
|
||||||
<a href="{% url 'order' order.id %}">{{ order.status }}</a>
|
<a href="{% url 'order' order.id %}">{{ order.status }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td scope="col">{{ order_positions_count }}</td>
|
|
||||||
<td scope="col">{{ total }} {{ currency_name }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -177,36 +177,11 @@ def profile(request):
|
||||||
order_positions = OrderPosition.objects.filter(order=order)
|
order_positions = OrderPosition.objects.filter(order=order)
|
||||||
if (order_positions.count()) > 0:
|
if (order_positions.count()) > 0:
|
||||||
order_positions_count = order_positions.count()
|
order_positions_count = order_positions.count()
|
||||||
order_position_list = list(order_positions)
|
|
||||||
for idx2, order_position in enumerate(order_position_list):
|
|
||||||
position_price = None
|
|
||||||
price = None
|
|
||||||
# get currencyname to display:
|
|
||||||
if order.exchange_rate is not None:
|
|
||||||
# get price of position in order and append to a list:
|
|
||||||
rate = ExchangeRate.objects.get(
|
|
||||||
id=order.exchange_rate.id)
|
|
||||||
price = round(
|
|
||||||
rate.exchange_rate_to_chf *
|
|
||||||
order_position.price_in_chf,
|
|
||||||
2)
|
|
||||||
currency_name = order.exchange_rate
|
|
||||||
else:
|
|
||||||
currency_name = 'CHF'
|
|
||||||
price = order_position.price_in_chf
|
|
||||||
position_price = price * Decimal.from_float(
|
|
||||||
order_position.amount)
|
|
||||||
totalprice_list.append(position_price)
|
|
||||||
order_position_list[idx2] = order_position
|
|
||||||
total = sum(totalprice_list)
|
|
||||||
currency_list.append(currency_name)
|
|
||||||
total_list.append(total)
|
|
||||||
order_positions_count_list.append(order_positions_count)
|
order_positions_count_list.append(order_positions_count)
|
||||||
orders_list[idx1] = order
|
orders_list[idx1] = order
|
||||||
order_list_zip = zip(orders_list,
|
order_list_zip = zip(orders_list,
|
||||||
order_positions_count_list,
|
order_positions_count_list
|
||||||
total_list,
|
)
|
||||||
currency_list)
|
|
||||||
# assert False
|
# assert False
|
||||||
return render(request, 'registration/profile.html',
|
return render(request, 'registration/profile.html',
|
||||||
{'person': person,
|
{'person': person,
|
||||||
|
|
Loading…
Reference in New Issue