summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-05-21 06:49:39 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-05-22 11:38:01 (GMT)
commitaabe5461ad3569d020a55f0df960297c44169582 (patch)
treee4920398653d0a24248e3cf4fd44b7d1d94c1dda
parent7884ea2aafed85ad36b41c9014b26e485089e53a (diff)
downloadcombo-aabe5461ad3569d020a55f0df960297c44169582.zip
combo-aabe5461ad3569d020a55f0df960297c44169582.tar.gz
combo-aabe5461ad3569d020a55f0df960297c44169582.tar.bz2
manager: make it possible for cells to override cell_form.html (#7321)
-rw-r--r--combo/data/models.py4
-rw-r--r--combo/manager/templates/combo/cell_form.html4
-rw-r--r--combo/manager/templatetags/cells.py6
3 files changed, 12 insertions, 2 deletions
diff --git a/combo/data/models.py b/combo/data/models.py
index 6cd4608..b1bfc40 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -217,6 +217,7 @@ class CellBase(models.Model):
default_form_class = None
visible = True
user_dependant = False
+ manager_form_template = 'combo/cell_form.html'
class Meta:
abstract = True
@@ -316,6 +317,9 @@ class CellBase(models.Model):
return model_forms.modelform_factory(self.__class__,
fields=['public', 'groups'])
+ def get_extra_manager_context(self):
+ return {}
+
def is_visible(self, user=None):
return element_is_visible(self, user=user)
diff --git a/combo/manager/templates/combo/cell_form.html b/combo/manager/templates/combo/cell_form.html
index 3152d3e..fcc115e 100644
--- a/combo/manager/templates/combo/cell_form.html
+++ b/combo/manager/templates/combo/cell_form.html
@@ -1,4 +1,5 @@
{% 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 %}
@@ -6,7 +7,9 @@
{% 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> |
@@ -14,5 +17,6 @@
{% if form %}
<button class="save">{% trans 'Save' %}</button>
{% endif %}
+{% endblock %}
</div>
</form>
diff --git a/combo/manager/templatetags/cells.py b/combo/manager/templatetags/cells.py
index e2ded65..390706d 100644
--- a/combo/manager/templatetags/cells.py
+++ b/combo/manager/templatetags/cells.py
@@ -28,5 +28,7 @@ def cell_form(context, cell):
context['form'] = form_class(instance=cell, prefix='c%s' % cell.get_reference())
else:
context['form'] = None
- cell_form_template = template.loader.get_template('combo/cell_form.html')
- return cell_form_template.render(context)
+ cell_form_template = template.loader.get_template(cell.manager_form_template)
+ with context.push():
+ context.update(cell.get_extra_manager_context())
+ return cell_form_template.render(context)