Merge lp:~doctormo/loco-team-portal/previous-used-venues into lp:loco-team-portal

Proposed by Martin Owens
Status: Merged
Approved by: Chris Johnston
Approved revision: 438
Merged at revision: 435
Proposed branch: lp:~doctormo/loco-team-portal/previous-used-venues
Merge into: lp:loco-team-portal
Diff against target: 87 lines (+25/-2)
3 files modified
loco_directory/events/forms.py (+18/-1)
loco_directory/teams/views.py (+4/-0)
loco_directory/templates/teams/team_event_list.html (+3/-1)
To merge this branch: bzr merge lp:~doctormo/loco-team-portal/previous-used-venues
Reviewer Review Type Date Requested Status
Chris Johnston Approve
Martin Owens (community) Approve
Michael Hall (community) Needs Fixing
Review via email: mp+65071@code.launchpad.net

Commit message

Add in a previously-used venue section into the create-new event screen. Also added a create-event link to the event-list screen to help UI.

Description of the change

Add in a previously-used venue section into the create-new event screen.

Also added a create-event link to the event-list screen to help UI.

To post a comment you must log in.
Revision history for this message
Michael Hall (mhall119) wrote :

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/events/ubuntu-us-florida/add/
Django Version: 1.1.2
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'common',
 'teams',
 'venues',
 'events',
 'meetings',
 'userprofiles',
 'django_openid_auth',
 'south',
 'bzr_apps']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback:
File "/home/mhall/projects/Ubuntu/locodir/work/.env/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  99. response = callback(request, *callback_args, **callback_kwargs)
File "/home/mhall/projects/Ubuntu/locodir/work/.env/lib/python2.6/site-packages/django/contrib/auth/decorators.py" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/home/mhall/projects/Ubuntu/locodir/work/loco_directory/events/views.py" in team_event_new
  209. form = TeamEventForm(initial={'global_event':request.GET.get('global_event_id', None)}, teams=[team_object])
File "/home/mhall/projects/Ubuntu/locodir/work/loco_directory/events/forms.py" in __init__
  69. self.fields['venue'].choices = self.grouped_venue_list()
File "/home/mhall/projects/Ubuntu/locodir/work/loco_directory/events/forms.py" in grouped_venue_list
  103. previous_choice.append((event.venue.id, str(event.venue)))

Exception Type: AttributeError at /events/ubuntu-us-florida/add/
Exception Value: 'NoneType' object has no attribute 'id'

review: Needs Fixing
437. By Martin Owens

Allow events with no venue.

Revision history for this message
Chris Johnston (cjohnston) wrote :

<h2>{% blocktrans with team_object.lp_name as teamname %}There are currently no events for this team.{% endblocktrans %}

There is no reason to have the with if you are taking out the specification of a team in the text.

review: Needs Fixing
Revision history for this message
Martin Owens (doctormo) wrote :

Both issues have been fixed and commits pushed.

review: Needs Resubmitting
438. By Martin Owens

Removed 'with' statement which is now useless.

Revision history for this message
Martin Owens (doctormo) :
review: Approve
Revision history for this message
Chris Johnston (cjohnston) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/events/forms.py'
2--- loco_directory/events/forms.py 2011-02-17 21:24:49 +0000
3+++ loco_directory/events/forms.py 2011-06-17 23:12:35 +0000
4@@ -90,9 +90,22 @@
5 in a way that Django will convert to OptGroups
6 """
7 venue_choices = [('', '---------')]
8+ previous_venues = []
9+ previous_choice = []
10 country_choices = []
11 current_country = ''
12-
13+
14+ # Have a look for previously used event venues
15+ team_events = TeamEvent.objects.filter(teams__lp_name__in=self.teams)
16+ for event in team_events:
17+ if event.venue and event.venue not in previous_venues:
18+ previous_venues.append(event.venue)
19+ previous_choice.append((event.venue.id, str(event.venue)))
20+
21+ # Add a previously used menu list if required.
22+ if previous_venues:
23+ venue_choices.insert(1, (_("Previously Used"), previous_choice))
24+
25 # Show the venues which belong the the 'current team' first. then show the other countries
26 venues_team = Venue.objects.filter(country__team__in=self.teams).order_by('country', 'spr', 'city')
27 venues_other = Venue.objects.all().exclude(country__team__in=self.teams).order_by('country', 'spr', 'city')
28@@ -101,6 +114,9 @@
29 # Ordered by country so we can tell when we're done with one
30 # and starting another
31 for venue in venues:
32+ # Ignore the venue if we've added it before.
33+ if venue in previous_venues:
34+ continue
35 # If this venue has a different country, start a new group
36 if venue.country != current_country:
37 # Add the old group to the list if it's non-empty
38@@ -110,6 +126,7 @@
39 current_country = venue.country
40 # Add venue to the current country group
41 country_choices.append((venue.id, str(venue)))
42+
43
44 # Add the last country group to the list if it's non-empty
45 if len(country_choices) > 0:
46
47=== modified file 'loco_directory/teams/views.py'
48--- loco_directory/teams/views.py 2011-02-26 02:09:43 +0000
49+++ loco_directory/teams/views.py 2011-06-17 23:12:35 +0000
50@@ -104,9 +104,13 @@
51 """
52 team_object = get_object_or_404(Team, lp_name=team_slug)
53 team_event_list = team_object.teamevent_set.next_events()
54+ is_member = False
55+ if request.user.is_authenticated():
56+ is_member = launchpad.is_team_member(request.user, team_object)
57 context = {
58 'team_object': team_object,
59 'team_event_list': team_event_list,
60+ 'is_member' : is_member,
61 }
62 return render_to_response('teams/team_event_list.html', context,
63 RequestContext(request))
64
65=== modified file 'loco_directory/templates/teams/team_event_list.html'
66--- loco_directory/templates/teams/team_event_list.html 2010-11-20 17:25:50 +0000
67+++ loco_directory/templates/teams/team_event_list.html 2011-06-17 23:12:35 +0000
68@@ -7,6 +7,7 @@
69 <a class="sub-nav-item" href="{% url team-detail team_object.lp_name %}">{% trans "Back to Team Details" %}</a>
70 <a class="sub-nav-item" href="{% url team-event-history team_object.lp_name %}">{% trans "Past Events" %}</a>
71 <a class="sub-nav-item" href="{% url team-events-rss team_object.lp_name %}" title="{% trans "Team Events (RSS)" %}"">{% trans "Team Events (RSS)" %}</a>
72+{% if is_member %}<a class="sub-nav-item" href="{% url team-event-new team_object.lp_name %}" title="{% trans "Add New Event" %}">{% trans "Add New Event" %}</a>{% endif %}
73 {% endblock %}
74
75
76@@ -26,9 +27,10 @@
77 {% include "events/team_event_list.inc.html" %}
78
79 {% else %}
80-<p>{% blocktrans with team_object.lp_name as teamname %}There are currently no Events for LoCo Team {{teamname}} :({% endblocktrans %}</p>
81+<h2>{% blocktrans %}There are currently no events for this team.{% endblocktrans %}</h2>
82 {% endif %}
83
84
85+
86 </article>
87 {% endblock %}

Subscribers

People subscribed via source and target branches