-# -*- coding: utf-8 -*-
-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
from django.contrib.auth.decorators import login_required
from django import forms
from oauthlib.common import urlencode
from oauthlib.oauth1 import RequestTokenEndpoint, AccessTokenEndpoint
from oauthlib.oauth1 import AuthorizationEndpoint, OAuth1Error
-from api.models import KEY_SIZE, SECRET_SIZE
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
-from rest_framework.generics import ListAPIView, RetrieveAPIView, get_object_or_404
-from migdal.models import Entry
+from rest_framework.generics import RetrieveAPIView, get_object_or_404
from catalogue.models import Book
-from .models import BookUserData
+from .models import BookUserData, KEY_SIZE, SECRET_SIZE
from . import serializers
from .request_validator import PistonRequestValidator
from .utils import oauthlib_request, oauthlib_response, vary_on_auth
realms, credentials = endpoint.get_realms_and_credentials(
**oauthlib_request(request))
except OAuth1Error as e:
- return HttpResponse(e.message, status=400)
+ return HttpResponse(str(e), status=400)
callback = request.GET.get('oauth_callback')
form = OAuthAuthenticationForm(initial={
return render(request, 'oauth/authorize_token.html', {'form': form})
- elif request.method == "POST":
+ if request.method == "POST":
try:
response = oauthlib_response(
endpoint.create_authorization_response(
return Response(serializer.data)
-class BlogView(ListAPIView):
- serializer_class = serializers.BlogSerializer
-
- def get_queryset(self):
- after = self.request.query_params.get('after')
- count = int(self.request.query_params.get('count', 20))
- entries = Entry.published_objects.filter(in_stream=True).order_by('-first_published_at')
- if after:
- entries = entries.filter(first_published_at__lt=after)
- if count:
- entries = entries[:count]
- return entries
+class BlogView(APIView):
+ def get(self, request):
+ return Response([])