X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/29f694eea94d09bd66976321ddfd80ac30b73d38..7cb7624d4864f0cb7ddce5b14879971ff97eb80e:/src/api/views.py diff --git a/src/api/views.py b/src/api/views.py index 518445dd0..f28a4e4e1 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -6,7 +6,7 @@ from django.http import Http404 from django.views.generic.base import View from oauthlib.common import urlencode from oauthlib.oauth1 import RequestTokenEndpoint, AccessTokenEndpoint -from piston.models import KEY_SIZE, SECRET_SIZE +from api.piston.models import KEY_SIZE, SECRET_SIZE from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView @@ -16,7 +16,7 @@ from catalogue.models import Book from .models import BookUserData from . import serializers from .request_validator import PistonRequestValidator -from .utils import oauthlib_request, oauthlib_response +from .utils import oauthlib_request, oauthlib_response, vary_on_auth class OAuth1RequestTokenEndpoint(RequestTokenEndpoint): @@ -35,6 +35,7 @@ class OAuth1RequestTokenEndpoint(RequestTokenEndpoint): return urlencode(token.items()) +# Never Cache class OAuth1RequestTokenView(View): def __init__(self): self.endpoint = OAuth1RequestTokenEndpoint(PistonRequestValidator()) @@ -66,6 +67,7 @@ class OAuth1AccessTokenEndpoint(AccessTokenEndpoint): return urlencode(token.items()) +# Never cache class OAuth1AccessTokenView(View): def __init__(self): self.endpoint = OAuth1AccessTokenEndpoint(PistonRequestValidator()) @@ -78,6 +80,7 @@ class OAuth1AccessTokenView(View): ) +@vary_on_auth class UserView(RetrieveAPIView): permission_classes = [IsAuthenticated] serializer_class = serializers.UserSerializer @@ -86,6 +89,7 @@ class UserView(RetrieveAPIView): return self.request.user +@vary_on_auth class BookUserDataView(RetrieveAPIView): permission_classes = [IsAuthenticated] serializer_class = serializers.BookUserDataSerializer