0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Ensure that group add/edit forms import form media js/css

This commit is contained in:
Matt Westcott 2018-05-31 18:46:56 +01:00 committed by Matt Westcott
parent 994e793773
commit d14afdc2c3
4 changed files with 26 additions and 0 deletions

View File

@ -7,6 +7,7 @@
{{ block.super }}
<link rel="stylesheet" href="{% static 'wagtailusers/css/groups_edit.css' %}" type="text/css" />
{{ form_media.css }}
{% endblock %}
{% block content %}

View File

@ -7,6 +7,7 @@
{{ block.super }}
<link rel="stylesheet" href="{% static 'wagtailusers/css/groups_edit.css' %}" type="text/css" />
{{ form_media.css }}
{% endblock %}
{% block content %}

View File

@ -9,3 +9,5 @@
<script src="{% static 'wagtailadmin/js/expanding_formset.js' %}"></script>
<script src="{% static 'wagtailadmin/js/modal-workflow.js' %}"></script>
<script src="{% static 'wagtailusers/js/group-form.js' %}"></script>
{{ form_media.js }}

View File

@ -89,6 +89,17 @@ class CreateView(PermissionPanelFormsMixin, generic.CreateView):
else:
return self.form_invalid(form)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# add a 'form_media' variable for the collected js/css media from the form and all formsets
form_media = context['form'].media
for panel in context['permission_panels']:
form_media += panel.media
context['form_media'] = form_media
return context
class EditView(PermissionPanelFormsMixin, generic.EditView):
success_message = _("Group '{0}' updated.")
@ -116,6 +127,17 @@ class EditView(PermissionPanelFormsMixin, generic.EditView):
else:
return self.form_invalid(form)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# add a 'form_media' variable for the collected js/css media from the form and all formsets
form_media = context['form'].media
for panel in context['permission_panels']:
form_media += panel.media
context['form_media'] = form_media
return context
class DeleteView(generic.DeleteView):
success_message = _("Group '{0}' deleted.")