def install(request): template_data = {} logger.debug("Installing for user id: {0}".format(request.user.id)) mirror = _get_mirror(request.user.id) _register_glass_app(mirror, request.user.id) # return HttpResponseRedirect('https://google.com/myglass') return HttpResponseRedirect('/add_wordpress/')
def subscription_reply(request): # Load the payload from Google try: post = json.loads(request.body) except Exception: logger.exception("Couldn't load request.body") post = dict(request.POST) # We only care if something was shared to us. If they deleted something, we don't care for now. if 'userActions' not in post or post['userActions'][0]['type'] not in ["SHARE", "DELETE"]: return HttpResponse("Non share ignored.") # Find the user that shared it to us. user_id = post['userToken'] user = User.objects.get(id=user_id) try: mirror = _get_mirror(user_id) except ValueError: return HttpResponseBadRequest("Need valid userToken") if post['userActions'][0]['type'] == "SHARE": return subscription_share(request, post, mirror) elif post['userActions'][0]['type'] == "DELETE": return subscription_delete(request, post, mirror)