Michael Hall has proposed merging lp:~mhall119/loco-directory/fixes-805280 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  Bug #805280 in LoCo Team Directory: "Venue template error"
  https://bugs.launchpad.net/loco-directory/+bug/805280

For more details, see:
https://code.launchpad.net/~mhall119/loco-directory/fixes-805280/+merge/66736

Overview
========
Reverse lookup was failing on a Korean venue

Details
=======
Reverse lookups were failing because the Country object of Korea has the name 
"Korea, Republic of" and the comma was causing the error.  I introduce a "slug" 
property to the Country model that will give a safer version of the country 
name, stripping commas and replacing spaces with underscores.
-- 
https://code.launchpad.net/~mhall119/loco-directory/fixes-805280/+merge/66736
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/fixes-805280 into lp:loco-directory.
=== modified file 'loco_directory/teams/models.py'
--- loco_directory/teams/models.py	2011-06-17 17:10:41 +0000
+++ loco_directory/teams/models.py	2011-07-04 01:13:25 +0000
@@ -58,6 +58,13 @@
     def related_venues(self):
         return self.venue_set.all()
 
+    @property
+    def slug(self):
+        if self.name is not None:
+            return self.name.replace(',', '').replace(' ', '_')
+        else:
+            return 'no-country'
+    
 def countries_without_continent():
     return Country.objects.filter(continents__isnull=True)
 

=== modified file 'loco_directory/templates/venues/venue_detail.html'
--- loco_directory/templates/venues/venue_detail.html	2011-03-16 18:35:53 +0000
+++ loco_directory/templates/venues/venue_detail.html	2011-07-04 01:13:25 +0000
@@ -11,7 +11,11 @@
 
 {% block sub_nav_links %}
 <a class="sub-nav-item" href="{% url venue-list %}" >{% trans "Back to Venues List" %}</a>
-<a class="sub-nav-item" href="{% url venue-update venue_object.country venue_object.id %}">{% trans "Edit Venue Details" %}</a>
+{% if venue_object.country %}
+<a class="sub-nav-item" href="{% url venue-update venue_object.country.slug venue_object.id %}">{% trans "Edit Venue Details" %}</a>
+{% else %}
+<a class="sub-nav-item" href="{% url venue-update 'no_country' venue_object.id %}">{% trans "Edit Venue Details" %}</a>
+{% endif %}
 {% endblock %}
 
 {% block content %}

=== modified file 'loco_directory/templates/venues/venue_list.html'
--- loco_directory/templates/venues/venue_list.html	2010-11-27 00:54:13 +0000
+++ loco_directory/templates/venues/venue_list.html	2011-07-04 01:13:25 +0000
@@ -57,7 +57,7 @@
                 <ul>
                     {% for venue in venues_without_country %}
                         <li>
-                            <p><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}{% if venue.spr %}, {{ venue.spr }}{% endif %}</a></p>
+                            <p><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{% if venue %}{{ venue.name }}{% else %}{% trans 'No Name' %}{% endif %}{% if venue.city %}, {{ venue.city }}{% endif %}{% if venue.spr %}, {{ venue.spr }}{% endif %}</a></p>
                         </li>
                     {% endfor %}
                 </ul>

=== modified file 'loco_directory/venues/models.py'
--- loco_directory/venues/models.py	2011-06-17 17:10:41 +0000
+++ loco_directory/venues/models.py	2011-07-04 01:13:25 +0000
@@ -45,7 +45,11 @@
     @models.permalink
     def get_absolute_url(self):
         """ get the absolute url for the venue """
-        return ('venue-detail', [self.country or 'no-country', self.id])
+        if self.country:
+            country = self.country.slug
+        else:
+            country = 'no_country'
+        return ('venue-detail', [country, self.id])
 
     def save(self, *args, **kargs):
         if self.id:

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to