manager: change manager_form_template to only be about the form (#31874)

This commit is contained in:
Frédéric Péters 2019-03-28 17:53:02 +01:00
parent 38d3a42711
commit c9e1f5f688
5 changed files with 35 additions and 25 deletions

View File

@ -1 +0,0 @@
{{form.as_p}}

View File

@ -1,24 +1,3 @@
{% load i18n %}
{% block cell-form %}
<form action="{{ url }}" method="post" data-label-url="{% url 'combo-manager-page-get-additional-label' page_pk=page.id cell_reference=cell.get_reference %}">
{% csrf_token %}
{% if form %}
<div class="cell-form">
{{ form.as_p }}
</div>
{% else %}
<p>{% trans "There are no options for this cell." %}</p>
{% endif %}
{{form.as_p}}
{% endblock %}
<div class="buttons">
{% block cell-buttons %}
<a rel="popup" href="{% url 'combo-manager-page-delete-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Delete' %}</a> |
<a rel="popup" href="{% url 'combo-manager-page-visibility-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Visibility' %}</a> |
<a rel="popup" href="{% url 'combo-manager-page-options-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Options' %}</a> |
<a class="close-button" href="#">{% trans 'Close' %}</a>
{% if form %}
<button class="save submit-button">{% trans 'Save' %}</button>
{% endif %}
{% endblock %}
</div>
</form>

View File

@ -0,0 +1,26 @@
{% load i18n %}
{% block cell-form %}
<form action="{{ url }}" method="post" data-label-url="{% url 'combo-manager-page-get-additional-label' page_pk=page.id cell_reference=cell.get_reference %}">
{% csrf_token %}
{% if form %}
<div class="cell-form">
{% block cell-form-content %}
{% include cell.manager_form_template %}
{% endblock %}
</div>
{% else %}
<p>{% trans "There are no options for this cell." %}</p>
{% endif %}
{% endblock %}
<div class="buttons">
{% block cell-buttons %}
<a rel="popup" href="{% url 'combo-manager-page-delete-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Delete' %}</a> |
<a rel="popup" href="{% url 'combo-manager-page-visibility-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Visibility' %}</a> |
<a rel="popup" href="{% url 'combo-manager-page-options-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Options' %}</a> |
<a class="close-button" href="#">{% trans 'Close' %}</a>
{% if form %}
<button class="save submit-button">{% trans 'Save' %}</button>
{% endif %}
{% endblock %}
</div>
</form>

View File

@ -29,7 +29,7 @@ def cell_form(context, cell):
else:
context['form'] = None
context['cell'] = cell
cell_form_template = template.loader.get_template(cell.manager_form_template)
cell_form_template = template.loader.get_template('combo/manager_edit_cell_block.html')
with context.push():
context = context.flatten()
context.update(cell.get_extra_manager_context())

View File

@ -352,7 +352,13 @@ page_add_cell = PageAddCellView.as_view()
class PageEditCellView(UpdateView):
template_name = 'combo/ajax_cell_form.html'
def get_template_names(self):
return [self.template_name or self.object.manager_form_template]
def get_context_data(self, **kwargs):
context = super(PageEditCellView, self).get_context_data(**kwargs)
context['cell'] = self.get_object()
return context
def get_object(self, queryset=None):
page_pk = self.kwargs.get('page_pk')