Merge lp:~mhall119/loco-team-portal/geo-grouping into lp:~dholbach/loco-team-portal/geo-grouping
- geo-grouping
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach | Approve | ||
Review via email: mp+31428@code.launchpad.net |
Commit message
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.
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 | 1 | import email | 1 | import email |
6 | 2 | import os | 2 | import os |
7 | 3 | from copy import deepcopy | ||
8 | 3 | 4 | ||
9 | 4 | def flat_list(some_list): | 5 | def flat_list(some_list): |
10 | 5 | """ | 6 | """ |
11 | @@ -41,3 +42,30 @@ | |||
12 | 41 | pass | 42 | pass |
13 | 42 | 43 | ||
14 | 43 | return "version %s (rev %s)" % (version, bzr_revno) | 44 | return "version %s (rev %s)" % (version, bzr_revno) |
15 | 45 | |||
16 | 46 | class simple_iterator(object): | ||
17 | 47 | |||
18 | 48 | def __init__(self, *args): | ||
19 | 49 | self.values = [] | ||
20 | 50 | self.index = -1 | ||
21 | 51 | if len(args) == 1 and isinstance(args[0], (list, tuple, set)): | ||
22 | 52 | self.values.extend(deepcopy(args[0])) | ||
23 | 53 | else: | ||
24 | 54 | self.values.extend(deepcopy(args)) | ||
25 | 55 | |||
26 | 56 | def get_next_index(self): | ||
27 | 57 | if self.index + 1 >= len(self.values): | ||
28 | 58 | self.index = 0 | ||
29 | 59 | else: | ||
30 | 60 | self.index = self.index + 1 | ||
31 | 61 | return self.index | ||
32 | 62 | next_index = property(get_next_index) | ||
33 | 63 | |||
34 | 64 | def get_next(self): | ||
35 | 65 | return self.values[self.next_index] | ||
36 | 66 | next = property(get_next) | ||
37 | 67 | |||
38 | 68 | def reset(self): | ||
39 | 69 | self.index = -1 | ||
40 | 70 | return '' | ||
41 | 71 | |||
42 | 44 | 72 | ||
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 | 32 | 32 | ||
48 | 33 | @property | 33 | @property |
49 | 34 | def related_venues(self): | 34 | def related_venues(self): |
51 | 35 | return flat_list([a.related_venues for a in self.related_countries]) | 35 | return flat_list([list(a.related_venues) for a in self.related_countries]) |
52 | 36 | 36 | ||
53 | 37 | @property | 37 | @property |
54 | 38 | def related_teams(self): | 38 | def related_teams(self): |
56 | 39 | return flat_list([a.related_teams for a in self.related_countries]) | 39 | return flat_list([list(a.related_teams) for a in self.related_countries]) |
57 | 40 | 40 | ||
58 | 41 | class Country(models.Model): | 41 | class Country(models.Model): |
59 | 42 | name = models.TextField(_("Name"), max_length=100) | 42 | name = models.TextField(_("Name"), max_length=100) |
60 | 43 | 43 | ||
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 | 12 | 12 | ||
66 | 13 | from django import http | 13 | from django import http |
67 | 14 | 14 | ||
69 | 15 | from common.utils import redirect | 15 | from common.utils import redirect, simple_iterator |
70 | 16 | from common import launchpad | 16 | from common import launchpad |
71 | 17 | 17 | ||
72 | 18 | from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country | 18 | from teams.models import Continent, Team, countries_without_continent, countries_without_continent_have_teams, teams_without_country |
73 | @@ -57,6 +57,7 @@ | |||
74 | 57 | 'countries_without_continent': countries_without_continent().order_by('name'), | 57 | 'countries_without_continent': countries_without_continent().order_by('name'), |
75 | 58 | 'countries_without_continent_have_teams': countries_without_continent_have_teams(), | 58 | 'countries_without_continent_have_teams': countries_without_continent_have_teams(), |
76 | 59 | 'teams_without_country': teams_without_country().order_by('name'), | 59 | 'teams_without_country': teams_without_country().order_by('name'), |
77 | 60 | 'colcycle' : simple_iterator('col_left', 'col_right'), | ||
78 | 60 | } | 61 | } |
79 | 61 | return render_to_response('teams/team_list.html', context, | 62 | return render_to_response('teams/team_list.html', context, |
80 | 62 | RequestContext(request)) | 63 | RequestContext(request)) |
81 | 63 | 64 | ||
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 | 20 | {% block content %} | 20 | {% block content %} |
87 | 21 | <article id="main-content" class="main-content"> | 21 | <article id="main-content" class="main-content"> |
88 | 22 | {% if team_list %} | 22 | {% if team_list %} |
91 | 23 | {% for continent in continents %} | 23 | {% for continent in continents %}{% if continent.related_teams %} |
90 | 24 | {% if continent.related_teams %} | ||
92 | 25 | <h2>{{continent.name}}</h2> | 24 | <h2>{{continent.name}}</h2> |
93 | 26 | {% for country in continent.related_countries %} | ||
94 | 27 | {% if country.related_teams %} | ||
95 | 28 | <h3>{{country.name}}</h3> | ||
96 | 29 | <ul> | 25 | <ul> |
99 | 30 | {% for team in country.related_teams %} | 26 | {{colcycle.reset}} |
100 | 31 | <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> | 27 | {% for team in continent.related_teams %} |
101 | 28 | <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 | 32 | {% endfor %} | 29 | {% endfor %} |
103 | 33 | </ul> | 30 | </ul> |
104 | 34 | <br class="clear" /> | 31 | <br class="clear" /> |
109 | 35 | {% endif %} | 32 | {% endif %}{% endfor %} |
106 | 36 | {% endfor %} | ||
107 | 37 | {% endif %} | ||
108 | 38 | {% endfor %} | ||
110 | 39 | 33 | ||
111 | 40 | {% if countries_without_continent_have_teams %} | 34 | {% if countries_without_continent_have_teams %} |
112 | 41 | <h2>{% trans "Countries without continent" %}</h2> | 35 | <h2>{% trans "Countries without continent" %}</h2> |
115 | 42 | {% for country in countries_without_continent %} | 36 | {% for country in countries_without_continent %}{% if country.related_teams %} |
114 | 43 | {% if country.related_teams %} | ||
116 | 44 | <h3>{{country.name}}</h3> | 37 | <h3>{{country.name}}</h3> |
117 | 45 | <ul> | 38 | <ul> |
118 | 39 | {{colcycle.reset}} | ||
119 | 46 | {% for team in country.related_teams %} | 40 | {% for team in country.related_teams %} |
121 | 47 | <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> | 41 | <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 | 48 | {% endfor %} | 42 | {% endfor %} |
123 | 49 | </ul> | 43 | </ul> |
124 | 50 | <br class="clear" /> | 44 | <br class="clear" /> |
127 | 51 | {% endif %} | 45 | {% endif %}{% endfor %} |
126 | 52 | {% endfor %} | ||
128 | 53 | {% endif %} | 46 | {% endif %} |
129 | 54 | 47 | ||
130 | 55 | {% if teams_without_country %} | 48 | {% if teams_without_country %} |
131 | 56 | <h2>{% trans "Teams without country" %}</h2> | 49 | <h2>{% trans "Teams without country" %}</h2> |
132 | 57 | <ul> | 50 | <ul> |
133 | 51 | {{colcycle.reset}} | ||
134 | 58 | {% for team in teams_without_country %} | 52 | {% for team in teams_without_country %} |
136 | 59 | <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> | 53 | <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 | 60 | {% endfor %} | 54 | {% endfor %} |
138 | 61 | </ul> | 55 | </ul> |
139 | 62 | <br class="clear" /> | 56 | <br class="clear" /> |
140 | 63 | 57 | ||
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 | 17 | {% endblock %} | 17 | {% endblock %} |
146 | 18 | 18 | ||
147 | 19 | {% block content %} | 19 | {% block content %} |
149 | 20 | <article class="main-content"> | 20 | <article id="main-content" class="main-content"> |
150 | 21 | 21 | ||
151 | 22 | <h2>{% trans "Ubuntu LoCo Venues" %}</h2> | 22 | <h2>{% trans "Ubuntu LoCo Venues" %}</h2> |
152 | 23 | 23 | ||
153 | @@ -31,8 +31,9 @@ | |||
154 | 31 | {% if country.related_venues %} | 31 | {% if country.related_venues %} |
155 | 32 | <h3>{{country.name}}</h3> | 32 | <h3>{{country.name}}</h3> |
156 | 33 | <ul> | 33 | <ul> |
157 | 34 | {{colcycle.reset}} | ||
158 | 34 | {% for venue in country.related_venues %} | 35 | {% for venue in country.related_venues %} |
160 | 35 | <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> | 36 | <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 | 36 | {% endfor %} | 37 | {% endfor %} |
162 | 37 | </ul> | 38 | </ul> |
163 | 38 | <br style="clear:left;"> | 39 | <br style="clear:left;"> |
164 | @@ -47,8 +48,9 @@ | |||
165 | 47 | {% if country.related_venues %} | 48 | {% if country.related_venues %} |
166 | 48 | <h3>{{country.name}}</h3> | 49 | <h3>{{country.name}}</h3> |
167 | 49 | <ul> | 50 | <ul> |
168 | 51 | {{colcycle.reset}} | ||
169 | 50 | {% for venue in country.related_venues %} | 52 | {% for venue in country.related_venues %} |
171 | 51 | <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> | 53 | <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 | 52 | {% endfor %} | 54 | {% endfor %} |
173 | 53 | </ul> | 55 | </ul> |
174 | 54 | <br style="clear:left;"> | 56 | <br style="clear:left;"> |
175 | @@ -59,8 +61,9 @@ | |||
176 | 59 | {% if venues_without_country %} | 61 | {% if venues_without_country %} |
177 | 60 | <h2>{% trans "Venues without Country" %}</h2> | 62 | <h2>{% trans "Venues without Country" %}</h2> |
178 | 61 | <ul> | 63 | <ul> |
179 | 64 | {{colcycle.reset}} | ||
180 | 62 | {% for venue in venues_without_country %} | 65 | {% for venue in venues_without_country %} |
182 | 63 | <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> | 66 | <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 | 64 | {% endfor %} | 67 | {% endfor %} |
184 | 65 | </ul> | 68 | </ul> |
185 | 66 | <br style="clear:left;"> | 69 | <br style="clear:left;"> |
186 | 67 | 70 | ||
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 | 11 | from models import Venue, venues_without_country | 11 | from models import Venue, venues_without_country |
192 | 12 | from forms import VenueForm, VenueSearchForm | 12 | from forms import VenueForm, VenueSearchForm |
193 | 13 | 13 | ||
195 | 14 | 14 | from common.utils import simple_iterator | |
196 | 15 | 15 | ||
197 | 16 | def venue_list(request): | 16 | def venue_list(request): |
198 | 17 | """ | 17 | """ |
199 | @@ -32,6 +32,7 @@ | |||
200 | 32 | 'countries_without_continent': countries_without_continent().order_by('name'), | 32 | 'countries_without_continent': countries_without_continent().order_by('name'), |
201 | 33 | 'countries_without_continent_have_venues': countries_without_continent_have_venues(), | 33 | 'countries_without_continent_have_venues': countries_without_continent_have_venues(), |
202 | 34 | 'venues_without_country': venues_without_country().order_by('name'), | 34 | 'venues_without_country': venues_without_country().order_by('name'), |
203 | 35 | 'colcycle' : simple_iterator('col_left', 'col_right'), | ||
204 | 35 | 36 | ||
205 | 36 | } | 37 | } |
206 | 37 | return render_to_response('venues/venue_list.html', context, | 38 | return render_to_response('venues/venue_list.html', context, |
Good work.