summaryrefslogtreecommitdiff
path: root/archaeological_operations/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r--archaeological_operations/views.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 9aa2222ba..1ce4c4622 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -30,6 +30,30 @@ from wizards import *
from forms import *
import models
+def autocomplete_patriarche(request, non_closed=True):
+ person_types = request.user.ishtaruser.person.person_type
+ if (not request.user.has_perm('ishtar_common.view_operation',
+ models.Operation)
+ and not request.user.has_perm('ishtar_common.view_own_operation',
+ models.Operation)
+ and not person_types.rights.filter(
+ wizard__url_name='operation_search').count()):
+ return HttpResponse(mimetype='text/plain')
+ if not request.GET.get('term'):
+ return HttpResponse(mimetype='text/plain')
+ q = request.GET.get('term')
+ query = Q()
+ for q in q.split(' '):
+ query = query & Q(code_patriarche__startswith=q)
+ if non_closed:
+ query = query & Q(end_date__isnull=True)
+ limit = 15
+ operations = models.Operation.objects.filter(query)[:limit]
+ data = json.dumps([{'id':operation.code_patriarche,
+ 'value':operation.code_patriarche}
+ for operation in operations])
+ return HttpResponse(data, mimetype='text/plain')
+
def autocomplete_operation(request, non_closed=True):
person_types = request.user.ishtaruser.person.person_type
if (not request.user.has_perm('ishtar_common.view_operation',
@@ -70,9 +94,19 @@ def get_available_operation_code(request, year=None):
get_operation = get_item(models.Operation, 'get_operation', 'operation',
bool_fields = ['end_date__isnull'],
+ dated_fields = ['start_date__lte', 'start_date__gte',
+ 'excavation_end_date__lte', 'excavation_end_date__gte'],
extra_request_keys={'common_name':'common_name__icontains',
'end_date':'end_date__isnull',
- 'year_index':('year', 'operation_code')})
+ 'year_index':('year', 'operation_code'),
+ 'start_before':'start_date__lte',
+ 'start_after':'start_date__gte',
+ 'end_before':'excavation_end_date__lte',
+ 'end_after':'excavation_end_date__gte',
+ 'parcel_0':'parcels__section',
+ 'parcel_1':'parcels__parcel_number',
+ },
+ )
show_operation = show_item(models.Operation, 'operation')
revert_operation = revert_item(models.Operation)
@@ -88,7 +122,6 @@ get_administrativeactop = get_item(models.AdministrativeAct,
'operation__towns':'operation__towns__pk',
'act_type__intented_to':'act_type__intented_to'})
-
def dashboard_operation(request, *args, **kwargs):
"""
Operation dashboard