Michael Hall has proposed merging lp:~mhall119/loco-directory/geo-grouping into 
lp:~dholbach/loco-directory/geo-grouping.

Requested reviews:
  loco-directory-dev (loco-directory-dev)


Fixes some problems with the col_left/col_right placement of teams and venues, 
and lists teams by continent not continent+country
-- 
https://code.launchpad.net/~mhall119/loco-directory/geo-grouping/+merge/31428
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/geo-grouping into 
lp:~dholbach/loco-directory/geo-grouping.
=== modified file 'loco_directory/common/utils.py'
--- loco_directory/common/utils.py	2010-07-28 13:01:58 +0000
+++ loco_directory/common/utils.py	2010-07-30 20:58:59 +0000
@@ -1,5 +1,6 @@
 import email
 import os
+from copy import deepcopy
 
 def flat_list(some_list):
     """
@@ -41,3 +42,30 @@
             pass
 
     return "version %s (rev %s)" % (version, bzr_revno)
+
+class simple_iterator(object):
+
+    def __init__(self, *args):
+        self.values = []
+        self.index = -1
+        if len(args) == 1 and isinstance(args[0], (list, tuple, set)):
+            self.values.extend(deepcopy(args[0]))
+        else:
+            self.values.extend(deepcopy(args))
+    
+    def get_next_index(self):
+        if self.index + 1 >= len(self.values):
+            self.index = 0
+        else:
+            self.index = self.index + 1
+        return self.index
+    next_index = property(get_next_index)
+
+    def get_next(self):
+        return self.values[self.next_index]
+    next = property(get_next)
+
+    def reset(self):
+        self.index = -1
+        return ''
+            

=== modified file 'loco_directory/teams/models.py'
--- loco_directory/teams/models.py	2010-07-29 13:53:43 +0000
+++ loco_directory/teams/models.py	2010-07-30 20:58:59 +0000
@@ -32,11 +32,11 @@
 
     @property
     def related_venues(self):
-        return flat_list([a.related_venues for a in self.related_countries])
+        return flat_list([list(a.related_venues) for a in self.related_countries])
     
     @property
     def related_teams(self):
-        return flat_list([a.related_teams for a in self.related_countries])
+        return flat_list([list(a.related_teams) for a in self.related_countries])
 
 class Country(models.Model):
     name = models.TextField(_("Name"), max_length=100)

=== modified file 'loco_directory/teams/views.py'
--- loco_directory/teams/views.py	2010-07-29 13:53:43 +0000
+++ loco_directory/teams/views.py	2010-07-30 20:58:59 +0000
@@ -12,7 +12,7 @@
 
 from django import http
 
-from common.utils import redirect
+from common.utils import redirect, simple_iterator
 from common import launchpad
 
 from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country
@@ -57,6 +57,7 @@
         'countries_without_continent': countries_without_continent().order_by('name'),
         'countries_without_continent_have_teams': countries_without_continent_have_teams(),
         'teams_without_country': teams_without_country().order_by('name'),
+        'colcycle' : simple_iterator('col_left', 'col_right'),
     }
     return render_to_response('teams/team_list.html', context,
                   RequestContext(request))

=== modified file 'loco_directory/templates/teams/team_list.html'
--- loco_directory/templates/teams/team_list.html	2010-07-29 13:53:43 +0000
+++ loco_directory/templates/teams/team_list.html	2010-07-30 20:58:59 +0000
@@ -20,43 +20,37 @@
 {% block content %}
 <article id="main-content" class="main-content">
 {% if team_list %}
-  {% for continent in continents %}
-    {% if continent.related_teams %}
+  {% for continent in continents %}{% if continent.related_teams %}
       <h2>{{continent.name}}</h2>
-      {% for country in continent.related_countries %}
-        {% if country.related_teams %}
-          <h3>{{country.name}}</h3>
           <ul>
-          {% for team in country.related_teams %}
-            <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {% cycle 'col_left' 'col_right' %}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
+          {{colcycle.reset}}
+          {% for team in continent.related_teams %}
+            <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {{colcycle.next}}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
           {% endfor %}
           </ul>
           <br class="clear" />
-        {% endif %}
-      {% endfor %}  
-    {% endif %}
-  {% endfor %}
+  {% endif %}{% endfor %}
 
   {% if countries_without_continent_have_teams %}
     <h2>{% trans "Countries without continent" %}</h2>
-    {% for country in countries_without_continent %}
-      {% if country.related_teams %}
+    {% for country in countries_without_continent %}{% if country.related_teams %}
         <h3>{{country.name}}</h3>
         <ul>
+        {{colcycle.reset}}
         {% for team in country.related_teams %}
-          <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {% cycle 'col_left' 'col_right' %}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
+          <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {{colcycle.next}}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
         {% endfor %}
         </ul>
         <br class="clear" />
-      {% endif %}    
-    {% endfor %}
+      {% endif %}{% endfor %}
   {% endif %}
 
   {% if teams_without_country %}
     <h2>{% trans "Teams without country" %}</h2>
     <ul>
+    {{colcycle.reset}}
     {% for team in teams_without_country %}
-      <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {% cycle 'col_left' 'col_right' %}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
+      <li title="{% if team.approved %}{% blocktrans with team.name as teamname %}{{ teamname }} approved{% endblocktrans %}{% else %}{% blocktrans with team.name as teamname %}{{ teamname }} not approved{% endblocktrans %}{% endif %}" class="{% if team.approved %}approved{% else %}unapproved{% endif %} {{colcycle.next}}"><a href="{{ team.get_absolute_url }}">{{ team.name }}</a></li>
     {% endfor %}
     </ul>
     <br class="clear" />

=== modified file 'loco_directory/templates/venues/venue_list.html'
--- loco_directory/templates/venues/venue_list.html	2010-07-29 13:54:09 +0000
+++ loco_directory/templates/venues/venue_list.html	2010-07-30 20:58:59 +0000
@@ -17,7 +17,7 @@
 {% endblock %}
 
 {% block content %}
-<article class="main-content">
+<article id="main-content" class="main-content">
 
 <h2>{% trans "Ubuntu LoCo Venues" %}</h2>
 
@@ -31,8 +31,9 @@
         {% if country.related_venues %}
           <h3>{{country.name}}</h3>
           <ul>
+          {{colcycle.reset}}
           {% for venue in country.related_venues %}
-            <li class="{% if forloop.counter|divisibleby:2 %}col_right{% else %}col_left{% endif %}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
+            <li class="{{colcycle.next}}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
           {% endfor %}
           </ul>
           <br style="clear:left;">
@@ -47,8 +48,9 @@
       {% if country.related_venues %}
         <h3>{{country.name}}</h3>
         <ul>
+        {{colcycle.reset}}
         {% for venue in country.related_venues %}
-          <li class="{% if forloop.counter|divisibleby:2 %}col_right{% else %}col_left{% endif %}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
+          <li class="{{colcycle.next}}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
         {% endfor %}
         </ul>
         <br style="clear:left;">
@@ -59,8 +61,9 @@
   {% if venues_without_country %}
     <h2>{% trans "Venues without Country" %}</h2>
     <ul>
+    {{colcycle.reset}}
     {% for venue in venues_without_country %}
-      <li class="{% if forloop.counter|divisibleby:2 %}col_right{% else %}col_left{% endif %}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
+      <li class="{{colcycle.next}}"><a title="{% trans "show venue details" %}" href="{{ venue.get_absolute_url }}">{{ venue.name }}{% if venue.city %}, {{ venue.city }}{% endif %}</a></li>
     {% endfor %}
     </ul>
     <br style="clear:left;">

=== modified file 'loco_directory/venues/views.py'
--- loco_directory/venues/views.py	2010-07-29 13:54:09 +0000
+++ loco_directory/venues/views.py	2010-07-30 20:58:59 +0000
@@ -11,7 +11,7 @@
 from models import Venue, venues_without_country
 from forms import VenueForm, VenueSearchForm
 
-
+from common.utils import simple_iterator
 
 def venue_list(request):
     """
@@ -32,6 +32,7 @@
         'countries_without_continent': countries_without_continent().order_by('name'),
         'countries_without_continent_have_venues': countries_without_continent_have_venues(),
         'venues_without_country': venues_without_country().order_by('name'),
+        'colcycle' : simple_iterator('col_left', 'col_right'),
 
     }
     return render_to_response('venues/venue_list.html', context,

_______________________________________________
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