from django.shortcuts import redirect from eventplanner_gcal.google_sync import syncFromGoogleToLocal, syncFromLocalToGoogle from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt from pprint import pformat from eventplanner_gcal.google_sync import checkIfGoogleCallbackIsValid import logging logger = logging.getLogger( __name__ ) def runSync( request ): syncFromLocalToGoogle() return redirect("/") @csrf_exempt def gcalApiCallback( request ): # TODO check channel info here token = "" if 'HTTP_X_GOOG_CHANNEL_TOKEN' in request.META: token = request.META['HTTP_X_GOOG_CHANNEL_TOKEN'] channelID = "" if 'HTTP_X_GOOG_CHANNEL_ID' in request.META: channelID = request.META['HTTP_X_GOOG_CHANNEL_ID'] resourceID = "" if 'HTTP_X_GOOG_RESOURCE_ID' in request.META: resourceID = request.META['HTTP_X_GOOG_RESOURCE_ID'] valid = checkIfGoogleCallbackIsValid( token, channelID, resourceID) if not valid: return HttpResponse('