Exemple #1
0
class ExportCountryHistory(BaseESModel):
    """Elasticsearch representation of CompanyExportCountryHistory model."""

    id = Keyword()
    history_date = Date(index=False)
    history_user = fields.id_unindexed_name_field()
    history_type = Keyword(index=True)
    country = fields.id_unindexed_name_field()

    company = fields.id_unindexed_name_field()
    status = Keyword(index=False)
    # Adding `date` field, mapping to `history_date` for sorting across entities
    # export_country_history and interaction.
    date = Date()

    MAPPINGS = {
        'history_user': dict_utils.id_name_dict,
        'country': dict_utils.id_name_dict,
        'company': dict_utils.id_name_dict,
    }

    COMPUTED_MAPPINGS = {
        'id': lambda obj: obj.history_id,  # Id required for indexing
        'date': lambda obj: obj.history_date,
    }

    class Meta:
        """Default document meta data."""

        doc_type = DOC_TYPE

    class Index:
        doc_type = DOC_TYPE
class Interaction(BaseESModel):
    """Elasticsearch representation of Interaction model."""

    id = Keyword()
    company = fields.company_field()
    company_sector = fields.sector_field()
    company_one_list_group_tier = fields.id_unindexed_name_field()
    communication_channel = fields.id_unindexed_name_field()
    contacts = _contact_field()
    created_on = Date()
    date = Date()
    dit_participants = Object(_DITParticipant)
    event = fields.id_name_partial_field()
    investment_project = fields.id_unindexed_name_field()
    investment_project_sector = fields.sector_field()
    is_event = Boolean(index=False)
    grant_amount_offered = Double(index=False)
    kind = Keyword()
    modified_on = Date()
    net_company_receipt = Double(index=False)
    notes = fields.Text(index=False)
    policy_areas = fields.id_unindexed_name_field()
    policy_issue_types = fields.id_unindexed_name_field()
    service = fields.id_unindexed_name_field()
    service_delivery_status = fields.id_unindexed_name_field()
    subject = fields.NormalizedKeyword(
        fields={
            'english': fields.EnglishText(),
        },
    )
    was_policy_feedback_provided = Boolean()
    were_countries_discussed = Boolean()
    export_countries = _export_country_field()

    MAPPINGS = {
        'company': dict_utils.company_dict,
        'communication_channel': dict_utils.id_name_dict,
        'contacts': dict_utils.contact_or_adviser_list_of_dicts,
        'dit_participants': _dit_participant_list,
        'export_countries': _export_countries_list,
        'event': dict_utils.id_name_dict,
        'investment_project': dict_utils.id_name_dict,
        'policy_areas': dict_utils.id_name_list_of_dicts,
        'policy_issue_types': dict_utils.id_name_list_of_dicts,
        'service': dict_utils.id_name_dict,
        'service_delivery_status': dict_utils.id_name_dict,
    }

    COMPUTED_MAPPINGS = {
        'company_sector': dict_utils.computed_nested_sector_dict('company.sector'),
        'company_one_list_group_tier': lambda obj: dict_utils.id_name_dict(
            obj.company.get_one_list_group_tier() if obj.company else None,
        ),
        'investment_project_sector': dict_utils.computed_nested_sector_dict(
            'investment_project.sector',
        ),
        'is_event': attrgetter('is_event'),
    }

    SEARCH_FIELDS = (
        'id',
        'company.name',
        'company.name.trigram',
        'contacts.name',  # to find 2-letter words
        'contacts.name.trigram',
        'event.name',
        'event.name.trigram',
        'subject.english',
        'dit_participants.adviser.name',
        'dit_participants.adviser.name.trigram',
        'dit_participants.team.name',
        'dit_participants.team.name.trigram',
    )

    class Meta:
        """Default document meta data."""

        doc_type = DOC_TYPE

    class Index:
        doc_type = DOC_TYPE
