comparison gpp/gcalendar/admin.py @ 454:5b2114cec3e3

Working on #220. Can't test locally, so committing in increments.
author Brian Neal <bgneal@gmail.com>
date Thu, 30 Jun 2011 02:30:30 +0000
parents 345825e6dcae
children 5be072292e2d
comparison
equal deleted inserted replaced
453:532b9c6f2482 454:5b2114cec3e3
4 """ 4 """
5 from django.conf import settings 5 from django.conf import settings
6 from django.conf.urls.defaults import * 6 from django.conf.urls.defaults import *
7 from django.contrib import admin 7 from django.contrib import admin
8 from django.contrib import messages 8 from django.contrib import messages
9 from django.contrib.sites.models import Site
9 from django.core.urlresolvers import reverse 10 from django.core.urlresolvers import reverse
10 from django.http import HttpResponse 11 from django.http import HttpResponse
11 from django.http import HttpResponseRedirect 12 from django.http import HttpResponseRedirect
12 from django.shortcuts import render_to_response 13 from django.shortcuts import render_to_response
13 from django.template import RequestContext 14 from django.template import RequestContext
117 """ 118 """
118 This view fetches a request token and then redirects the user to 119 This view fetches a request token and then redirects the user to
119 authorize it. 120 authorize it.
120 121
121 """ 122 """
122 callback_url = reverse('admin:gcalendar-get_access_token') 123 site = Site.objects.get_current()
124 callback_url = 'http://%s%s' % (site.domain,
125 reverse('admin:gcalendar-get_access_token'))
123 try: 126 try:
124 auth_url = oauth.fetch_auth(request, SCOPES, callback_url) 127 auth_url = oauth.fetch_auth(request, SCOPES, callback_url)
125 except gdata.client.Error, e: 128 except gdata.client.Error, e:
126 messages.error(request, str(e)) 129 messages.error(request, str(e))
127 return HttpResponseRedirect(reverse('admin:gcalendar-google_sync')) 130 return HttpResponseRedirect(reverse('admin:gcalendar-google_sync'))