Example #1
0
class SearchOrderSerializer(SearchSerializer):
    """Serialiser used to validate OMIS search POST bodies."""

    primary_market = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(), required=False)
    uk_region = SingleOrListField(child=StringUUIDField(), required=False)
    created_on_before = RelaxedDateTimeField(required=False)
    created_on_after = RelaxedDateTimeField(required=False)
    assigned_to_adviser = SingleOrListField(child=StringUUIDField(), required=False)
    assigned_to_team = SingleOrListField(child=StringUUIDField(), required=False)
    status = SingleOrListField(child=serializers.CharField(), required=False)
    reference = SingleOrListField(child=serializers.CharField(), required=False)
    total_cost = serializers.IntegerField(required=False)
    subtotal_cost = serializers.IntegerField(required=False)
    contact_name = serializers.CharField(required=False)
    company = SingleOrListField(child=StringUUIDField(), required=False)
    company_name = serializers.CharField(required=False)

    DEFAULT_ORDERING = 'created_on:desc'

    SORT_BY_FIELDS = (
        'created_on',
        'modified_on',
        'delivery_date',
        'payment_due_date',
    )
Example #2
0
class SearchInteractionSerializer(SearchSerializer):
    """Serialiser used to validate interaction search POST bodies."""

    kind = SingleOrListField(child=serializers.CharField(), required=False)
    company = SingleOrListField(child=StringUUIDField(), required=False)
    company_name = serializers.CharField(required=False)
    contact = SingleOrListField(child=StringUUIDField(), required=False)
    contact_name = serializers.CharField(required=False)
    date_after = RelaxedDateTimeField(required=False)
    date_before = RelaxedDateTimeField(required=False)
    created_on_exists = serializers.BooleanField(required=False)
    dit_adviser = SingleOrListField(child=StringUUIDField(), required=False)
    dit_adviser_name = serializers.CharField(required=False)
    dit_team = SingleOrListField(child=StringUUIDField(), required=False)
    communication_channel = SingleOrListField(child=StringUUIDField(),
                                              required=False)
    investment_project = SingleOrListField(child=StringUUIDField(),
                                           required=False)
    service = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(),
                                        required=False)

    DEFAULT_ORDERING = 'date:desc'

    SORT_BY_FIELDS = (
        'company.name',
        'contact.name',
        'date',
        'dit_adviser.name',
        'dit_team.name',
        'id',
        'subject',
    )
Example #3
0
class SearchEventSerializer(SearchSerializer):
    """Serialiser used to validate Event search POST bodies.

    Nested disabled_on filters use "or" operator. For example if you want to
    find events that were disabled after certain date, but also those that
    have not been disabled.
    """

    address_country = SingleOrListField(child=StringUUIDField(),
                                        required=False)
    disabled_on = NestedDisabledOnOrFilterSerializer(required=False)
    disabled_on_exists = serializers.BooleanField(required=False)
    event_type = SingleOrListField(child=StringUUIDField(), required=False)
    lead_team = SingleOrListField(child=StringUUIDField(), required=False)
    name = serializers.CharField(required=False)
    organiser = SingleOrListField(child=StringUUIDField(), required=False)
    organiser_name = serializers.CharField(required=False)
    start_date_after = RelaxedDateTimeField(required=False)
    start_date_before = RelaxedDateTimeField(required=False)
    teams = SingleOrListField(child=StringUUIDField(), required=False)
    uk_region = SingleOrListField(child=StringUUIDField(), required=False)

    SORT_BY_FIELDS = (
        'id',
        'name',
        'created_on',
        'modified_on',
        'start_date',
        'end_date',
    )
Example #4
0
class SearchOrderQuerySerializer(EntitySearchQuerySerializer):
    """Serialiser used to validate OMIS search POST bodies."""

    primary_market = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(), required=False)
    uk_region = SingleOrListField(child=StringUUIDField(), required=False)
    # Note that completed_on is a DateTime field, but we only allow filtering using whole dates
    # for simplicity
    # OpenSearch sets the time component for completed_on_before to 23:59:59.999 automatically
    completed_on_before = RelaxedDateField(required=False)
    completed_on_after = RelaxedDateField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)
    created_on_after = RelaxedDateTimeField(required=False)
    delivery_date_before = RelaxedDateField(required=False)
    delivery_date_after = RelaxedDateField(required=False)
    assigned_to_adviser = SingleOrListField(child=StringUUIDField(), required=False)
    assigned_to_team = SingleOrListField(child=StringUUIDField(), required=False)
    status = SingleOrListField(child=serializers.CharField(), required=False)
    reference = SingleOrListField(child=serializers.CharField(), required=False)
    total_cost = serializers.IntegerField(required=False)
    subtotal_cost = serializers.IntegerField(required=False)
    contact_name = serializers.CharField(required=False)
    company = SingleOrListField(child=StringUUIDField(), required=False)
    company_name = serializers.CharField(required=False)

    DEFAULT_ORDERING = SearchOrdering('created_on', SortDirection.desc)

    SORT_BY_FIELDS = (
        'created_on',
        'modified_on',
        'delivery_date',
        'payment_due_date',
    )
