Skip to content

Commit

Permalink
Block for extra content in area/postcode info
Browse files Browse the repository at this point in the history
Useful for cobrands that want to display a small amount of custom
data, or a message to users, without overriding the whole template.
  • Loading branch information
zarino committed Feb 15, 2017
1 parent d48351e commit 3d26447
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 5 additions & 3 deletions mapit/templates/mapit/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ <h2>{{ area.name }} <em class="area_id">ID {{ area.id }}</em></h2>
{% if area.children.count %}
<li><a href="{% url "mapit_index" %}area/{{ area.id }}/children.html">{% trans "Children" %}</a></li>
{% endif %}
{% with area.id|slugify as area_id %}
<li>{% blocktrans with json_url=index_url|add:"area/"|add:area_id %}Get <a href="{{ json_url }}">this data as JSON</a>{% endblocktrans %}</li>
{% endwith %}
</ul>
{% with area.id|slugify as area_id %}
<p>{% blocktrans with json_url=index_url|add:"area/"|add:area_id %}Get <a href="{{ json_url }}">this data as JSON</a>{% endblocktrans %}</p>
{% endwith %}

{% block area_info_extra %}{% endblock %}
</header>

{% if area.polygons.count %}
Expand Down
27 changes: 14 additions & 13 deletions mapit/templates/mapit/postcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
<header class="area_info">
<h2>{{ postcode.postcode }}</h2>
<ul>
{% if postcode.coordsyst %}
<li>{% ifequal postcode.coordsyst "G" %}OSGB{% else %}IRE65{% endifequal %}
E/N: {{ postcode.easting }}, {{ postcode.northing }}
{% endif %}
{% if postcode.wgs84_lat or postcode.wgs84_lon %}
<li>{% trans "WGS84 lat/lon" %}: <a href="https://tools.wmflabs.org/geohack/geohack.php?params={{ postcode.wgs84_lat|floatformat }};{{ postcode.wgs84_lon }}">{{ postcode.wgs84_lat }}, {{ postcode.wgs84_lon }}</a>
{% else %}
<li>{% blocktrans trimmed %}
{% if postcode.coordsyst %}
<li>{% ifequal postcode.coordsyst "G" %}OSGB{% else %}IRE65{% endifequal %}
E/N: {{ postcode.easting }}, {{ postcode.northing }}
{% endif %}
{% if postcode.wgs84_lat or postcode.wgs84_lon %}
<li>{% trans "WGS84 lat/lon" %}: <a href="https://tools.wmflabs.org/geohack/geohack.php?params={{ postcode.wgs84_lat|floatformat }};{{ postcode.wgs84_lon }}">{{ postcode.wgs84_lat }}, {{ postcode.wgs84_lon }}</a>
{% else %}
<li>{% blocktrans trimmed %}
No location information. Note this <em>is</em> a valid postcode (otherwise you would have got a 404), just one for which we don&rsquo;t know the location.
{% endblocktrans %}</li>

{% endif %}
{% endblocktrans %}</li>
{% endif %}
{% url json_view postcode=postcode.postcode as json_url %}
<li>{% blocktrans %}Get <a href="{{ json_url }}">this data as JSON</a>{% endblocktrans %}</li>
</ul>
{% url json_view postcode=postcode.postcode as json_url %}
<p>{% blocktrans %}Get <a href="{{ json_url }}">this data as JSON</a>{% endblocktrans %}</p>

{% block area_info_extra %}{% endblock %}
</header>

{% if postcode.wgs84_lat or postcode.wgs84_lon %}
Expand Down

0 comments on commit 3d26447

Please sign in to comment.