Skip to content

Commit

Permalink
Merge pull request #103 from ccnmtl/dont-use-block-template-var
Browse files Browse the repository at this point in the history
Use 'pageblock' instead of 'block' as django template var
  • Loading branch information
thraxil committed Jul 21, 2015
2 parents 1fd247c + 141c42f commit a04f0ea
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 36 deletions.
3 changes: 2 additions & 1 deletion pagetree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ def render(self, **kwargs):
if hasattr(self.content_object, "template_file"):
t = get_template(getattr(self.content_object, "template_file"))
d = kwargs
d['block'] = self.content_object
d['pageblock'] = self.content_object
d['block'] = d['pageblock']
c = Context(d)
return t.render(c)
else:
Expand Down
42 changes: 23 additions & 19 deletions pagetree/templates/pagetree/edit_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,72 +179,75 @@ <h3 style="margin-top: 0;"><a href="{{root.get_edit_url}}">{{section.hierarchy.n

<p>Drag the <span class="glyphicon glyphicon-resize-vertical"></span> arrows to reorder pageblocks:</p>

{% for block in section.pageblock_set.all %}
<div class="row block-dragger" id="pageblock-{{block.id}}">
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
<div class="row block-dragger" id="pageblock-{{pageblock.id}}">

<div class="col-md-1 draghandle">
<span class="glyphicon glyphicon-resize-vertical"></span>
</div>

<div class="col-md-2">
<b><a data-toggle="modal" href="#edit-pageblock-{{block.id}}">{{block.block.display_name}}</a></b>
<b><a data-toggle="modal" href="#edit-pageblock-{{pageblock.id}}">{{pageblock.block.display_name}}</a></b>
</div>

<div class="col-md-6">
<a data-toggle="modal" href="#edit-pageblock-{{block.id}}">{{block.label}}</a>
{% rendersummary block %}
<a data-toggle="modal" href="#edit-pageblock-{{pageblock.id}}">{{pageblock.label}}</a>
{% rendersummary pageblock %}
</div>

<div class="col-md-3">
<div class="btn-group">
<a data-toggle="modal" class="btn btn-default btn-sm"
href="#edit-pageblock-{{block.id}}" title="Edit">
href="#edit-pageblock-{{pageblock.id}}" title="Edit">
<span class="glyphicon glyphicon-edit"></span> edit</a>

<a href="{% url 'delete-pageblock' block.id %}"
<a href="{% url 'delete-pageblock' pageblock.id %}"
class="btn btn-danger btn-sm" title="Delete">
<span class="glyphicon glyphicon-trash"></span></a>
</div>

<div class="btn-group">
{% if block.block.exportable %}
{% if pageblock.block.exportable %}
<a class="btn btn-sm"
rel="tooltip" title="Download JSON dump of this block"
id="export-{{block.id}}"
href="{% url 'export-pageblock-json' block.id %}">
id="export-{{pageblock.id}}"
href="{% url 'export-pageblock-json' pageblock.id %}">
<span class="glyphicon glyphicon-download"></span> export</a>
{% endif %}
</div>
</div>


</div>
{% endwith %}
{% endfor %}


{% for block in section.pageblock_set.all %}
<div class="modal fade block-edit" id="edit-pageblock-{{block.id}}" role="dialog">
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
<div class="modal fade block-edit" id="edit-pageblock-{{pageblock.id}}" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Edit {{block.block.display_name}}</h3>
<h3>Edit {{pageblock.block.display_name}}</h3>
</div>
<div class="modal-body">

{% if block.block.importable %}
<a href="{% url 'import-pageblock-json' block.id %}">import json</a>
{% if pageblock.block.importable %}
<a href="{% url 'import-pageblock-json' pageblock.id %}">import json</a>
{% endif %}

<form action="{% url 'edit-pageblock' block.id %}" method="post"
<form action="{% url 'edit-pageblock' pageblock.id %}" method="post"
class=""
{% if block.edit_form.is_multipart %}
{% if pageblock.edit_form.is_multipart %}
enctype="multipart/form-data"
{% endif %}>
{% csrf_token %}

{{ block.default_edit_form|bootstrap }}
{% with block.edit_form as ef %}
{{ pageblock.default_edit_form|bootstrap }}
{% with pageblock.edit_form as ef %}
{{ ef|bootstrap }}
{% if ef.alt_text %}
<div>{{ ef.alt_text|safe }}</div>
Expand All @@ -261,6 +264,7 @@ <h3>Edit {{block.block.display_name}}</h3>
</form>
</div></div>
</div>
{% endwith %}
{% endfor %}

{% else %}
Expand Down
22 changes: 14 additions & 8 deletions pagetree/templates/pagetree/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
{% load render %}

{% block js %}
{% for block in section.pageblock_set.all %}
{% renderjs block %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
{% renderjs pageblock %}
{% endwith %}
{% endfor %}
{% endblock %}

{% block css %}
{% for block in section.pageblock_set.all %}
{% rendercss block %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
{% rendercss pageblock %}
{% endwith %}
{% endfor %}
{% endblock %}

Expand Down Expand Up @@ -58,11 +62,13 @@ <h3>Sections</h3>
{% endif %}


{% for block in section.pageblock_set.all %}
<div class="pageblock{% if block.css_extra %} {{block.css_extra}}{% endif %}">
{% if block.label %}<h3>{{block.label}}</h3>{% endif %}
{% render block %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
<div class="pageblock{% if pageblock.css_extra %} {{pageblock.css_extra}}{% endif %}">
{% if pageblock.label %}<h3>{{pageblock.label}}</h3>{% endif %}
{% render pageblock %}
</div>
{% endwith %}
{% endfor %}


Expand Down
20 changes: 13 additions & 7 deletions pagetree/templates/pagetree/test_page.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{% load render %}

{% block js %}
{% for block in section.pageblock_set.all %}
{% renderjs block %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
{% renderjs pageblock %}
{% endwith %}
{% endfor %}
{% endblock %}

{% block css %}
{% for block in section.pageblock_set.all %}
{% rendercss block %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
{% rendercss pageblock %}
{% endwith %}
{% endfor %}
{% endblock %}

Expand Down Expand Up @@ -55,11 +59,13 @@ <h3>Sections</h3>
{% endif %}


{% for block in section.pageblock_set.all %}
<div class="pageblock{% if block.css_extra %} {{block.css_extra}}{% endif %}">
{% if block.label %}<h3>{{block.label}}</h3>{% endif %}
{% for pageblock in section.pageblock_set.all %}
{% with block=pageblock %}
<div class="pageblock{% if pageblock.css_extra %} {{pageblock.css_extra}}{% endif %}">
{% if pageblock.label %}<h3>{{pageblock.label}}</h3>{% endif %}
{% render block %}
</div>
{% endwith %}
{% endfor %}


Expand Down
2 changes: 1 addition & 1 deletion pagetree/templates/pagetree/testblock.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% load markup %}
{{block.body|markdown}}
{{pageblock.body|markdown}}

0 comments on commit a04f0ea

Please sign in to comment.