Skip to content

Shared

Shared functions for the workflows.

summary_form(product_name, summary_data)

Generate a summary form for the product.

Source code in gso/workflows/shared.py
def summary_form(product_name: str, summary_data: dict) -> Generator:
    """Generate a summary form for the product."""

    class SummaryForm(SubmitFormPage):
        model_config = ConfigDict(title=f"{product_name} summary")

        product_summary: cast(type[MigrationSummary], migration_summary(summary_data))  # type: ignore[valid-type]

    yield SummaryForm

create_summary_form(user_input, product_name, fields)

Create a summary form for the product.

Source code in gso/workflows/shared.py
def create_summary_form(user_input: dict, product_name: str, fields: list[str]) -> Generator:
    """Create a summary form for the product."""
    columns = [[str(user_input[nm]) for nm in fields]]
    yield from summary_form(product_name, {"labels": fields, "columns": columns})

modify_summary_form(user_input, block, fields)

Modify the summary form for the product.

Source code in gso/workflows/shared.py
def modify_summary_form(user_input: dict, block: ProductBlockModel, fields: list[str]) -> Generator:
    """Modify the summary form for the product."""
    before = [str(getattr(block, nm)) for nm in fields]
    after = [str(user_input[nm]) for nm in fields]
    yield from summary_form(
        block.subscription.product.name,
        {
            "labels": fields,
            "headers": ["Before", "After"],
            "columns": [before, after],
        },
    )