aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
Diffstat (limited to 'servo')
-rw-r--r--servo/forms/orders.py4
-rw-r--r--servo/views/order.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/servo/forms/orders.py b/servo/forms/orders.py
index ae97e87..eb5d554 100644
--- a/servo/forms/orders.py
+++ b/servo/forms/orders.py
@@ -141,6 +141,10 @@ class OrderSearchForm(forms.Form):
label=mark_safe(' '),
widget=DatepickerInput(attrs={'class': "input-small"})
)
+ status_older_than = forms.IntegerField(
+ required=False,
+ label=_('Status older than (days)'),
+ )
def __init__(self, request, *args, **kwargs):
super(OrderSearchForm, self).__init__(*args, **kwargs)
diff --git a/servo/views/order.py b/servo/views/order.py
index cc6d430..80e0077 100644
--- a/servo/views/order.py
+++ b/servo/views/order.py
@@ -42,8 +42,7 @@ def prepare_list_view(request, args):
"""
data = {'title': _("Orders")}
- form = OrderSearchForm(args)
- form.fields['location'].queryset = request.user.locations
+ form = OrderSearchForm(request, args)
if request.session.get("current_queue"):
del(request.session['current_queue'])
@@ -64,6 +63,12 @@ def prepare_list_view(request, args):
end_date = args.get('end_date') or timezone.now()
orders = orders.filter(created_at__range=[start_date, end_date])
+ if args.get("status_older_than"):
+ from datetime import datetime, timedelta
+ days = int(args.get("status_older_than"))
+ limit = datetime.now() - timedelta(days=days)
+ orders = orders.filter(status_started_at__lt=limit)
+
if args.get("assigned_to"):
users = args.getlist("assigned_to")
orders = orders.filter(user__in=users)