diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-10-20 20:40:42 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2014-10-20 20:40:42 +0200 |
commit | 57cdf8896f854de7ba573cfe8d5040155df1e656 (patch) | |
tree | 28c99961d82172cefbc1c2972789e7f647d05e63 /archaeological_files | |
parent | 2feb794529f3a99ff9ee5402803bafc935f45f72 (diff) | |
download | Ishtar-57cdf8896f854de7ba573cfe8d5040155df1e656.tar.bz2 Ishtar-57cdf8896f854de7ba573cfe8d5040155df1e656.zip |
Dashboard: many improvments on graph (refs #2075)
* by default graph is set by month
* data are reapeated in a table
* ability to save the graph in a file
* detail by department with a line by department + total
* add a legend
* ability to zoom on the graph
Diffstat (limited to 'archaeological_files')
-rw-r--r-- | archaeological_files/forms.py | 8 | ||||
-rw-r--r-- | archaeological_files/models.py | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index dbbbafbd9..68a004e4f 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -122,13 +122,15 @@ class FileFormSelection(forms.Form): raise forms.ValidationError(_(u"You should select a file.")) return cleaned_data -SLICING = (('year',_(u"years")), ("month",_(u"months"))) +SLICING = (("month",_(u"months")), ('year',_(u"years")),) DATE_SOURCE = (('creation',_(u"Creation date")), ("reception",_(u"Reception date"))) class DashboardForm(forms.Form): slicing = forms.ChoiceField(label=_("Slicing"), choices=SLICING, required=False) + department_detail = forms.BooleanField(label=_("Department detail"), + required=False) date_source = forms.ChoiceField(label=_("Date get from"), choices=DATE_SOURCE, required=False) file_type = forms.ChoiceField(label=_("File type"), choices=[], @@ -145,6 +147,10 @@ class DashboardForm(forms.Form): self.fields['saisine_type'].choices = models.SaisineType.get_types() self.fields['file_type'].choices = models.FileType.get_types() + def get_show_detail(self): + return hasattr(self, 'cleaned_data') and \ + self.cleaned_data.get('department_detail') + def get_date_source(self): date_source = 'creation' if hasattr(self, 'cleaned_data') and \ diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 70570e145..a649ceac1 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -230,7 +230,7 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): return sorted(owns.all(), key=lambda x:x.cached_label) @classmethod - def get_periods(cls, slice='year', fltr={}, date_source='creation'): + def get_periods(cls, slice='month', fltr={}, date_source='creation'): date_var = date_source + '_date' q = cls.objects.filter(**{date_var+'__isnull':False}) if fltr: @@ -258,7 +258,8 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): q = cls.objects.filter(**{date_var+'__isnull':False}) if fltr: q = q.filter(**fltr) - return q.filter(**{date_var+'__year':year, date_var+'__month':month}) + q = q.filter(**{date_var+'__year':year, date_var+'__month':month}) + return q @classmethod def get_total_number(cls, fltr={}): |