Example #5
0
class SearchInteractionQuerySerializer(EntitySearchQuerySerializer):
    """Serialiser used to validate interaction search POST bodies."""

    kind = SingleOrListField(child=serializers.CharField(), required=False)
    company = SingleOrListField(child=StringUUIDField(), required=False)
    company_name = serializers.CharField(required=False)
    company_one_list_group_tier = SingleOrListField(child=StringUUIDField(), required=False)
    date_after = RelaxedDateTimeField(required=False)
    date_before = RelaxedDateTimeField(required=False)
    created_on_exists = serializers.BooleanField(required=False)
    dit_participants__adviser = SingleOrListField(child=StringUUIDField(), required=False)
    dit_participants__team = SingleOrListField(child=StringUUIDField(), required=False)
    communication_channel = SingleOrListField(child=StringUUIDField(), required=False)
    investment_project = SingleOrListField(child=StringUUIDField(), required=False)
    policy_areas = SingleOrListField(child=StringUUIDField(), required=False)
    policy_issue_types = SingleOrListField(child=StringUUIDField(), required=False)
    service = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(), required=False)
    was_policy_feedback_provided = serializers.BooleanField(required=False)

    DEFAULT_ORDERING = SearchOrdering('date', SortDirection.desc)

    SORT_BY_FIELDS = (
        'company.name',
        'date',
        'subject',
    )
Example #6
0
class SearchCompaniesHouseCompanySerializer(SearchSerializer):
    """Serialiser used to validate companies house company POST bodies."""

    name = serializers.CharField(required=False)
    company_number = serializers.CharField(required=False)
    company_status = SingleOrListField(child=serializers.CharField(),
                                       required=False)
    incorporation_date_after = RelaxedDateTimeField(required=False)
    incorporation_date_before = RelaxedDateTimeField(required=False)

    SORT_BY_FIELDS = (
        'incorporation_date',
        'name',
    )
Example #7
0
class TimelineEventSerializer(serializers.Serializer):
    """Company timeline event serialiser."""

    data_source = serializers.CharField()
    data_source_label = serializers.CharField()
    datetime = RelaxedDateTimeField()
    description = serializers.CharField()
Example #8
0
class NestedDisabledOnQuerySerializer(serializers.Serializer):
    """
    Serialiser used to validate disabled_on filter.

    Validated data uses "or" operator. For example if you want to
    find events that were disabled after certain date, but also those that
    have not been disabled.
    """

    exists = serializers.BooleanField(required=False)
    after = RelaxedDateTimeField(required=False)
class SearchInvestmentProjectQuerySerializer(EntitySearchQuerySerializer):
    """Serialiser used to validate investment project search POST bodies."""

    adviser = SingleOrListField(child=StringUUIDField(), required=False)
    client_relationship_manager = SingleOrListField(child=StringUUIDField(), required=False)
    created_on_after = RelaxedDateTimeField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)
    actual_land_date_after = RelaxedDateTimeField(required=False)
    actual_land_date_before = RelaxedDateTimeField(required=False)
    estimated_land_date_after = RelaxedDateTimeField(required=False)
    estimated_land_date_before = RelaxedDateTimeField(required=False)
    investment_type = SingleOrListField(child=StringUUIDField(), required=False)
    investor_company = SingleOrListField(child=StringUUIDField(), required=False)
    investor_company_country = SingleOrListField(child=StringUUIDField(), required=False)
    country_investment_originates_from = SingleOrListField(child=StringUUIDField(), required=False)
    likelihood_to_land = SingleOrListField(child=StringUUIDField(), required=False)
    sector = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(), required=False)
    stage = SingleOrListField(child=StringUUIDField(), required=False)
    status = SingleOrListField(child=serializers.CharField(), required=False)
    uk_region_location = SingleOrListField(child=StringUUIDField(), required=False)
    level_of_involvement_simplified = SingleOrListField(
        child=serializers.ChoiceField(choices=InvestmentProject.INVOLVEMENT),
        required=False,
    )
    gross_value_added_start = serializers.IntegerField(required=False, min_value=0)
    gross_value_added_end = serializers.IntegerField(required=False, min_value=0)

    SORT_BY_FIELDS = (
        'created_on',
        'estimated_land_date',
        'name',
        'stage.name',
    )
