Adnane Belmadiaf has proposed merging lp:~daker/loco-directory/fix.814840 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  Bug #814840 in LoCo Team Directory: "A team should only appear once in a 
continent"
  https://bugs.launchpad.net/loco-directory/+bug/814840
  Bug #815439 in LoCo Team Directory: "The teams listing legend has an 
incorrect closing tag"
  https://bugs.launchpad.net/loco-directory/+bug/815439

For more details, see:
https://code.launchpad.net/~daker/loco-directory/fix.814840/+merge/68995
-- 
https://code.launchpad.net/~daker/loco-directory/fix.814840/+merge/68995
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~daker/loco-directory/fix.814840 into lp:loco-directory.
=== modified file 'loco_directory/teams/models.py'
--- loco_directory/teams/models.py	2011-07-04 01:15:21 +0000
+++ loco_directory/teams/models.py	2011-07-24 15:18:33 +0000
@@ -21,10 +21,10 @@
 
 class Continent(models.Model):
     name = models.TextField(_("Name"), max_length=50)
-    
+
     class Meta:
         ordering = ('name',)
-        
+
     def __unicode__(self):
         return u'%s' % (self.name)
 
@@ -35,16 +35,16 @@
     @property
     def related_venues(self):
         from venues.models import Venue
-        return Venue.objects.filter(country__continents=self)
-    
+        return Venue.objects.filter(country__continents=self).distinct()
+
     @property
     def related_teams(self):
-        return Team.objects.filter(countries__continents=self)
+        return Team.objects.filter(countries__continents=self).distinct()
 
 class Country(models.Model):
     name = models.TextField(_("Name"), max_length=100)
     continents = models.ManyToManyField(Continent)
-    
+
     class Meta:
         ordering = ('name',)
     

=== modified file 'loco_directory/teams/views.py'
--- loco_directory/teams/views.py	2011-06-24 15:25:54 +0000
+++ loco_directory/teams/views.py	2011-07-24 15:18:33 +0000
@@ -65,10 +65,17 @@
     return response
 
 def team_list(request):
-    
+    continents = Continent.objects.all().order_by('name')
+    for continent in continents:
+        continent.continent_related_teams = continent.related_teams
+
+    all_countries_without_continent = countries_without_continent().order_by('name')
+    for country in all_countries_without_continent:
+        country.country_without_continent_related_teams = country.related_teams
+
     context = {
-        'continents': Continent.objects.all().order_by('name'),
-        'countries_without_continent': countries_without_continent().order_by('name'),
+        'continents': continents,
+        'countries_without_continent': all_countries_without_continent,
         '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'),

=== modified file 'loco_directory/templates/teams/team_list.html'
--- loco_directory/templates/teams/team_list.html	2011-07-18 01:14:26 +0000
+++ loco_directory/templates/teams/team_list.html	2011-07-24 15:18:33 +0000
@@ -16,7 +16,7 @@
     <ul>
         <li class="approved col_left">{% trans "Approved Teams" %}</li>
         <li class="unapproved col_right">{% trans "Unapproved Teams" %}</li>
-    </li>
+    </ul>
 </article>
 
   {% for continent in continents %}{% if continent.related_teams %}
@@ -24,7 +24,7 @@
       <h2><a name="{{continent.name}}">{{continent.name}}</a></h2>
           <ul>
           {{colcycle.reset}}
-          {% for team in continent.related_teams %}
+          {% for team in continent.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>
@@ -35,11 +35,11 @@
   {% if countries_without_continent_have_teams %}
     <article class="main-content">
     <h2>{% trans "Countries without continent" %}</h2>
-    {% for country in countries_without_continent %}{% if country.related_teams %}
+    {% for country in countries_without_continent %}{% if country.country_without_continent_related_teams %}
         <h3>{{country.name}}</h3>
         <ul>
         {{colcycle.reset}}
-        {% for team in country.related_teams %}
+        {% for team in country.country_without_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>

_______________________________________________
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