Merge lp:~mhall119/loco-team-portal/geo-grouping into lp:~dholbach/loco-team-portal/geo-grouping

Proposed by Michael Hall
Status: Merged
Merged at revision: 206
Proposed branch: lp:~mhall119/loco-team-portal/geo-grouping
Merge into: lp:~dholbach/loco-team-portal/geo-grouping
Diff against target: 206 lines (+52/-25)
6 files modified
loco_directory/common/utils.py (+28/-0)
loco_directory/teams/models.py (+2/-2)
loco_directory/teams/views.py (+2/-1)
loco_directory/templates/teams/team_list.html (+11/-17)
loco_directory/templates/venues/venue_list.html (+7/-4)
loco_directory/venues/views.py (+2/-1)
To merge this branch: bzr merge lp:~mhall119/loco-team-portal/geo-grouping
Reviewer Review Type Date Requested Status
Daniel Holbach Approve
Review via email: mp+31428@code.launchpad.net

Description of the change

Fixes some problems with the col_left/col_right placement of teams and venues, and lists teams by continent not continent+country

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Good work.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/common/utils.py'
2--- loco_directory/common/utils.py 2010-07-28 13:01:58 +0000
3+++ loco_directory/common/utils.py 2010-07-30 20:58:59 +0000
4@@ -1,5 +1,6 @@
5 import email
6 import os
7+from copy import deepcopy
8
9 def flat_list(some_list):
10 """
11@@ -41,3 +42,30 @@
12 pass
13
14 return "version %s (rev %s)" % (version, bzr_revno)
15+
16+class simple_iterator(object):
17+
18+ def __init__(self, *args):
19+ self.values = []
20+ self.index = -1
21+ if len(args) == 1 and isinstance(args[0], (list, tuple, set)):
22+ self.values.extend(deepcopy(args[0]))
23+ else:
24+ self.values.extend(deepcopy(args))
25+
26+ def get_next_index(self):
27+ if self.index + 1 >= len(self.values):
28+ self.index = 0
29+ else:
30+ self.index = self.index + 1
31+ return self.index
32+ next_index = property(get_next_index)
33+
34+ def get_next(self):
35+ return self.values[self.next_index]
36+ next = property(get_next)
37+
38+ def reset(self):
39+ self.index = -1
40+ return ''
41+
42
43=== modified file 'loco_directory/teams/models.py'
44--- loco_directory/teams/models.py 2010-07-29 13:53:43 +0000
45+++ loco_directory/teams/models.py 2010-07-30 20:58:59 +0000
46@@ -32,11 +32,11 @@
47
48 @property
49 def related_venues(self):
50- return flat_list([a.related_venues for a in self.related_countries])
51+ return flat_list([list(a.related_venues) for a in self.related_countries])
52
53 @property
54 def related_teams(self):
55- return flat_list([a.related_teams for a in self.related_countries])
56+ return flat_list([list(a.related_teams) for a in self.related_countries])
57
58 class Country(models.Model):
59 name = models.TextField(_("Name"), max_length=100)
60
61=== modified file 'loco_directory/teams/views.py'
62--- loco_directory/teams/views.py 2010-07-29 13:53:43 +0000
63+++ loco_directory/teams/views.py 2010-07-30 20:58:59 +0000
64@@ -12,7 +12,7 @@
65
66 from django import http
67
68-from common.utils import redirect
69+from common.utils import redirect, simple_iterator
70 from common import launchpad
71
72 from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country
73@@ -57,6 +57,7 @@
74 'countries_without_continent': countries_without_continent().order_by('name'),
75 'countries_without_continent_have_teams': countries_without_continent_have_teams(),
76 'teams_without_country': teams_without_country().order_by('name'),
77+ 'colcycle' : simple_iterator('col_left', 'col_right'),
78 }
79 return render_to_response('teams/team_list.html', context,
80 RequestContext(request))
81
82=== modified file 'loco_directory/templates/teams/team_list.html'
83--- loco_directory/templates/teams/team_list.html 2010-07-29 13:53:43 +0000
84+++ loco_directory/templates/teams/team_list.html 2010-07-30 20:58:59 +0000
85@@ -20,43 +20,37 @@
86 {% block content %}
87 <article id="main-content" class="main-content">
88 {% if team_list %}
89- {% for continent in continents %}
90- {% if continent.related_teams %}
91+ {% for continent in continents %}{% if continent.related_teams %}
92 <h2>{{continent.name}}</h2>
93- {% for country in continent.related_countries %}
94- {% if country.related_teams %}
95- <h3>{{country.name}}</h3>
96 <ul>
97- {% for team in country.related_teams %}
98- <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>
99+ {{colcycle.reset}}
100+ {% for team in continent.related_teams %}
101+ <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>
102 {% endfor %}
103 </ul>
104 <br class="clear" />
105- {% endif %}
106- {% endfor %}
107- {% endif %}
108- {% endfor %}
109+ {% endif %}{% endfor %}
110
111 {% if countries_without_continent_have_teams %}
112 <h2>{% trans "Countries without continent" %}</h2>
113- {% for country in countries_without_continent %}
114- {% if country.related_teams %}
115+ {% for country in countries_without_continent %}{% if country.related_teams %}
116 <h3>{{country.name}}</h3>
117 <ul>
118+ {{colcycle.reset}}
119 {% for team in country.related_teams %}
120- <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>
121+ <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>
122 {% endfor %}
123 </ul>
124 <br class="clear" />
125- {% endif %}
126- {% endfor %}
127+ {% endif %}{% endfor %}
128 {% endif %}
129
130 {% if teams_without_country %}
131 <h2>{% trans "Teams without country" %}</h2>
132 <ul>
133+ {{colcycle.reset}}
134 {% for team in teams_without_country %}
135- <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>
136+ <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>
137 {% endfor %}
138 </ul>
139 <br class="clear" />
140
141=== modified file 'loco_directory/templates/venues/venue_list.html'
142--- loco_directory/templates/venues/venue_list.html 2010-07-29 13:54:09 +0000
143+++ loco_directory/templates/venues/venue_list.html 2010-07-30 20:58:59 +0000
144@@ -17,7 +17,7 @@
145 {% endblock %}
146
147 {% block content %}
148-<article class="main-content">
149+<article id="main-content" class="main-content">
150
151 <h2>{% trans "Ubuntu LoCo Venues" %}</h2>
152
153@@ -31,8 +31,9 @@
154 {% if country.related_venues %}
155 <h3>{{country.name}}</h3>
156 <ul>
157+ {{colcycle.reset}}
158 {% for venue in country.related_venues %}
159- <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>
160+ <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>
161 {% endfor %}
162 </ul>
163 <br style="clear:left;">
164@@ -47,8 +48,9 @@
165 {% if country.related_venues %}
166 <h3>{{country.name}}</h3>
167 <ul>
168+ {{colcycle.reset}}
169 {% for venue in country.related_venues %}
170- <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>
171+ <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>
172 {% endfor %}
173 </ul>
174 <br style="clear:left;">
175@@ -59,8 +61,9 @@
176 {% if venues_without_country %}
177 <h2>{% trans "Venues without Country" %}</h2>
178 <ul>
179+ {{colcycle.reset}}
180 {% for venue in venues_without_country %}
181- <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>
182+ <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>
183 {% endfor %}
184 </ul>
185 <br style="clear:left;">
186
187=== modified file 'loco_directory/venues/views.py'
188--- loco_directory/venues/views.py 2010-07-29 13:54:09 +0000
189+++ loco_directory/venues/views.py 2010-07-30 20:58:59 +0000
190@@ -11,7 +11,7 @@
191 from models import Venue, venues_without_country
192 from forms import VenueForm, VenueSearchForm
193
194-
195+from common.utils import simple_iterator
196
197 def venue_list(request):
198 """
199@@ -32,6 +32,7 @@
200 'countries_without_continent': countries_without_continent().order_by('name'),
201 'countries_without_continent_have_venues': countries_without_continent_have_venues(),
202 'venues_without_country': venues_without_country().order_by('name'),
203+ 'colcycle' : simple_iterator('col_left', 'col_right'),
204
205 }
206 return render_to_response('venues/venue_list.html', context,

Subscribers

People subscribed via source and target branches

to all changes: