manager: make it possible for cells to override cell_form.html (#7321)
This commit is contained in:
parent
7884ea2aaf
commit
aabe5461ad
|
@ -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)
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue