Merge lp:~daker/loco-team-portal/fix.gj into lp:loco-team-portal

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: Adnane Belmadiaf
Approved revision: 611
Merged at revision: 610
Proposed branch: lp:~daker/loco-team-portal/fix.gj
Merge into: lp:loco-team-portal
Diff against target: 146 lines (+34/-84)
2 files modified
loco_directory/events/views.py (+11/-22)
loco_directory/templates/events/global_event_detail_attending_teamevents.inc.html (+23/-62)
To merge this branch: bzr merge lp:~daker/loco-team-portal/fix.gj
Reviewer Review Type Date Requested Status
LoCo Team Portal Developers Pending
Review via email: mp+148352@code.launchpad.net

Commit message

Optimized the global event page

Description of the change

A gloval event with 225 events now generate 731 queries rather than 1379 queries

http://i.imgur.com/fkyMFat.jpg

To post a comment you must log in.
lp:~daker/loco-team-portal/fix.gj updated
611. By Adnane Belmadiaf

Remove print statement

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/events/views.py'
2--- loco_directory/events/views.py 2012-12-22 23:22:32 +0000
3+++ loco_directory/events/views.py 2013-02-14 00:27:22 +0000
4@@ -385,37 +385,26 @@
5 detailed view for a global event
6 """
7 global_event = get_object_or_404(GlobalEvent, pk=global_event_id)
8- team_events = global_event.teamevent_set.all()
9-
10+ team_events = global_event.teamevent_set.all().order_by('venue__continent__name')
11+ for event in team_events:
12+ event.v = "z-v"
13+ event.ctr = "z-ctr"
14+ event.ctn = "z-ctn"
15+ if event.venue and event.venue is not None:
16+ event.v = event.venue
17+ if event.v.country:
18+ event.ctr = str(event.v.country)
19+ if event.v.continent:
20+ event.ctn = str(event.v.continent)
21 add_team_event = (request.user and request.user.is_authenticated() and \
22 request.user.groups.exclude(name__exact='ubuntu-lococouncil'))
23 is_on_lc = launchpad.is_user_on_loco_council(request.user)
24
25- events_without_venue = team_events.filter(venue__isnull=True)
26- country_ids = [a.venue.country.id for a in team_events.filter(venue__isnull=False,
27- venue__country__continents__isnull=False)]
28- country_without_continents_ids = [a.venue.country.id \
29- for a in team_events.filter(venue__isnull=False,
30- venue__country__isnull=False,
31- venue__country__continents__isnull=True)]
32-
33- countries = Country.objects.filter(id__in=country_ids).order_by('name')
34- countries_without_continents = Country.objects.filter(id__in=country_without_continents_ids).order_by('name')
35- continent_ids = []
36- for continent_list in map(lambda a: a.continents.all(), countries):
37- continent_ids += [continent.id for continent in continent_list]
38- continents = Continent.objects.filter(id__in=continent_ids).order_by('name')
39-
40 context = {
41 'global_event': global_event,
42 'team_events': team_events,
43 'add_team_event': add_team_event,
44- 'events_without_venue': events_without_venue,
45 'user_is_on_lc': is_on_lc,
46- 'continents': continents,
47- 'countries': countries,
48- 'countries_without_continents': countries_without_continents,
49- 'colcycle': simple_iterator('col_left', 'col_right'),
50 }
51 return render_to_response('events/global_event_detail.html',
52 context, RequestContext(request))
53
54=== modified file 'loco_directory/templates/events/global_event_detail_attending_teamevents.inc.html'
55--- loco_directory/templates/events/global_event_detail_attending_teamevents.inc.html 2012-12-22 23:22:32 +0000
56+++ loco_directory/templates/events/global_event_detail_attending_teamevents.inc.html 2013-02-14 00:27:22 +0000
57@@ -1,65 +1,26 @@
58 {% load i18n %}
59 {% if team_events %}
60- <table class="basic wide">
61- {% for continent in continents %}
62- <thead><tr><th colspan="3">{{ continent.name }}</th></tr></thead>
63- {% for country in countries %}{% for cont in country.continents.all %}{% ifequal cont continent %}
64- {% for team_event in team_events %}{% ifequal country team_event.venue.country %}
65- <tr>
66- <td>
67- <a title="{% trans 'More Information about Team Event' %}" href="{{ team_event.get_absolute_url }}">{{ team_event.name }}</a>
68- </td>
69- <td>
70- {{ country.name }}
71- {% for team in team_event.teams.all %}
72- {% if team_event.venue.city %}, {{ team_event.venue.city }}{% endif %}
73- {% endfor %}
74- </td>
75- <td>
76- {{ team_event.local_date_begin|date:"D, d N" }}
77- </td>
78- </tr>
79- {% endifequal %}{% endfor %}
80- {% endifequal %}{% endfor %}{% endfor %}
81+
82+<div class="events-meetings-wrapper">
83+ {% regroup team_events|dictsort:"ctn" by ctn as events_list_by_continent %}
84+ {% for continent in events_list_by_continent %}
85+ <div style="overflow: auto; margin-bottom: 10px;border-bottom: 1px solid #E6E6E6;">
86+ <h1 style="padding-left: 15px;">{% if continent.grouper == 'z-ctn'%}{% trans "Events in countries without continents" %}{% else %}{{ continent.grouper }}{% endif %}</h2>
87+ {% regroup continent.list|dictsort:"ctr" by ctr as events_list_by_countries %}
88+ {% for events in events_list_by_countries %}
89+ <h3 style="border-top: 1px solid #E6E6E6;padding-top: 10px;padding-left: 15px;">{% if events.grouper == 'z-ctr'%}{% trans "Events without countries" %}{% else %}{{ events.grouper }} ({{ events.list|length }}){% endif %}</h3>
90+ {% for team_event in events.list %}
91+ <a href="{{ team_event.get_absolute_url }}" title="{{ team_event.name }}" class="event-meetings">
92+ <span class="title">{{ team_event.name }}</span>
93+ <small>{{ team_event.local_date_begin|date:"D, d N" }}</small>
94+ {% if team_event.v != 'z-v' %}
95+ <p>{% if team_event.v.city %}{{ team_event.v.city }}{% endif %}</p>
96+ {% endif %}
97+ </a>
98+ {% endfor %}
99+ {% endfor %}
100+ </div>
101 {% endfor %}
102-
103- {% if countries_without_continents %}
104- <thead><tr><th colspan="3">{% trans "Events in countries without continents" %}</th></tr></thead>
105- {% for country in countries_without_continents %}
106- <tr>
107- <td>
108- <a title="{{ team_event.name }}" href="{{ team_event.get_absolute_url }}">{{ team_event.name }}</a>
109- </td>
110- <td>
111- {{ country.name }}
112- {% for team in team_event.teams.all %}
113- {% if team_event.venue.city %}, {{ team_event.venue.city }}{% endif %}
114- {% endfor %}
115- </td>
116- <td>
117- {{ team_event.local_date_begin|date:"D, d N" }}
118- </td>
119- </tr>
120- {% endfor %}
121- {% endif %}
122-
123- {% if events_without_venue %}
124- <thead><tr><th colspan="3">{% trans "Events without venue" %}</th></tr></thead>
125- {% for team_event in events_without_venue %}
126- <tr>
127- <td>
128- <a title="{% trans 'More Information about Team Event' %}" href="{{ team_event.get_absolute_url }}">{{ team_event.name }}</a>
129- </td>
130- <td>
131- {% for team in team_event.teams.all %}
132- {{team.country}}
133- {% endfor %}
134- </td>
135- <td>
136- {{ team_event.local_date_begin|date:"D, d N" }}
137- </td>
138- </tr>
139- {% endfor %}
140- {% endif %}
141- </table>
142-{% endif %}
143+</div>
144+
145+{% endif %}
146\ No newline at end of file

Subscribers

People subscribed via source and target branches