Exemple #3
0
class LargeCapitalOpportunity(BaseSearchModel):
    """OpenSearch representation of LargeCapitalOpportunity."""

    id = Keyword()

    name = Text(fields={
        'keyword': fields.NormalizedKeyword(),
        'trigram': fields.TrigramText(),
    }, )
    type = fields.id_unindexed_name_field()

    description = Text(fields={
        'keyword': fields.NormalizedKeyword(),
        'trigram': fields.TrigramText(),
    }, )
    uk_region_locations = fields.id_unindexed_name_field()

    promoters = fields.company_field()

    required_checks_conducted = fields.id_unindexed_name_field()
    required_checks_conducted_by = fields.contact_or_adviser_field(
        include_dit_team=True)
    required_checks_conducted_on = Date()

    lead_dit_relationship_manager = fields.contact_or_adviser_field(
        include_dit_team=True)
    other_dit_contacts = fields.contact_or_adviser_field(include_dit_team=True)

    asset_classes = fields.id_unindexed_name_field()
    opportunity_value_type = fields.id_unindexed_name_field()
    opportunity_value = Long()
    construction_risks = fields.id_unindexed_name_field()

    total_investment_sought = Long()
    current_investment_secured = Long()
    investment_types = fields.id_unindexed_name_field()
    estimated_return_rate = fields.id_unindexed_name_field()
    time_horizons = fields.id_unindexed_name_field()
    investment_projects = fields.id_unindexed_name_field()
    status = fields.id_unindexed_name_field()
    sources_of_funding = fields.id_unindexed_name_field()
    dit_support_provided = Boolean()
    reasons_for_abandonment = fields.id_unindexed_name_field()

    created_by = fields.contact_or_adviser_field(include_dit_team=True)
    created_on = Date()
    modified_on = Date()

    _MAIN_FIELD_MAPPINGS = {
        'type': dict_utils.id_name_dict,
        'status': dict_utils.id_name_dict,
        'created_by': dict_utils.adviser_dict_with_team,
    }

    _DETAIL_FIELD_MAPPINGS = {
        'uk_region_locations': _get_many_to_many_list,
        'promoters': _get_company_list,
        'required_checks_conducted': dict_utils.id_name_dict,
        'required_checks_conducted_by': dict_utils.adviser_dict_with_team,
        'lead_dit_relationship_manager': dict_utils.adviser_dict_with_team,
        'other_dit_contacts': _get_adviser_list,
        'asset_classes': _get_many_to_many_list,
        'opportunity_value_type': dict_utils.id_name_dict,
        'construction_risks': _get_many_to_many_list,
        'investment_projects': _get_investment_project_list,
        'sources_of_funding': _get_many_to_many_list,
        'reasons_for_abandonment': _get_many_to_many_list,
    }

    _REQUIREMENT_FIELD_MAPPINGS = {
        'investment_types': _get_many_to_many_list,
        'estimated_return_rate': dict_utils.id_name_dict,
        'time_horizons': _get_many_to_many_list,
    }

    MAPPINGS = {
        **_MAIN_FIELD_MAPPINGS,
        **_DETAIL_FIELD_MAPPINGS,
        **_REQUIREMENT_FIELD_MAPPINGS,
    }
Exemple #4
0
class LargeInvestorProfile(BaseSearchModel):
    """OpenSearch representation of LargeInvestorProfile."""

    id = Keyword()

    investor_company = fields.company_field()
    country_of_origin = fields.country_field()
    asset_classes_of_interest = fields.id_unindexed_name_field()
    created_by = fields.contact_or_adviser_field(include_dit_team=True)

    investor_type = fields.id_unindexed_name_field()
    global_assets_under_management = Long()
    investable_capital = Long()
    required_checks_conducted = fields.id_unindexed_name_field()

    deal_ticket_sizes = fields.id_unindexed_name_field()
    investment_types = fields.id_unindexed_name_field()
    minimum_return_rate = fields.id_unindexed_name_field()
    time_horizons = fields.id_unindexed_name_field()
    restrictions = fields.id_unindexed_name_field()
    construction_risks = fields.id_unindexed_name_field()
    minimum_equity_percentage = fields.id_unindexed_name_field()
    desired_deal_roles = fields.id_unindexed_name_field()

    uk_region_locations = fields.id_unindexed_name_field()
    other_countries_being_considered = fields.country_field()

    investor_description = fields.EnglishText()
    notes_on_locations = fields.EnglishText()

    created_on = Date()
    modified_on = Date()

    _MAIN_FIELD_MAPPINGS = {
        'asset_classes_of_interest': _get_many_to_many_list,
        'country_of_origin': dict_utils.id_name_dict,
        'investor_company': dict_utils.company_dict,
        'created_by': dict_utils.adviser_dict_with_team,
    }

    _DETAIL_FIELD_MAPPINGS = {
        'investor_type': dict_utils.id_name_dict,
        'required_checks_conducted': dict_utils.id_name_dict,
    }

    _REQUIREMENT_FIELD_MAPPINGS = {
        'deal_ticket_sizes': _get_many_to_many_list,
        'investment_types': _get_many_to_many_list,
        'minimum_return_rate': dict_utils.id_name_dict,
        'time_horizons': _get_many_to_many_list,
        'restrictions': _get_many_to_many_list,
        'construction_risks': _get_many_to_many_list,
        'minimum_equity_percentage': dict_utils.id_name_dict,
        'desired_deal_roles': _get_many_to_many_list,
    }

    _LOCATION_FIELD_MAPPINGS = {
        'uk_region_locations': _get_many_to_many_list,
        'other_countries_being_considered': _get_many_to_many_list,
    }

    MAPPINGS = {
        **_MAIN_FIELD_MAPPINGS,
        **_DETAIL_FIELD_MAPPINGS,
        **_REQUIREMENT_FIELD_MAPPINGS,
        **_LOCATION_FIELD_MAPPINGS,
    }