summaryrefslogtreecommitdiff
path: root/archaeological_files/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2014-10-16 20:34:20 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2014-10-16 20:34:20 +0200
commite96320dc97ee2befd7deed6e518b9237a1441727 (patch)
treed1dd7549f0a9d11e1170157ed1700f9930caf91d /archaeological_files/forms.py
parent709db764b4cb98ca7a4aa88aab4c4006d50201d5 (diff)
downloadIshtar-e96320dc97ee2befd7deed6e518b9237a1441727.tar.bz2
Ishtar-e96320dc97ee2befd7deed6e518b9237a1441727.zip
Dashboards - graphs: allow to choose source of the date (creation or reception)
Diffstat (limited to 'archaeological_files/forms.py')
-rw-r--r--archaeological_files/forms.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py
index e3b480a57..4364829b2 100644
--- a/archaeological_files/forms.py
+++ b/archaeological_files/forms.py
@@ -123,10 +123,14 @@ class FileFormSelection(forms.Form):
return cleaned_data
SLICING = (('year',_(u"years")), ("month",_(u"months")))
+DATE_SOURCE = (('creation',_(u"Creation date")),
+ ("reception",_(u"Reception date")))
class DashboardForm(forms.Form):
slicing = forms.ChoiceField(label=_("Slicing"), choices=SLICING,
required=False)
+ date_source = forms.ChoiceField(label=_("Date get from"),
+ choices=DATE_SOURCE, required=False)
file_type = forms.ChoiceField(label=_("File type"), choices=[],
required=False)
saisine_type = forms.ChoiceField(label=_("Saisine type"), choices=[],
@@ -141,18 +145,26 @@ class DashboardForm(forms.Form):
self.fields['saisine_type'].choices = models.SaisineType.get_types()
self.fields['file_type'].choices = models.FileType.get_types()
+ def get_date_source(self):
+ date_source = 'creation'
+ if hasattr(self, 'cleaned_data') and \
+ self.cleaned_data.get('date_source'):
+ date_source = self.cleaned_data['date_source']
+ return date_source
+
def get_filter(self):
if not hasattr(self, 'cleaned_data') or not self.cleaned_data:
return {}
+ date_source = self.get_date_source()
fltr = {}
if self.cleaned_data.get('saisine_type'):
fltr['saisine_type_id'] = self.cleaned_data['saisine_type']
if self.cleaned_data.get('file_type'):
fltr['file_type_id'] = self.cleaned_data['file_type']
if self.cleaned_data.get('after'):
- fltr['creation_date__gte'] = self.cleaned_data['after']
+ fltr[date_source+'_date__gte'] = self.cleaned_data['after']
if self.cleaned_data.get('before'):
- fltr['creation_date__lte'] = self.cleaned_data['before']
+ fltr[date_source+'_date__lte'] = self.cleaned_data['before']
return fltr
class FileFormGeneral(forms.Form):