{# One @edit_action / @list_action control. A GET action is a link; a POST action is a small form carrying the CSRF token, so it can change state safely and ask for confirmation first (up-confirm, only allowed on POST actions). Both look the same. variant: "button" (labelled .fcu-btn), "icon" (bare header icon) or "row" (list row icon). target: Unpoly target. A GET link is only followed by Unpoly when one is given; a POST form falls back to #main-content. history: carry up-history="true" (RCRUD tab content). next: optional return URL, posted as "next" for the handler. #} {% macro action_control(construct, action, href, variant="button", target=none, history=false, next=none) %} {%- set label = construct.t(action.name) -%} {%- set cls = {"button": "fcu-btn", "icon": "fcu-icon-action", "row": "fcu-row-action"}[variant] -%} {%- if action.method == "post" -%} {# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
{%- else -%} {{- _action_content(action, label, variant) -}} {%- endif -%} {% endmacro %} {% macro _action_content(action, label, variant) -%} {%- if variant == "button" -%} {{ icon(action.icon, size="sm") }} {{ label }} {%- else -%} {{ icon(action.icon, label=label) }} {%- endif -%} {%- endmacro %}