class InfrastructureFilterSet(StructureRelatedFilterSet): name = CharFilter(label=_('Name'), lookup_expr='icontains') description = CharFilter(label=_('Description'), lookup_expr='icontains') implantation_year = ValueFilter( name='implantation_year', widget=InfrastructureImplantationYearSelect) intervention_year = YearFilter(name='interventions_set__date', widget=InfrastructureYearSelect) def __init__(self, *args, **kwargs): super(InfrastructureFilterSet, self).__init__(*args, **kwargs) field = self.form.fields['type'] field.queryset = field.queryset.exclude( type=INFRASTRUCTURE_TYPES.SIGNAGE) field = self.form.fields['type__type'] all_choices = field.widget.choices all_choices = [ c for c in all_choices if c[0] != INFRASTRUCTURE_TYPES.SIGNAGE ] field.widget.choices = [('', _(u"Category"))] + all_choices[1:] class Meta(StructureRelatedFilterSet.Meta): model = Infrastructure fields = StructureRelatedFilterSet.Meta.fields + [ 'type__type', 'type', 'condition', 'implantation_year', 'intervention_year', 'published' ]
class InterventionFilterSet(StructureRelatedFilterSet): ON_CHOICES = (('infrastructure', _("Infrastructure")), ('signage', _("Signage")), ('blade', _("Blade")), ('topology', _("Path")), ('trek', _("Trek")), ('poi', _("POI")), ('service', _("Service")), ('trail', _("Trail"))) bbox = PolygonTopologyFilter(lookup_expr='intersects') year = YearFilter(field_name='date', widget=InterventionYearSelect, label=_("Year")) on = ChoiceFilter(field_name='target_type__model', choices=ON_CHOICES, label=_("On"), empty_label=_("On")) class Meta(StructureRelatedFilterSet.Meta): model = Intervention fields = StructureRelatedFilterSet.Meta.fields + [ 'status', 'type', 'stake', 'subcontracting', 'project', 'on', ]
class InterventionFilterSet(StructureRelatedFilterSet): bbox = PolygonTopologyFilter(name='topology', lookup_expr='intersects') year = YearFilter(name='date', widget=InterventionYearSelect, label=_(u"Year")) class Meta(StructureRelatedFilterSet.Meta): model = Intervention fields = StructureRelatedFilterSet.Meta.fields + [ 'status', 'type', 'stake', 'subcontracting', 'project' ]
class SignageFilterSet(StructureRelatedFilterSet): intervention_year = YearFilter(name='interventions_set__date', widget=InfrastructureYearSelect) def __init__(self, *args, **kwargs): super(SignageFilterSet, self).__init__(*args, **kwargs) field = self.form.fields['type'] field.queryset = field.queryset.filter(type=INFRASTRUCTURE_TYPES.SIGNAGE) class Meta(StructureRelatedFilterSet.Meta): model = Signage fields = StructureRelatedFilterSet.Meta.fields + ['type']
class SignageFilterSet(StructureRelatedFilterSet): name = CharFilter(label=_('Name'), lookup_expr='icontains') description = CharFilter(label=_('Description'), lookup_expr='icontains') implantation_year = ValueFilter(name='implantation_year', widget=SignageImplantationYearSelect) intervention_year = YearFilter(name='interventions_set__date', widget=InfrastructureYearSelect) def __init__(self, *args, **kwargs): super(SignageFilterSet, self).__init__(*args, **kwargs) field = self.form.fields['type'] field.queryset = field.queryset.filter(type=INFRASTRUCTURE_TYPES.SIGNAGE) class Meta(StructureRelatedFilterSet.Meta): model = Signage fields = StructureRelatedFilterSet.Meta.fields + ['type', 'condition', 'implantation_year', 'intervention_year']
class SignageFilterSet(StructureRelatedFilterSet): name = CharFilter(label=_('Name'), lookup_expr='icontains') description = CharFilter(label=_('Description'), lookup_expr='icontains') implantation_year = ValueFilter(field_name='implantation_year', widget=SignageImplantationYearSelect) intervention_year = YearFilter(field_name='interventions_set__date', widget=SignageYearSelect) def __init__(self, *args, **kwargs): super(SignageFilterSet, self).__init__(*args, **kwargs) class Meta(StructureRelatedFilterSet.Meta): model = Signage fields = StructureRelatedFilterSet.Meta.fields + [ 'type', 'condition', 'implantation_year', 'intervention_year', 'published', 'code', 'printed_elevation', 'manager', 'sealing' ]
class InfrastructureFilterSet(StructureRelatedFilterSet): intervention_year = YearFilter(name='interventions_set__date', widget=InfrastructureYearSelect) def __init__(self, *args, **kwargs): super(InfrastructureFilterSet, self).__init__(*args, **kwargs) field = self.form.fields['type'] field.queryset = field.queryset.exclude(type=INFRASTRUCTURE_TYPES.SIGNAGE) field = self.form.fields['type__type'] all_choices = field.widget.choices all_choices = [c for c in all_choices if c[0] != INFRASTRUCTURE_TYPES.SIGNAGE] field.widget.choices = [('', _(u"Category"))] + all_choices class Meta(StructureRelatedFilterSet.Meta): model = Infrastructure fields = StructureRelatedFilterSet.Meta.fields + ['type__type', 'type']
class InfrastructureFilterSet(StructureRelatedFilterSet): name = CharFilter(label=_('Name'), lookup_expr='icontains') description = CharFilter(label=_('Description'), lookup_expr='icontains') implantation_year = ValueFilter( field_name='implantation_year', widget=InfrastructureImplantationYearSelect) intervention_year = YearFilter(field_name='interventions_set__date', widget=InfrastructureYearSelect) def __init__(self, *args, **kwargs): super(InfrastructureFilterSet, self).__init__(*args, **kwargs) field = self.form.fields['type__type'] all_choices = list(field.widget.choices) field.widget.choices = [('', _("Category"))] + all_choices[1:] class Meta(StructureRelatedFilterSet.Meta): model = Infrastructure fields = StructureRelatedFilterSet.Meta.fields + [ 'type__type', 'type', 'condition', 'implantation_year', 'intervention_year', 'published' ]
class InterventionFilterSet(StructureRelatedFilterSet): ON_CHOICES = (('INFRASTRUCTURE', _("Infrastructure")), ('SIGNAGE', _("Signage"))) bbox = PolygonTopologyFilter(name='topology', lookup_expr='intersects') year = YearFilter(name='date', widget=InterventionYearSelect, label=_(u"Year")) on = ChoiceFilter(name='topology__kind', choices=ON_CHOICES, label=_("On"), empty_label=_("On")) class Meta(StructureRelatedFilterSet.Meta): model = Intervention fields = StructureRelatedFilterSet.Meta.fields + [ 'status', 'type', 'stake', 'subcontracting', 'project', 'on', ]