diff options
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/forms.py | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 06ee160d0..7203da6c6 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -673,84 +673,6 @@ class OperationFormFileChoice(IshtarForm): validators=[valid_id(File)], required=False) -SLICING = (("month", _("months")), ('year', _("years")),) - -DATE_SOURCE = (('creation', _("Creation date")), - ("start", _("Start of field work"))) - -PREVENTIVE_RESARCH = (('all', _('All')), - ('preventive', _("Preventive")), - ('research', _("Research")),) - - -class DashboardForm(IshtarForm): - 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) - preventive_research = forms.ChoiceField( - label=_("Preventive/Research"), choices=PREVENTIVE_RESARCH, - required=False) - operation_type = forms.ChoiceField(label=_("Operation type"), choices=[], - required=False) - operator = forms.ChoiceField(label=_("Operator"), choices=[], - required=False) - after = DateField(label=_("Date after"), required=False) - before = DateField(label=_("Date before"), required=False) - with_report = forms.BooleanField(label=_("With reports"), required=False) - with_finds = forms.BooleanField(label=_("With finds"), required=False) - - def __init__(self, *args, **kwargs): - if 'prefix' not in kwargs: - kwargs['prefix'] = 'operations' - super(DashboardForm, self).__init__(*args, **kwargs) - self.fields['operation_type'].choices = \ - models.OperationType.get_types() - self.fields['operator'].choices = [('', '--')] - self.fields['operator'].choices += [ - (orga.pk, orga.name) - for orga in Organization.objects.filter(operator__isnull=False) - .order_by('name').distinct().all()] - - 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 \ - 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('preventive_research'): - preventive_research = self.cleaned_data['preventive_research'] - if preventive_research == 'preventive': - fltr['operation_type__preventive'] = True - elif preventive_research == 'research': - fltr['operation_type__preventive'] = False - if self.cleaned_data.get('operation_type'): - fltr['operation_type_id'] = self.cleaned_data['operation_type'] - if self.cleaned_data.get('operator'): - fltr['operator_id'] = self.cleaned_data['operator'] - if self.cleaned_data.get('after'): - fltr[date_source + '_date__gte'] = self.cleaned_data['after'] - if self.cleaned_data.get('before'): - fltr[date_source + '_date__lte'] = self.cleaned_data['before'] - if self.cleaned_data.get('with_report'): - fltr['report_delivery_date__isnull'] = False - if self.cleaned_data.get('with_finds'): - fltr['context_record__base_finds__isnull'] = False - return fltr - - class OperationFormGeneral(CustomForm, ManageOldType): HEADERS = {} form_label = _("General") |