Example #1
0
class ActivityAggregationFilter(ActivityFilter):
    """
    Activity aggregation filter class
    """

    sector_vocabulary = CommaSeparatedStickyCharFilter(
        name='sector__vocabulary__code',
        lookup_expr='in',
    )
Example #2
0
class TransactionAggregationFilter(TransactionFilter):
    """
    Transaction aggregation filter class
    """

    recipient_country = CommaSeparatedStickyCharFilter(
        name='transactionrecipientcountry__country__code',
        lookup_expr='in',
    )

    recipient_region = CommaSeparatedStickyCharFilter(
        name='transactionrecipientregion__region__code',
        lookup_expr='in',
    )

    sector = CommaSeparatedStickyCharFilter(
        name='transactionsector__sector__code',
        lookup_expr='in',
    )

    sector_vocabulary = CommaSeparatedStickyCharFilter(
        name='transactionsector__sector__vocabulary__code',
        lookup_expr='in',
    )

    transaction_recipient_country = CommaSeparatedStickyCharFilter(
        name='transactionrecipientcountry__country__code',
        lookup_expr='in',
    )

    transaction_recipient_region = CommaSeparatedStickyCharFilter(
        name='transactionrecipientregion__region__code',
        lookup_expr='in',
    )

    transaction_sector = CommaSeparatedStickyCharFilter(
        name='transactionsector__sector__code',
        lookup_expr='in',
    )

    policy_marker = CommaSeparatedStickyCharFilter(
        name='activity__activitypolicymarker__code',
        lookup_expr='in',
    )

    policy_marker_significance = CommaSeparatedStickyCharFilter(
        name='activity__activitypolicymarker__significance',
        lookup_expr='in',
    )
Example #3
0
class TransactionAggregationFilter(TransactionFilter):
    """
    Transaction aggregation filter class
    """

    recipient_country = CommaSeparatedStickyCharFilter(
        field_name='transactionrecipientcountry__country__code',
        lookup_expr='in',
    )

    recipient_region = CommaSeparatedStickyCharFilter(
        field_name='transactionrecipientregion__region__code',
        lookup_expr='in',
    )

    sector = CommaSeparatedStickyCharFilter(
        field_name='transactionsector__sector__code',
        lookup_expr='in',
    )

    sector_vocabulary = CommaSeparatedStickyCharFilter(
        field_name='transactionsector__sector__vocabulary__code',
        lookup_expr='in',
    )

    transaction_recipient_country = CommaSeparatedStickyCharFilter(
        field_name='transactionrecipientcountry__country__code',
        lookup_expr='in',
    )

    transaction_recipient_region = CommaSeparatedStickyCharFilter(
        field_name='transactionrecipientregion__region__code',
        lookup_expr='in',
    )

    transaction_sector = CommaSeparatedStickyCharFilter(
        field_name='transactionsector__sector__code',
        lookup_expr='in',
    )

    policy_marker = CommaSeparatedStickyCharFilter(
        field_name='activity__activitypolicymarker__code',
        lookup_expr='in',
    )

    policy_marker_significance = CommaSeparatedStickyCharFilter(
        field_name='activity__activitypolicymarker__significance',
        lookup_expr='in',
    )

    #
    # Aggregated Budget values filters
    #

    total_budget_lte = NumberFilter(
        lookup_expr='lte',
        field_name='activity__activity_aggregation__budget_value')

    total_budget_gte = NumberFilter(
        lookup_expr='gte',
        field_name='activity__activity_aggregation__budget_value')
Example #4
0
class ResultFilter(TogetherFilterSet):

    activity_id = CommaSeparatedCharFilter(
        field_name='activity__iati_identifier', lookup_expr='in')

    result_title = CommaSeparatedStickyCharFilter(
        field_name='resulttitle__primary_name',
        lookup_expr='in',
    )

    indicator_title = CommaSeparatedStickyCharFilter(
        field_name='resultindicator__resultindicatortitle__primary_name',
        lookup_expr='in',
    )

    indicator_period_actual_null = StickyBooleanFilter(
        lookup_expr='isnull',
        field_name='resultindicator__resultindicatorperiod__actual')

    result_indicator_period_end_year = StickyCharFilter(
        field_name='resultindicator__resultindicatorperiod__period_end',
        lookup_expr='year')

    # default filters
    activity_scope = CommaSeparatedCharFilter(
        field_name='activity__scope__code',
        lookup_expr='in',
    )

    planned_start_date_lte = DateFilter(lookup_expr='lte',
                                        field_name='activity__planned_start')

    planned_start_date_gte = DateFilter(lookup_expr='gte',
                                        field_name='activity__planned_start')

    actual_start_date_lte = DateFilter(lookup_expr='lte',
                                       field_name='activity__actual_start')

    actual_start_date_gte = DateFilter(lookup_expr='gte',
                                       field_name='activity__actual_start')

    planned_end_date_lte = DateFilter(lookup_expr='lte',
                                      field_name='activity__planned_end')

    planned_end_date_gte = DateFilter(lookup_expr='gte',
                                      field_name='activity__planned_end')

    actual_end_date_lte = DateFilter(lookup_expr='lte',
                                     field_name='activity__actual_end')

    actual_end_date_gte = DateFilter(lookup_expr='gte',
                                     field_name='activity__actual_end')

    end_date_lte = DateFilter(lookup_expr='lte',
                              field_name='activity__end_date')

    end_date_gte = DateFilter(lookup_expr='gte',
                              field_name='activity__end_date')

    start_date_lte = DateFilter(lookup_expr='lte',
                                field_name='activity__start_date')

    start_date_gte = DateFilter(lookup_expr='gte',
                                field_name='activity__start_date')

    end_date_isnull = BooleanFilter(field_name='activity__end_date__isnull')
    start_date_isnull = BooleanFilter(
        field_name='activity__start_date__isnull')

    activity_status = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__activity_status',
    )

    document_link_category = ToManyFilter(
        main_fk='activity',
        qs=DocumentLink,
        fk='activity',
        lookup_expr='in',
        field_name='categories__code',
    )

    hierarchy = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__hierarchy',
    )

    collaboration_type = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__collaboration_type',
    )

    default_flow_type = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__default_flow_type',
    )

    default_aid_type = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__default_aid_type',
    )

    default_finance_type = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__default_finance_type',
    )

    default_tied_status = CommaSeparatedCharFilter(
        lookup_expr='in',
        field_name='activity__default_tied_status',
    )

    budget_period_start = DateFilter(
        lookup_expr='gte',
        field_name='activity__budget__period_start',
    )

    budget_period_end = DateFilter(lookup_expr='lte',
                                   field_name='activity__budget__period_end')

    recipient_country = ToManyFilter(
        main_fk='activity',
        qs=ActivityRecipientCountry,
        lookup_expr='in',
        field_name='country__code',
        fk='activity',
    )

    recipient_region = ToManyFilter(
        main_fk='activity',
        qs=ActivityRecipientRegion,
        lookup_expr='in',
        field_name='region__code',
        fk='activity',
    )

    sector = ToManyFilter(
        main_fk='activity',
        qs=ActivitySector,
        lookup_expr='in',
        field_name='sector__code',
        fk='activity',
    )

    sector_vocabulary = ToManyFilter(
        main_fk='activity',
        qs=ActivitySector,
        lookup_expr='in',
        field_name='sector__vocabulary__code',
        fk='activity',
    )

    sector_category = ToManyFilter(
        main_fk='activity',
        qs=ActivitySector,
        lookup_expr='in',
        field_name='sector__category__code',
        fk='activity',
    )

    participating_organisation = ToManyFilter(
        main_fk='activity',
        qs=ActivityParticipatingOrganisation,
        lookup_expr='in',
        field_name='normalized_ref',
        fk='activity',
    )

    participating_organisation_name = ToManyFilter(
        main_fk='activity',
        qs=ActivityParticipatingOrganisation,
        lookup_expr='in',
        field_name='primary_name',
        fk='activity',
    )

    participating_organisation_role = ToManyFilter(
        main_fk='activity',
        qs=ActivityParticipatingOrganisation,
        lookup_expr='in',
        field_name='role__code',
        fk='activity',
    )

    participating_organisation_type = ToManyFilter(
        main_fk='activity',
        qs=ActivityParticipatingOrganisation,
        lookup_expr='in',
        field_name='type__code',
        fk='activity',
    )

    reporting_organisation_identifier = ToManyFilter(
        main_fk='activity',
        qs=ActivityReportingOrganisation,
        lookup_expr='in',
        field_name='organisation__organisation_identifier',
        fk='activity',
    )

    related_activity_id = ToManyFilter(
        main_fk='activity',
        qs=RelatedActivity,
        fk='current_activity',
        lookup_expr='in',
        field_name='ref_activity__iati_identifier',
    )

    total_incoming_funds_lte = NumberFilter(
        lookup_expr='lte',
        field_name='activity__activity_aggregation__incoming_funds_value')

    total_incoming_funds_gte = NumberFilter(
        lookup_expr='gte',
        field_name='activity__activity_aggregation__incoming_funds_value')

    class Meta:
        model = Result
        fields = '__all__'