Projet

Général

Profil

0001-manager-change-manager_form_template-to-only-be-abou.patch

Frédéric Péters, 01 avril 2019 13:56

Télécharger (5,01 ko)

Voir les différences:

Subject: [PATCH] manager: change manager_form_template to only be about the
 form (#31874)

 .../templates/combo/ajax_cell_form.html       |  1 -
 combo/manager/templates/combo/cell_form.html  | 25 +-----------------
 .../combo/manager_edit_cell_block.html        | 26 +++++++++++++++++++
 combo/manager/templatetags/cells.py           |  2 +-
 combo/manager/views.py                        |  8 +++++-
 5 files changed, 35 insertions(+), 27 deletions(-)
 delete mode 100644 combo/manager/templates/combo/ajax_cell_form.html
 create mode 100644 combo/manager/templates/combo/manager_edit_cell_block.html
combo/manager/templates/combo/ajax_cell_form.html
1
{{form.as_p}}
combo/manager/templates/combo/cell_form.html
1
{% load i18n %}
2
{% block cell-form %}
3
<form action="{{ url }}" method="post" data-label-url="{% url 'combo-manager-page-get-additional-label' page_pk=page.id cell_reference=cell.get_reference %}">
4
{% csrf_token %}
5
{% if form %}
6
  <div class="cell-form">
7
  {{ form.as_p }}
8
  </div>
9
{% else %}
10
  <p>{% trans "There are no options for this cell." %}</p>
11
{% endif %}
12
{% endblock %}
13
<div class="buttons">
14
{% block cell-buttons %}
15
<a rel="popup" href="{% url 'combo-manager-page-delete-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Delete' %}</a> |
16
<a rel="popup" href="{% url 'combo-manager-page-visibility-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Visibility' %}</a> |
17
<a rel="popup" href="{% url 'combo-manager-page-options-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Options' %}</a> |
18
<a class="close-button" href="#">{% trans 'Close' %}</a>
19
{% if form %}
20
<button class="save submit-button">{% trans 'Save' %}</button>
21
{% endif %}
22
{% endblock %}
23
</div>
24
</form>
1
{{form.as_p}}
combo/manager/templates/combo/manager_edit_cell_block.html
1
{% load i18n %}
2
{% block cell-form %}
3
<form action="{{ url }}" method="post" data-label-url="{% url 'combo-manager-page-get-additional-label' page_pk=page.id cell_reference=cell.get_reference %}">
4
{% csrf_token %}
5
{% if form %}
6
  <div class="cell-form">
7
    {% block cell-form-content %}
8
      {% include cell.manager_form_template %}
9
    {% endblock %}
10
  </div>
11
{% else %}
12
  <p>{% trans "There are no options for this cell." %}</p>
13
{% endif %}
14
{% endblock %}
15
<div class="buttons">
16
{% block cell-buttons %}
17
<a rel="popup" href="{% url 'combo-manager-page-delete-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Delete' %}</a> |
18
<a rel="popup" href="{% url 'combo-manager-page-visibility-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Visibility' %}</a> |
19
<a rel="popup" href="{% url 'combo-manager-page-options-cell' page_pk=page.id cell_reference=cell.get_reference %}">{% trans 'Options' %}</a> |
20
<a class="close-button" href="#">{% trans 'Close' %}</a>
21
{% if form %}
22
<button class="save submit-button">{% trans 'Save' %}</button>
23
{% endif %}
24
{% endblock %}
25
</div>
26
</form>
combo/manager/templatetags/cells.py
29 29
    else:
30 30
        context['form'] = None
31 31
    context['cell'] = cell
32
    cell_form_template = template.loader.get_template(cell.manager_form_template)
32
    cell_form_template = template.loader.get_template('combo/manager_edit_cell_block.html')
33 33
    with context.push():
34 34
        context = context.flatten()
35 35
        context.update(cell.get_extra_manager_context())
combo/manager/views.py
352 352

  
353 353

  
354 354
class PageEditCellView(UpdateView):
355
    template_name = 'combo/ajax_cell_form.html'
355
    def get_template_names(self):
356
        return [self.template_name or self.object.manager_form_template]
357

  
358
    def get_context_data(self, **kwargs):
359
        context = super(PageEditCellView, self).get_context_data(**kwargs)
360
        context['cell'] = self.get_object()
361
        return context
356 362

  
357 363
    def get_object(self, queryset=None):
358 364
        page_pk = self.kwargs.get('page_pk')
359
-