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
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):
return urlencode(token.items())
+# Never Cache
class OAuth1RequestTokenView(View):
def __init__(self):
self.endpoint = OAuth1RequestTokenEndpoint(PistonRequestValidator())
return urlencode(token.items())
+# Never cache
class OAuth1AccessTokenView(View):
def __init__(self):
self.endpoint = OAuth1AccessTokenEndpoint(PistonRequestValidator())
)
+@vary_on_auth
class UserView(RetrieveAPIView):
permission_classes = [IsAuthenticated]
serializer_class = serializers.UserSerializer
return self.request.user
+@vary_on_auth
class BookUserDataView(RetrieveAPIView):
permission_classes = [IsAuthenticated]
serializer_class = serializers.BookUserDataSerializer