diff options
Diffstat (limited to 'ishtar/furnitures/views.py')
| -rw-r--r-- | ishtar/furnitures/views.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py index 811618449..b266bed63 100644 --- a/ishtar/furnitures/views.py +++ b/ishtar/furnitures/views.py @@ -157,7 +157,14 @@ def json_operation(request, non_closed=True): continue dct[request_keys[k]] = q if not dct: - return HttpResponse(mimetype='text/plain') + if 'json_operation' in request.session: + dct = request.session['json_operation'] + elif 'operation' in request.session: + dct = {"pk":request.session['operation']} + if not dct: + return HttpResponse(mimetype='text/plain') + else: + request.session['json_operation'] = dct query = Q(**dct) operations = models.Operation.objects.filter(query) q = request.GET.get('sidx') @@ -166,9 +173,13 @@ def json_operation(request, non_closed=True): if k.endswith("__pk"): k = k[:-len("__pk")] + "__label" q = request.GET.get('sord') - if q and q == u'desc': - k = "-" + k - operations.order_by(k) + sign = q and q == u'desc' and "-" or '' + if k == "name": + k = "operation_code" + operations = operations.order_by(sign + 'year').order_by( + sign + 'operation_code') + else: + operations = operations.order_by(sign + k) data = json.dumps({ "records":len(operations), "rows":[{"id":unicode(operation.pk), |
