Skip to content

Delete partners

A delete workflow that remove a partner.

initial_input_form_generator()

Gather input from the user needed for deleting a partner.

Source code in gso/workflows/tasks/delete_partners.py
def initial_input_form_generator() -> FormGenerator:
    """Gather input from the user needed for deleting a partner."""

    class SelectPartnerForm(SubmitFormPage):
        model_config = ConfigDict(title="Delete a Partner")
        partners: partner_choice()  # type: ignore[valid-type]

        @field_validator("partners")
        def validate_partners(cls, value: Enum) -> Enum:
            if get_subscriptions(partner_id=str(value)):
                msg = "This partner has associated data and cannot be removed."
                raise ValueError(msg)

            return value

    initial_user_input = yield SelectPartnerForm

    partner = get_partner_by_name(name=initial_user_input.partners.name)

    return {"email": partner["email"], "name": partner["name"], "partner_id": partner["partner_id"]}

delete_partner_from_database(partner_id, name, email)

Delete a partner from database.

Source code in gso/workflows/tasks/delete_partners.py
@step("Delete partner information from database")
def delete_partner_from_database(
    partner_id: UUIDstr,
    name: str,
    email: EmailStr,
) -> State:
    """Delete a partner from database."""
    delete_partner(partner_id=partner_id)

    return {"deleted_partner": {"name": name, "email": email, "partner_id": partner_id}}

task_delete_partners()

Delete a Partner.

Source code in gso/workflows/tasks/delete_partners.py
@workflow(
    "Delete partners",
    initial_input_form=initial_input_form_generator,
    target=Target.SYSTEM,
)
def task_delete_partners() -> StepList:
    """Delete a Partner."""
    return begin >> delete_partner_from_database >> done