Mercurial > public > sg101
annotate gpp/gcalendar/admin_views.py @ 340:2541d27ca056
Fix #153. Update verbiage on the donations thanks template to meet Paypal guidelines for making it a auto-return page.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 27 Feb 2011 00:28:20 +0000 |
parents | 9fb8e804652b |
children |
rev | line source |
---|---|
gremmie@1 | 1 """ |
gremmie@1 | 2 Admin views for the gcalendar application. |
gremmie@1 | 3 """ |
gremmie@1 | 4 from django.shortcuts import render_to_response |
gremmie@1 | 5 from django.template import RequestContext |
gremmie@1 | 6 |
gremmie@1 | 7 from gcalendar.models import Event |
gremmie@1 | 8 from gcalendar.forms import PasswordForm |
gremmie@1 | 9 from gcalendar.calendar import Calendar |
gremmie@1 | 10 from gcalendar.calendar import CalendarError |
gremmie@1 | 11 import gcalendar.settings |
gremmie@1 | 12 |
gremmie@1 | 13 |
gremmie@1 | 14 def google_sync(request): |
gremmie@1 | 15 """View to synchronize approved event changes with Google calendar.""" |
gremmie@1 | 16 events = Event.pending_events.all() |
gremmie@1 | 17 messages = [] |
bgneal@69 | 18 err_msg = '' |
gremmie@1 | 19 if request.method == 'POST': |
gremmie@1 | 20 form = PasswordForm(request.POST) |
gremmie@1 | 21 if form.is_valid(): |
gremmie@1 | 22 try: |
gremmie@1 | 23 cal = Calendar(gcalendar.settings.EMAIL, |
gremmie@1 | 24 form.cleaned_data['password'], |
gremmie@1 | 25 gcalendar.settings.CALENDAR_ID) |
gremmie@1 | 26 cal.sync_events(events) |
gremmie@1 | 27 except CalendarError, e: |
bgneal@69 | 28 err_msg = e.msg |
gremmie@1 | 29 events = Event.pending_events.all() |
gremmie@1 | 30 form = PasswordForm() |
gremmie@1 | 31 else: |
gremmie@1 | 32 messages.append('All events processed successfully.') |
gremmie@1 | 33 events = Event.objects.none() |
gremmie@1 | 34 form = PasswordForm() |
gremmie@1 | 35 |
gremmie@1 | 36 else: |
gremmie@1 | 37 form = PasswordForm() |
gremmie@1 | 38 |
gremmie@1 | 39 return render_to_response('gcalendar/google_sync.html', { |
gremmie@1 | 40 'messages': messages, |
bgneal@69 | 41 'err_msg': err_msg, |
gremmie@1 | 42 'events': events, |
gremmie@1 | 43 'form': form, |
gremmie@1 | 44 }, |
gremmie@1 | 45 context_instance=RequestContext(request)) |
gremmie@1 | 46 |