Simplify group create/edit templates

This also introduces the footer actions and unsaved changes warning
to these views.
pull/12425/head
Sage Abdullah 2024-10-10 17:18:08 +01:00 zatwierdzone przez Thibaud Colas
rodzic fc05b3eb59
commit 6fef75376e
2 zmienionych plików z 21 dodań i 57 usunięć

Wyświetl plik

@ -1,26 +1,28 @@
{% extends "wagtailadmin/generic/create.html" %}
{% load wagtailusers_tags i18n wagtailadmin_tags %}
{% block main_content %}
<form action="{% url 'wagtailusers_groups:add' %}" method="POST" novalidate>
{% csrf_token %}
{% block form_content %}
{% block fields %}
{% comment %}
This block is not documented, but developers might assume its existence
based on the docs for custom user forms.
{% endcomment %}
{% panel id="name" heading=form.name.label id_for_label=form.name.id_for_label is_required=True %}
{% formattedfield field=form.name show_label=False %}
{% endpanel %}
<div class="w-form-width">
{# This block is documented in the docs for customizing group views #}
{% block extra_fields %}{% endblock extra_fields %}
{% format_permissions permission_bound_field=form.permissions %}
<ul class="fields">
{% block fields %}
<li>{% formattedfield form.name %}</li>
{% block extra_fields %}{% endblock extra_fields %}
{% endblock fields %}
<li>
{% format_permissions permission_bound_field=form.permissions %}
</li>
{% for panel in permission_panels %}
<li>
{{ panel.as_admin_panel }}
</li>
{{ panel.as_admin_panel }}
{% endfor %}
<li><input type="submit" value="{% trans 'Add group' %}" class="button" /></li>
</ul>
</form>
</div>
{% endblock %}
{% endblock %}
{% block extra_js %}

Wyświetl plik

@ -1,40 +1,2 @@
{% extends "wagtailadmin/generic/edit.html" %}
{% load wagtailusers_tags wagtailadmin_tags i18n %}
{% block main_content %}
<form action="{% url 'wagtailusers_groups:edit' group.id %}" method="POST" novalidate>
{% csrf_token %}
<div class="fields">
{% block fields %}
{% panel id="name" heading=form.name.label id_for_label=form.name.id_for_label is_required=True %}
{% formattedfield field=form.name show_label=False %}
{% endpanel %}
{% block extra_fields %}{% endblock extra_fields %}
{% endblock fields %}
<div>
{% format_permissions permission_bound_field=form.permissions %}
</div>
{% for panel in permission_panels %}
<div>
{{ panel.as_admin_panel }}
</div>
{% endfor %}
<div>
<input type="submit" value="{% trans 'Save' %}" class="button" />
{% if perms.auth.delete_group %}
<a href="{% url 'wagtailusers_groups:delete' group.id %}" class="button no">{% trans "Delete group" %}</a>
{% endif %}
</div>
</div>
</form>
{% endblock %}
{% block extra_js %}
{{ block.super }}
{% include "wagtailusers/groups/includes/group_form_js.html" %}
{% endblock %}
{% extends "wagtailusers/groups/create.html" %}
{# The built-in templates are now identical. #}