kopia lustrzana https://github.com/wagtail/wagtail
Make redirects add view and searchpromotions add/edit view templates extend the generic ones
Some hacks required until we properly refactor the views to be subclasses of the generic viewspull/12425/head
rodzic
e231a13dbc
commit
eecc4ff895
|
@ -1,4 +1,4 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% extends "wagtailadmin/generic/form.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% trans "Add redirect" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
@ -14,22 +14,11 @@
|
|||
{% for field in form.visible_fields %}
|
||||
<li>{% formattedfield field %}</li>
|
||||
{% endfor %}
|
||||
|
||||
<li>
|
||||
<input type="submit" value="{% trans 'Save' %}" class="button" />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% block footer %}
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||
{{ form.media.js }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{{ block.super }}
|
||||
{{ form.media.css }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -236,6 +236,11 @@ def add(request):
|
|||
"wagtailredirects/add.html",
|
||||
{
|
||||
"form": form,
|
||||
# Remove these when this view is refactored to a generic.CreateView subclass.
|
||||
# Avoid defining new translatable strings.
|
||||
"submit_button_label": generic.CreateView.submit_button_label,
|
||||
"submit_button_active_label": generic.CreateView.submit_button_active_label,
|
||||
"media": form.media,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% extends "wagtailadmin/generic/form.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% trans "Add search promotion" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
@ -26,21 +26,18 @@
|
|||
<li>
|
||||
{% include "wagtailsearchpromotions/includes/searchpromotions_formset.html" with formset=searchpicks_formset only %}
|
||||
</li>
|
||||
<li><input type="submit" value="{% trans 'Save' %}" class="button" /></li>
|
||||
</ul>
|
||||
|
||||
{% block footer %}
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{{ block.super }}
|
||||
{{ form_media.css }}
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||
<script src="{% versioned_static 'wagtailsearchpromotions/js/query-chooser-modal.js' %}"></script>
|
||||
{{ form_media.js }}
|
||||
|
||||
<script type="text/javascript">
|
||||
{% include "wagtailsearchpromotions/includes/searchpromotions_formset.js" with formset=searchpicks_formset only %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% extends "wagtailadmin/generic/form.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% blocktrans trimmed with query=query.query_string %}Editing {{ query }}{% endblocktrans %}{% endblock %}
|
||||
{% block content %}
|
||||
|
@ -15,23 +15,28 @@
|
|||
<li>
|
||||
{% include "wagtailsearchpromotions/includes/searchpromotions_formset.html" with formset=searchpicks_formset only %}
|
||||
</li>
|
||||
<li>
|
||||
<input type="submit" value="{% trans 'Save' %}" class="button" />
|
||||
<a href="{% url 'wagtailsearchpromotions:delete' query.id %}" class="button no">{% trans "Delete" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% block footer %}
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{{ block.super }}
|
||||
{{ form_media.css }}
|
||||
{% block extra_actions %}
|
||||
{% comment %}
|
||||
The view hasn't extended from generic EditView, so we cannot use the new
|
||||
header buttons in the breadcrumbs for the Delete button. Instead, we'll
|
||||
add a Delete button to the footer actions.
|
||||
{% endcomment %}
|
||||
{% if can_delete %}
|
||||
<a href="{{ delete_url }}" class="button">{{ delete_item_label }}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||
<script src="{% versioned_static 'wagtailsearchpromotions/js/query-chooser-modal.js' %}"></script>
|
||||
{{ form_media.js }}
|
||||
|
||||
<script type="text/javascript">
|
||||
{% include "wagtailsearchpromotions/includes/searchpromotions_formset.js" with formset=searchpicks_formset only %}
|
||||
|
|
|
@ -177,7 +177,11 @@ def add(request):
|
|||
{
|
||||
"query_form": query_form,
|
||||
"searchpicks_formset": searchpicks_formset,
|
||||
"form_media": query_form.media + searchpicks_formset.media,
|
||||
"media": query_form.media + searchpicks_formset.media,
|
||||
# Remove these when this view is refactored to a generic.CreateView subclass.
|
||||
# Avoid defining new translatable strings.
|
||||
"submit_button_label": generic.CreateView.submit_button_label,
|
||||
"submit_button_active_label": generic.CreateView.submit_button_active_label,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -236,7 +240,16 @@ def edit(request, query_id):
|
|||
"query_form": query_form,
|
||||
"searchpicks_formset": searchpicks_formset,
|
||||
"query": query,
|
||||
"form_media": query_form.media + searchpicks_formset.media,
|
||||
"media": query_form.media + searchpicks_formset.media,
|
||||
# Remove these when this view is refactored to a generic.CreateView subclass.
|
||||
# Avoid defining new translatable strings.
|
||||
"submit_button_label": generic.EditView.submit_button_label,
|
||||
"submit_button_active_label": generic.EditView.submit_button_active_label,
|
||||
"can_delete": request.user.has_perm(
|
||||
"wagtailsearchpromotions.delete_searchpromotion"
|
||||
),
|
||||
"delete_url": reverse("wagtailsearchpromotions:delete", args=(query.id,)),
|
||||
"delete_item_label": generic.EditView.delete_item_label,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue