Skip to content

Feature request: confirm_action, but with configurable choices #13

Closed as not planned
@kbakk

Description

@kbakk

The confirm action is useful when the user is presented with one option and some information about the action.

For some cases it could be useful to present the user with multiple options. A further extension to this could be to add some description on each option.

Some mockup:

**Do you want to mark order 123 from customer jane@example.com as paid?**

<Button: Mark as paid without sending receipt>
Will only mark as paid. 


<Button: Mark as paid and send receipt>
Will send an email after marking the order as paid

API

    @button(
        label="Manage payment",
    )
    def mark_as_paid(self, request, pk):
        order: shop.models.Order = self.get_object(request, pk)

        @multi_action(label="Mark as paid without sending receipt", description="Will only mark as paid.") 
        def _action_charge_order(_request):
            order.charge()
            self.message_user(_request, message="Charged.")

        @multi_action(label="Mark as paid and send receipt", description="Will send an email after marking the order as paid.")
        def _action_charge_order_and_email(_request):
            order.charge_and_email()
            self.message_user(_request, message="Charged and emailed.")

        return confirm_action(
            self,
            request,
            actions=[_action_charge_order, _action_charge_order_and_email],
            message=f"Do you want to mark order {order.pk} from customer {order.custome} as paid",
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions