diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-12 18:55:58 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-12 18:55:58 +0200 |
commit | cae951766530d6ada5240f9f3d9653b017a30a98 (patch) | |
tree | 12dae6dbcb1dd5594998582ecfa97c8d752906e5 /ishtar_common/views.py | |
parent | eb481f63dce8af51c2e6e3269723f775232b9802 (diff) | |
download | Ishtar-cae951766530d6ada5240f9f3d9653b017a30a98.tar.bz2 Ishtar-cae951766530d6ada5240f9f3d9653b017a30a98.zip |
Treament dashboard: add filter form (refs #3381)
Diffstat (limited to 'ishtar_common/views.py')
-rw-r--r-- | ishtar_common/views.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py index e8a2c9e12..4aa452641 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -63,6 +63,7 @@ from archaeological_finds.models import Find, Treatment, TreatmentFile, \ from archaeological_operations.forms import DashboardForm as DashboardFormOpe from archaeological_files.forms import DashboardForm as DashboardFormFile +from archaeological_finds.forms import DashboardTreatmentForm from ishtar_common.forms import FinalForm, FinalDeleteForm from ishtar_common.widgets import JQueryAutoComplete @@ -1458,7 +1459,10 @@ def dashboard_main(request, dct, obj_id=None, *args, **kwargs): return render_to_response('ishtar/dashboards/dashboard_main.html', dct, context_instance=RequestContext(request)) -DASHBOARD_FORMS = {'files': DashboardFormFile, 'operations': DashboardFormOpe} +DASHBOARD_FORMS = { + 'files': DashboardFormFile, 'operations': DashboardFormOpe, + 'treatments': DashboardTreatmentForm +} def dashboard_main_detail(request, item_name): @@ -1473,8 +1477,11 @@ def dashboard_main_detail(request, item_name): form = None slicing, date_source, fltr, show_detail = 'year', None, {}, False profile = models.get_current_profile() - if (item_name == 'files' and profile.files) \ - or item_name == 'operations': + has_form = (item_name == 'files' and profile.files) \ + or item_name == 'operations' \ + or (item_name in ('treatmentfiles', 'treatments') + and profile.warehouse) + if has_form: slicing = 'month' if item_name in DASHBOARD_FORMS: if request.method == 'POST': @@ -1490,8 +1497,7 @@ def dashboard_main_detail(request, item_name): form = DASHBOARD_FORMS[item_name]() lbl, dashboard = None, None dashboard_kwargs = {} - if (item_name == 'files' and profile.files) \ - or item_name == 'operations': + if has_form: dashboard_kwargs = {'slice': slicing, 'fltr': fltr, 'show_detail': show_detail} # date_source is only relevant when the form has set one @@ -1515,12 +1521,13 @@ def dashboard_main_detail(request, item_name): elif item_name == 'treatmentfiles' and profile.warehouse: lbl, dashboard = ( _(u"Treatment requests"), - models.Dashboard(TreatmentFile, slice=slicing, fltr=fltr)) + models.Dashboard(TreatmentFile, **dashboard_kwargs)) elif item_name == 'treatments' and profile.warehouse: + if 'date_source' not in dashboard_kwargs: + dashboard_kwargs['date_source'] = 'start' lbl, dashboard = ( _(u"Treatments"), - models.Dashboard(Treatment, slice=slicing, fltr=fltr, - date_source='start')) + models.Dashboard(Treatment, **dashboard_kwargs)) if not lbl: raise Http404 dct = {'lbl': lbl, 'dashboard': dashboard, |