comparison gpp/gcalendar/admin_views.py @ 69:9fb8e804652b

GCalendar: should have committed this with the previous change. A single error message is produced instead of a list now.
author Brian Neal <bgneal@gmail.com>
date Sun, 28 Jun 2009 18:54:29 +0000
parents dbd703f7d63a
children
comparison
equal deleted inserted replaced
68:cce1fc3f8752 69:9fb8e804652b
13 13
14 def google_sync(request): 14 def google_sync(request):
15 """View to synchronize approved event changes with Google calendar.""" 15 """View to synchronize approved event changes with Google calendar."""
16 events = Event.pending_events.all() 16 events = Event.pending_events.all()
17 messages = [] 17 messages = []
18 errors = [] 18 err_msg = ''
19 if request.method == 'POST': 19 if request.method == 'POST':
20 form = PasswordForm(request.POST) 20 form = PasswordForm(request.POST)
21 if form.is_valid(): 21 if form.is_valid():
22 try: 22 try:
23 cal = Calendar(gcalendar.settings.EMAIL, 23 cal = Calendar(gcalendar.settings.EMAIL,
24 form.cleaned_data['password'], 24 form.cleaned_data['password'],
25 gcalendar.settings.CALENDAR_ID) 25 gcalendar.settings.CALENDAR_ID)
26 cal.sync_events(events) 26 cal.sync_events(events)
27 except CalendarError, e: 27 except CalendarError, e:
28 errors = e.errs 28 err_msg = e.msg
29 events = Event.pending_events.all() 29 events = Event.pending_events.all()
30 form = PasswordForm() 30 form = PasswordForm()
31 else: 31 else:
32 messages.append('All events processed successfully.') 32 messages.append('All events processed successfully.')
33 events = Event.objects.none() 33 events = Event.objects.none()
36 else: 36 else:
37 form = PasswordForm() 37 form = PasswordForm()
38 38
39 return render_to_response('gcalendar/google_sync.html', { 39 return render_to_response('gcalendar/google_sync.html', {
40 'messages': messages, 40 'messages': messages,
41 'errors': errors, 41 'err_msg': err_msg,
42 'events': events, 42 'events': events,
43 'form': form, 43 'form': form,
44 }, 44 },
45 context_instance=RequestContext(request)) 45 context_instance=RequestContext(request))
46 46
47 # vim: ts=4 sw=4