Example #10
0
class NestedDisabledOnOrFilterSerializer(serializers.Serializer):
    """Serialiser used to validate disabled_on filter."""

    exists = serializers.BooleanField(required=False)
    after = RelaxedDateTimeField(required=False)
class SearchInvestmentProjectQuerySerializer(EntitySearchQuerySerializer):
    """Serialiser used to validate investment project search POST bodies."""

    adviser = SingleOrListField(child=StringUUIDField(), required=False)
    client_relationship_manager = SingleOrListField(child=StringUUIDField(),
                                                    required=False)
    created_on_after = RelaxedDateTimeField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)
    actual_land_date_after = RelaxedDateTimeField(required=False)
    actual_land_date_before = RelaxedDateTimeField(required=False)
    estimated_land_date_after = RelaxedDateTimeField(required=False)
    estimated_land_date_before = RelaxedDateTimeField(required=False)
    investment_type = SingleOrListField(child=StringUUIDField(),
                                        required=False)
    investor_company = SingleOrListField(child=StringUUIDField(),
                                         required=False)
    investor_company_country = SingleOrListField(child=StringUUIDField(),
                                                 required=False)
    country_investment_originates_from = SingleOrListField(
        child=StringUUIDField(), required=False)
    likelihood_to_land = SingleOrListField(child=StringUUIDField(),
                                           required=False)
    sector = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(),
                                        required=False)
    stage = SingleOrListField(child=StringUUIDField(), required=False)
    status = SingleOrListField(child=serializers.CharField(), required=False)
    uk_region_location = SingleOrListField(child=StringUUIDField(),
                                           required=False)
    level_of_involvement_simplified = SingleOrListField(
        child=serializers.ChoiceField(choices=InvestmentProject.INVOLVEMENT),
        required=False,
    )
    gross_value_added_start = serializers.IntegerField(required=False,
                                                       min_value=0)
    gross_value_added_end = serializers.IntegerField(required=False,
                                                     min_value=0)

    # TODO: Deprecate unused sort by values, and add logging to double-check that they aren't
    #  being used
    SORT_BY_FIELDS = (
        'actual_land_date',
        'approved_commitment_to_invest',
        'approved_fdi',
        'approved_good_value',
        'approved_high_value',
        'approved_landed',
        'approved_non_fdi',
        'archived',
        'archived_by.name',
        'average_salary.name',
        'business_activities.name',
        'client_cannot_provide_total_investment',
        'client_contacts.name',
        'client_relationship_manager.name',
        'created_on',
        'estimated_land_date',
        'export_revenue',
        'fdi_type.name',
        'foreign_equity_investment',
        'government_assistance',
        'id',
        'intermediate_company.name',
        'investment_type.name',
        'investor_company.name',
        'likelihood_to_land.name',
        'modified_on',
        'name',
        'new_tech_to_uk',
        'non_fdi_r_and_d_budget',
        'number_new_jobs',
        'project_assurance_adviser.name',
        'project_code',
        'project_manager.name',
        'r_and_d_budget',
        'referral_source_activity.name',
        'referral_source_activity_event',
        'referral_source_activity_marketing.name',
        'referral_source_activity_website.name',
        'referral_source_adviser.name',
        'sector.name',
        'site_decided',
        'stage.name',
        'total_investment',
        'uk_company.name',
    )
