annotate gpp/gcalendar/admin_views.py @ 7:ca66189c7c44

Added tiny_mce to the GPP_THIRD_PARTY_JS setting. Updated code to use it.
author Brian Neal <bgneal@gmail.com>
date Sun, 12 Apr 2009 00:31:36 +0000
parents dbd703f7d63a
children 9fb8e804652b
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 = []
gremmie@1 18 errors = []
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:
gremmie@1 28 errors = e.errs
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,
gremmie@1 41 'errors': errors,
gremmie@1 42 'events': events,
gremmie@1 43 'form': form,
gremmie@1 44 },
gremmie@1 45 context_instance=RequestContext(request))
gremmie@1 46
gremmie@1 47 # vim: ts=4 sw=4