Merge lp:~mhall119/loco-team-portal/fixes-599640 into lp:loco-team-portal

Proposed by Michael Hall on 2010-07-29
Status: Merged
Merged at revision: 203
Proposed branch: lp:~mhall119/loco-team-portal/fixes-599640
Merge into: lp:loco-team-portal
Diff against target: 84 lines (+39/-2)
3 files modified
loco_directory/events/urls.py (+1/-0)
loco_directory/events/views.py (+37/-2)
loco_directory/templates/events/team_event_detail.html (+1/-0)
To merge this branch: bzr merge lp:~mhall119/loco-team-portal/fixes-599640
Reviewer Review Type Date Requested Status
Daniel Holbach (community) 2010-07-29 Approve on 2010-07-29
Review via email: mp+31225@code.launchpad.net

Description of the change

Adds a "Copy Event" link to event details page, which is like the add event page, only the fields are pre-populated with the values from the copied event

To post a comment you must log in.
Daniel Holbach (dholbach) wrote :

Nice 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/events/urls.py'
2--- loco_directory/events/urls.py 2010-01-20 16:47:30 +0000
3+++ loco_directory/events/urls.py 2010-07-29 01:09:49 +0000
4@@ -11,6 +11,7 @@
5 url(r'^team/(?P<team_event_id>\d+)/delete/$', 'events.views.team_event_delete', name='team-event-delete'),
6 url(r'^team/(?P<team_event_id>\d+)/update/$', 'events.views.team_event_update', name='team-event-update'),
7 url(r'^team/(?P<team_event_id>\d+)/comment/$', 'events.views.team_event_comment_new', name='team-event-comment-new'),
8+ url(r'^team/(?P<team_event_id>\d+)/copy/$', 'events.views.team_event_copy', name='team-event-copy'),
9 url(r'^team/(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/add/$', 'events.views.team_event_new', name='team-event-new'),
10 url(r'^team/add/$', 'events.views.team_event_select', name='team-event-select'),
11 url(r'^team/(?P<team_slug>[a-zA-Z0-9\-\.\+?]+)/rss/$', 'events.views.team_events_rss', name='team-events-rss'),
12
13=== modified file 'loco_directory/events/views.py'
14--- loco_directory/events/views.py 2010-06-19 21:35:39 +0000
15+++ loco_directory/events/views.py 2010-07-29 01:09:49 +0000
16@@ -106,12 +106,12 @@
17 team_event_object = get_object_or_404(TeamEvent, pk=team_event_id)
18 is_member = False
19 for team_object in team_event_object.teams.all():
20- is_member = is_member or launchpad.is_team_member(request.user, team_object)
21+ is_member = is_member or launchpad.is_team_member(request.user, team_object)
22
23 context = {
24 'team_event_object': team_event_object,
25 'user_is_attending': team_event_object.is_attending(request.user),
26- 'user_is_team_member': is_member,
27+ 'user_is_team_member': is_member,
28 }
29 return render_to_response('events/team_event_detail.html',
30 context, RequestContext(request))
31@@ -216,6 +216,41 @@
32 return redirect( team_object )
33
34 @login_required
35+def team_event_copy(request, team_event_id):
36+ """
37+ new team event
38+ """
39+
40+ team_event = get_object_or_404(TeamEvent, pk=team_event_id)
41+ team_object = team_event.teams.all()[0]
42+ team_event.id = team_event.pk = None
43+
44+ is_on_lc = launchpad.is_user_on_loco_council(request.user)
45+ is_member = launchpad.is_team_member(request.user, team_object)
46+
47+ if is_on_lc or is_member:
48+ if request.method == 'POST':
49+ form = TeamEventForm(instance=team_event, data=request.POST)
50+ if form.is_valid():
51+ team_event = form.save()
52+ team_event.teams.add(team_object)
53+ request.user.message_set.create(message=_('New event created.'))
54+ return redirect( team_object )
55+ else:
56+ form = TeamEventForm(instance=team_event)
57+
58+ context = {
59+ 'team_object': team_object,
60+ 'form': form,
61+ }
62+ return render_to_response('events/team_event_new.html',
63+ context, RequestContext(request))
64+ else:
65+ # XXX: Once we move to a new ACL system, this needs fixing.
66+ request.user.message_set.create(message=_('You can not add a new event for this team. You are not member of the team or on the LoCo Council.'))
67+ return redirect( team_object )
68+
69+@login_required
70 def team_event_update(request, team_event_id):
71 """
72 update team event
73
74=== modified file 'loco_directory/templates/events/team_event_detail.html'
75--- loco_directory/templates/events/team_event_detail.html 2010-06-24 19:18:57 +0000
76+++ loco_directory/templates/events/team_event_detail.html 2010-07-29 01:09:49 +0000
77@@ -17,6 +17,7 @@
78 {% if user_is_team_member %}
79 <a class="sub-nav-item" href="{% url team-event-update team_event_object.id %}">{% trans "Edit details" %}</a>
80 <a class="sub-nav-item" href="{% url team-event-delete team_event_object.id %}">{% trans "Delete team event" %}</a>
81+<a class="sub-nav-item" href="{% url team-event-copy team_event_object.id %}">{% trans "Copy event" %}</a>
82 {% endif %}
83
84 {% endif %}

Subscribers

People subscribed via source and target branches