Example #12
0
class SearchInvestmentProjectSerializer(SearchSerializer):
    """Serialiser used to validate investment project search POST bodies."""

    adviser = SingleOrListField(child=StringUUIDField(), required=False)
    client_relationship_manager = SingleOrListField(child=StringUUIDField(),
                                                    required=False)
    created_on_after = RelaxedDateTimeField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)
    actual_land_date_after = RelaxedDateTimeField(required=False)
    actual_land_date_before = RelaxedDateTimeField(required=False)
    estimated_land_date_after = RelaxedDateTimeField(required=False)
    estimated_land_date_before = RelaxedDateTimeField(required=False)
    investment_type = SingleOrListField(child=StringUUIDField(),
                                        required=False)
    investor_company = SingleOrListField(child=StringUUIDField(),
                                         required=False)
    investor_company_country = SingleOrListField(child=StringUUIDField(),
                                                 required=False)
    sector = SingleOrListField(child=StringUUIDField(), required=False)
    sector_descends = SingleOrListField(child=StringUUIDField(),
                                        required=False)
    stage = SingleOrListField(child=StringUUIDField(), required=False)
    status = SingleOrListField(child=serializers.CharField(), required=False)
    uk_region_location = SingleOrListField(child=StringUUIDField(),
                                           required=False)

    SORT_BY_FIELDS = (
        'actual_land_date',
        'approved_commitment_to_invest',
        'approved_fdi',
        'approved_good_value',
        'approved_high_value',
        'approved_landed',
        'approved_non_fdi',
        'archived',
        'archived_by.name',
        'average_salary.name',
        'business_activities.name',
        'client_cannot_provide_total_investment',
        'client_contacts.name',
        'client_relationship_manager.name',
        'created_on',
        'estimated_land_date',
        'export_revenue',
        'fdi_type.name',
        'foreign_equity_investment',
        'government_assistance',
        'id',
        'intermediate_company.name',
        'investment_type.name',
        'investor_company.name',
        'modified_on',
        'name',
        'new_tech_to_uk',
        'non_fdi_r_and_d_budget',
        'number_new_jobs',
        'project_assurance_adviser.name',
        'project_code',
        'project_manager.name',
        'r_and_d_budget',
        'referral_source_activity.name',
        'referral_source_activity_event',
        'referral_source_activity_marketing.name',
        'referral_source_activity_website.name',
        'referral_source_adviser.name',
        'sector.name',
        'site_decided',
        'stage.name',
        'total_investment',
        'uk_company.name',
    )
Example #13
0
class SearchLargeInvestorProfileQuerySerializer(EntitySearchQuerySerializer):
    """Serializer used to validate investor profile search POST bodies."""

    id = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Main filters
    asset_classes_of_interest = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    country_of_origin = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    investor_company = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    investor_company_name = CharField(required=False)
    created_by = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Detail filters
    investor_type = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    required_checks_conducted = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    global_assets_under_management_start = IntegerField(required=False)
    global_assets_under_management_end = IntegerField(required=False)
    investable_capital_start = IntegerField(required=False)
    investable_capital_end = IntegerField(required=False)

    # Requirement filters
    deal_ticket_size = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    investment_type = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    minimum_return_rate = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    time_horizon = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    restriction = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    construction_risk = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    minimum_equity_percentage = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    desired_deal_role = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Location filters
    uk_region_location = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    other_countries_being_considered = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Extra filters
    created_on_after = RelaxedDateTimeField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)

    SORT_BY_FIELDS = (
        'created_on',
        'modified_on',
        'investor_company.name',
        'global_assets_under_management',
        'investable_capital',
    )
Example #14
0
class SearchLargeCapitalOpportunityQuerySerializer(EntitySearchQuerySerializer
                                                   ):
    """Serializer used to validate large capital opportunity search POST bodies."""

    id = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Main filters
    type = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    status = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    name = CharField(required=False)

    created_by = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Detail filters
    uk_region_location = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    promoter = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    promoter_name = CharField(required=False)
    lead_dit_relationship_manager = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    required_checks_conducted = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    required_checks_conducted_by = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    asset_class = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    opportunity_value_type = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    opportunity_value_start = IntegerField(required=False)
    opportunity_value_end = IntegerField(required=False)
    construction_risk = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Requirement filters
    total_investment_sought_start = IntegerField(required=False)
    total_investment_sought_end = IntegerField(required=False)
    current_investment_secured_start = IntegerField(required=False)
    current_investment_secured_end = IntegerField(required=False)
    investment_type = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    estimated_return_rate = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )
    time_horizon = SingleOrListField(
        child=StringUUIDField(),
        required=False,
    )

    # Extra filters
    created_on_after = RelaxedDateTimeField(required=False)
    created_on_before = RelaxedDateTimeField(required=False)

    SORT_BY_FIELDS = (
        'created_on',
        'modified_on',
        'name',
    )