Example #1
0
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'
        ]
Example #2
0
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',
        ]
Example #3
0
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'
        ]
Example #4
0
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']
Example #5
0
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']
Example #6
0
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'
        ]
Example #7
0
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']
Example #8
0
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'
        ]
Example #9
0
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',
        ]