Skip to content
Browse files

Prefer website:mobile and website over url when rendering website in …

…an OSM tag. Also, keys with : are normalised to - when adding to dictionary, to allow access in templates
  • Loading branch information...
1 parent 8df097b commit 05d31273752c204edd5c3aba4fe27c3dfcc9271e @cnorthwood cnorthwood committed May 27, 2011
Showing with 26 additions and 10 deletions.
  1. +3 −3 molly/apps/places/providers/osm.py
  2. +23 −7 molly/apps/places/templates/places/metadata/osm.html
View
6 molly/apps/places/providers/osm.py
@@ -137,7 +137,7 @@ def endElement(self, name):
entity.title = name
entity.metadata['osm'] = {
'attrs': dict(self.attrs),
- 'tags': self.tags
+ 'tags': dict(zip((k.replace(':', '-') for k in self.tags.keys()), self.tags.values()))
}
entity.primary_type = self.entity_types[types[0]]
@@ -399,8 +399,8 @@ def disambiguate_titles(self, source):
for inferred_name, entities in inferred_names.items():
if len(entities) > 1:
for entity in entities:
- if entity.metadata['osm']['tags'].get('addr:street'):
- entity.title = u"%s, %s" % (inferred_name, entity.metadata['osm']['tags'].get('addr:street'))
+ if entity.metadata['osm']['tags'].get('addr-street'):
+ entity.title = u"%s, %s" % (inferred_name, entity.metadata['osm']['tags'].get('addr-street'))
continue
try:
View
30 molly/apps/places/templates/places/metadata/osm.html
@@ -1,6 +1,6 @@
{% load molly_osm %}{% load molly_utils %}
-{% if entity|osm_tags or entity.metadata.osm.tags.phone or entity.metadata.osm.tags.wikipedia or entity.metadata.osm.tags.url %}
+{% if entity|osm_tags or entity.metadata.osm.tags.phone or entity.metadata.osm.tags.wikipedia or entity.metadata.osm.tags.website-mobile or entity.metadata.osm.tags.website or entity.metadata.osm.tags.url %}
<div class="section">
<div class="header">
@@ -35,12 +35,28 @@
</a>
</li>
{% endif %}
- {% if entity.metadata.osm.tags.url %}
- <li>
- <a class="external" href="{{ entity.metadata.osm.tags.url|escape }}">
- Website
- </a>
- </li>
+ {% if entity.metadata.osm.tags.website-mobile %}
+ <li>
+ <a class="external" href="{{ entity.metadata.osm.tags.website-mobile|escape }}">
+ Website
+ </a>
+ </li>
+ {% else %}
+ {% if entity.metadata.osm.tags.website %}
+ <li>
+ <a class="external" href="{{ entity.metadata.osm.tags.website|escape }}">
+ Website
+ </a>
+ </li>
+ {% else %}
+ {% if entity.metadata.osm.tags.url %}
+ <li>
+ <a class="external" href="{{ entity.metadata.osm.tags.url|escape }}">
+ Website
+ </a>
+ </li>
+ {% endif %}
+ {% endif %}
{% endif %}
<li>
<a href="{% url places:entity-update entity.identifier_scheme entity.identifier_value %}">

0 comments on commit 05d3127

Please sign in to comment.
Something went wrong with that request. Please try again.