Skip to content

Staff search

OpenSearch index

The Staff search uses an OpenSearch index to store the data.

Staff index mapping schema

core/utils/staff_index.py
STAFF_INDEX_BODY: Mapping[str, Any] = {
    "mappings": {
        "properties": {
            "uuid": {"type": "text"},
            "available_in_staff_sso": {"type": "boolean"},
            "staff_sso_activity_stream_id": {"type": "text"},
            "staff_sso_email_user_id": {"type": "text"},
            "staff_sso_legacy_id": {"type": "text"},
            "staff_sso_first_name": {"type": "text"},
            "staff_sso_last_name": {"type": "text"},
            "staff_sso_contact_email_address": {"type": "text"},
            "staff_sso_email_addresses": {"type": "text"},  # Can accept list
            "people_finder_first_name": {"type": "text"},
            "people_finder_last_name": {"type": "text"},
            "people_finder_job_title": {"type": "text"},
            "people_finder_directorate": {"type": "text"},
            "people_finder_phone": {"type": "text"},
            "people_finder_grade": {"type": "text"},
            "people_finder_email": {"type": "text"},
            "people_finder_photo": {"type": "text"},
            "people_finder_photo_small": {"type": "text"},
        },
    },
}

Staff search component

Staff search component

Example implementation

Add char field to the form

Add a char field to a form to hold the inital staff_uuid value and use the HTMX component to render the form field.

leavers/forms/leaver.py
    ReturnOptions,
    SecurityClearance,
    StaffType,
    WhoIsLeaving,
)


class WhoIsLeavingForm(BaseForm):
    required_error_messages: Dict[str, str] = {
        "who": "Please tell us who you are offboarding.",
    }

    who = forms.ChoiceField(
        label="Who are you offboarding?",
        widget=forms.RadioSelect,
        choices=WhoIsLeaving.choices,
    )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.layout = Layout(

Suppling search_url to the staff_search_autocomplete_field method, will tell the component which search view to use that will handle storing the data.

Suppling remove_url to the staff_search_autocomplete_field method, will tell the component which view will handle the logic to clear the data.

Create a custom search view

Add a View that inherits StaffSearchView to handle the search.

leavers/views/leaver.py
class WhoIsLeavingView(BaseTemplateView, FormView):
    template_name = "leaving/who_is_leaving.html"

The query_param_name is the name of the query param that will be used to pass the staff_uuid back to the success_url to be stored somewhere.