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', )
class SearchExportCountryHistorySerializer(EntitySearchQuerySerializer): """Serializer used to validate ExportCountryHistory search POST bodies.""" default_error_messages = { 'no_empty_field': gettext_lazy( 'Request must include either country or company parameters', ), } DEFAULT_ORDERING = SearchOrdering('date', SortDirection.desc) SORT_BY_FIELDS = ( 'date', ) country = SingleOrListField(child=StringUUIDField(), required=False) company = SingleOrListField(child=StringUUIDField(), required=False) def validate(self, data): """Serializer should have at least one parameter""" if not data.keys() & {'company', 'country'}: raise serializers.ValidationError( self.error_messages['no_empty_field'], ) return data
class SearchCompanyQuerySerializer(EntitySearchQuerySerializer): """Serialiser used to validate company search POST bodies.""" archived = serializers.BooleanField(required=False) headquarter_type = SingleOrListField( child=StringUUIDField(allow_null=True), required=False, allow_null=True, ) name = serializers.CharField(required=False) sector_descends = SingleOrListField(child=StringUUIDField(), required=False) country = SingleOrListField(child=StringUUIDField(), required=False) uk_based = serializers.BooleanField(required=False) uk_region = SingleOrListField(child=StringUUIDField(), required=False) export_to_countries = SingleOrListField(child=StringUUIDField(), required=False) future_interest_countries = SingleOrListField(child=StringUUIDField(), required=False) one_list_group_global_account_manager = SingleOrListField( child=StringUUIDField(), required=False, ) latest_interaction_date_after = RelaxedDateField(required=False) latest_interaction_date_before = RelaxedDateField(required=False) uk_postcode = SingleOrListField(child=serializers.CharField(), required=False) area = SingleOrListField(child=StringUUIDField(), required=False) SORT_BY_FIELDS = ( 'modified_on', 'name', 'latest_interaction_date', )
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', )
class SearchContactQuerySerializer(EntitySearchQuerySerializer): """Serialiser used to validate contact search POST bodies.""" archived = serializers.BooleanField(required=False) email = serializers.CharField(required=False) name = serializers.CharField(required=False) company = SingleOrListField(child=StringUUIDField(), required=False) company_name = serializers.CharField(required=False) company_sector = SingleOrListField(child=StringUUIDField(), required=False) company_sector_descends = SingleOrListField(child=StringUUIDField(), required=False) company_uk_region = SingleOrListField(child=StringUUIDField(), required=False) address_country = SingleOrListField(child=StringUUIDField(), required=False) address_area = SingleOrListField(child=StringUUIDField(), required=False) created_by = SingleOrListField(child=StringUUIDField(), required=False) created_on_exists = serializers.BooleanField(required=False) SORT_BY_FIELDS = ( 'address_country.name', 'address_area.name', 'company.name', 'created_on', 'last_name', 'modified_on', )
class SearchCompanySerializer(SearchSerializer): """Serialiser used to validate company search POST bodies.""" archived = serializers.BooleanField(required=False) trading_name = serializers.CharField(required=False) description = serializers.CharField(required=False) export_to_country = SingleOrListField(child=StringUUIDField(), required=False) future_interest_country = SingleOrListField(child=StringUUIDField(), required=False) global_headquarters = SingleOrListField(child=StringUUIDField(), required=False) headquarter_type = SingleOrListField( child=StringUUIDField(allow_null=True), required=False, allow_null=True, ) name = serializers.CharField(required=False) sector = SingleOrListField(child=StringUUIDField(), required=False) sector_descends = SingleOrListField(child=StringUUIDField(), required=False) trading_address_country = SingleOrListField(child=StringUUIDField(), required=False) country = SingleOrListField(child=StringUUIDField(), required=False) uk_based = serializers.BooleanField(required=False) uk_region = SingleOrListField(child=StringUUIDField(), required=False) SORT_BY_FIELDS = ( 'trading_name', 'archived', 'archived_by', 'business_type.name', 'classification.name', 'companies_house_data.company_number', 'company_number', 'created_on', 'employee_range.name', 'headquarter_type.name', 'id', 'modified_on', 'name', 'registered_address_town', 'sector.name', 'trading_address_town', 'turnover_range.name', 'uk_based', 'uk_region.name', )
class SearchCompanyQuerySerializer(EntitySearchQuerySerializer): """Serialiser used to validate company search POST bodies.""" archived = serializers.BooleanField(required=False) headquarter_type = SingleOrListField( child=StringUUIDField(allow_null=True), required=False, allow_null=True, ) name = serializers.CharField(required=False) sector_descends = SingleOrListField(child=StringUUIDField(), required=False) country = SingleOrListField(child=StringUUIDField(), required=False) uk_based = serializers.BooleanField(required=False) uk_region = SingleOrListField(child=StringUUIDField(), required=False) SORT_BY_FIELDS = ( 'modified_on', 'name', )
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', )
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', )
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', )
class SearchContactQuerySerializer(EntitySearchQuerySerializer): """Serialiser used to validate contact search POST bodies.""" archived = serializers.BooleanField(required=False) name = serializers.CharField(required=False) company = SingleOrListField(child=StringUUIDField(), required=False) company_name = serializers.CharField(required=False) company_sector = SingleOrListField(child=StringUUIDField(), required=False) company_sector_descends = SingleOrListField(child=StringUUIDField(), required=False) company_uk_region = SingleOrListField(child=StringUUIDField(), required=False) address_country = SingleOrListField(child=StringUUIDField(), required=False) created_by = SingleOrListField(child=StringUUIDField(), required=False) created_on_exists = serializers.BooleanField(required=False) # TODO: Deprecate unused sort by values, and add logging to double-check that they aren't # being used SORT_BY_FIELDS = ( 'address_country.name', 'address_county', 'address_same_as_company', 'address_town', 'adviser.name', 'archived', 'archived_on', 'archived_by.name', 'company.name', 'accepts_dit_email_marketing', 'created_on', 'email', 'first_name', 'id', 'job_title', 'last_name', 'modified_on', 'name', 'primary', 'telephone_countrycode', 'telephone_number', 'title.name', 'company_sector.name', )
class SearchContactSerializer(SearchSerializer): """Serialiser used to validate contact search POST bodies.""" archived = serializers.BooleanField(required=False) name = serializers.CharField(required=False) company = SingleOrListField(child=StringUUIDField(), required=False) company_name = serializers.CharField(required=False) company_sector = SingleOrListField(child=StringUUIDField(), required=False) company_sector_descends = SingleOrListField(child=StringUUIDField(), required=False) company_uk_region = SingleOrListField(child=StringUUIDField(), required=False) address_country = SingleOrListField(child=StringUUIDField(), required=False) created_by = SingleOrListField(child=StringUUIDField(), required=False) created_on_exists = serializers.BooleanField(required=False) SORT_BY_FIELDS = ( 'address_country.name', 'address_county', 'address_same_as_company', 'address_town', 'adviser.name', 'archived', 'archived_on', 'archived_by.name', 'company.name', 'accepts_dit_email_marketing', 'created_on', 'email', 'first_name', 'id', 'job_title', 'last_name', 'modified_on', 'name', 'primary', 'telephone_countrycode', 'telephone_number', 'title.name', 'company_sector.name', )
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', )
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.choices), 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', )
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', )
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', )
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', )