Browse Source

added category to orders list

funding-tag
Holger Frey 5 years ago
parent
commit
87a7dfc827
  1. 6
      ordr3/templates/orders/list.jinja2
  2. 6
      ordr3/templates/orders/list_content.jinja2
  3. 22
      ordr3/views/orders.py

6
ordr3/templates/orders/list.jinja2

@ -59,9 +59,13 @@
<div class="text-secondary small">Unit Price</div> <div class="text-secondary small">Unit Price</div>
</th> </th>
<th scope="col" class="o3-dont-wrap"> <th scope="col" class="o3-dont-wrap">
Ordered by Category
<div class="text-secondary small">Account</div> <div class="text-secondary small">Account</div>
</th> </th>
<th scope="col" class="o3-dont-wrap">
Ordered by
<div class="text-secondary small">&nbsp;</div>
</th>
<th scope="col" class="o3-dont-wrap"> <th scope="col" class="o3-dont-wrap">
Status Status
<div class="text-secondary small">&nbsp;</div> <div class="text-secondary small">&nbsp;</div>

6
ordr3/templates/orders/list_content.jinja2

@ -21,9 +21,13 @@
<div class="text-secondary small o3-dont-wrap"><a class="o3-copy" title="copy to clipboard">{{ order.model.amount }}</a> * <a class="o3-copy" title="copy to clipboard">{{ "%.2f"|format(order.model.unit_price)|replace(".", ",") }}</a> {{ order.model.currency }}</div> <div class="text-secondary small o3-dont-wrap"><a class="o3-copy" title="copy to clipboard">{{ order.model.amount }}</a> * <a class="o3-copy" title="copy to clipboard">{{ "%.2f"|format(order.model.unit_price)|replace(".", ",") }}</a> {{ order.model.currency }}</div>
</td> </td>
<td> <td>
<a href="{{ request.resource_url(context, query={'user':order.model.created_by})}}" title="Show orders for this user">{{ order.model.created_by}}</a> <span class="o3-dont-wrap">{{ order.model.category.name|title }}</span>
<div class="text-secondary small"><a class="o3-copy" title="copy to clipboard">{{ order.model.account }}</a></div> <div class="text-secondary small"><a class="o3-copy" title="copy to clipboard">{{ order.model.account }}</a></div>
</td> </td>
<td>
<a href="{{ request.resource_url(context, query={'user':order.model.created_by})}}" title="Show orders for this user">{{ order.model.created_by}}</a>
<div class="text-secondary small">&nbsp;</div>
</td>
<td> <td>
{{ macros.status_label(order.model.status) }} {{ macros.status_label(order.model.status) }}
<div class="text-secondary small">&nbsp;</div> <div class="text-secondary small">&nbsp;</div>

22
ordr3/views/orders.py

@ -9,6 +9,8 @@ from .. import events, models, services, resources
# from ..schemas import account # from ..schemas import account
QUERY_LIMIT = 25
def get_status(request): def get_status(request):
status_param = request.GET.get("status", "") status_param = request.GET.get("status", "")
@ -42,7 +44,7 @@ def get_multiple_orders(context, request):
renderer="ordr3:templates/orders/list_content.jinja2", renderer="ordr3:templates/orders/list_content.jinja2",
) )
def order_list(context, request): def order_list(context, request):
limit = 25 limit = QUERY_LIMIT
offset = get_offset(request) offset = get_offset(request)
status = get_status(request) status = get_status(request)
username = request.GET.get("user", None) username = request.GET.get("user", None)
@ -105,10 +107,11 @@ def batch_delete(context, request):
if not orders: if not orders:
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
if len(orders) > 100: if len(orders) > QUERY_LIMIT:
request.emit( request.emit(
events.FlashMessage.warning( events.FlashMessage.warning(
f"You cannot delete more than 100 orders in one sweep." f"You cannot delete more than "
f"{QUERY_LIMIT} orders in one sweep."
) )
) )
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
@ -133,10 +136,11 @@ def batch_delete_confirmed(context, request):
if not orders: if not orders:
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
if len(orders) > 100: if len(orders) > QUERY_LIMIT:
request.emit( request.emit(
events.FlashMessage.warning( events.FlashMessage.warning(
f"You cannot delete more than 100 orders in one sweep." f"You cannot delete more than "
f"{QUERY_LIMIT} orders in one sweep."
) )
) )
else: else:
@ -164,10 +168,10 @@ def batch_edit(context, request):
if not orders: if not orders:
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
if len(orders) > 100: if len(orders) > QUERY_LIMIT:
request.emit( request.emit(
events.FlashMessage.warning( events.FlashMessage.warning(
f"You cannot edit more than 100 orders in one sweep." f"You cannot edit more than {QUERY_LIMIT} orders in one sweep."
) )
) )
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
@ -197,10 +201,10 @@ def batch_edit_confirm(context, request):
if not orders: if not orders:
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))
if len(orders) > 100: if len(orders) > QUERY_LIMIT:
request.emit( request.emit(
events.FlashMessage.warning( events.FlashMessage.warning(
f"You cannot edit more than 100 orders in one sweep." f"You cannot edit more than {QUERY_LIMIT} orders in one sweep."
) )
) )
return HTTPFound(request.resource_path(context)) return HTTPFound(request.resource_path(context))

Loading…
Cancel
Save