def readability(request, pk): # Support both API key and session authentication if request.method != 'POST': return HttpResponseForbidden() if not request.user.is_authenticated(): auth = ApiKeyAuthentication() auth._unauthorized = lambda: False if not auth.is_authenticated(request): return HttpResponseForbidden() url = request.POST.get('url') if not url: return HttpResponseForbidden() publication = get_object_or_404(Publication, pk=pk) r = Readability.objects.create(url=url, publication=publication) tasks.parse_readability.delay(r) Meter('chrome.submitted').inc() return HttpResponse()
def chrome_extension(request): # Support both API key and session authentication if not request.user.is_authenticated(): auth = ApiKeyAuthentication() auth._unauthorized = lambda: False if not auth.is_authenticated(request): return HttpResponseForbidden() groups = request.user.get_groups() Meter('chrome.clicked').inc() return { 'groups': groups }