Last active
December 10, 2019 21:30
-
-
Save aballah-chamakh/d13bcffc191883506fd4640148d2d415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import generics | |
from .serializers import SentimentAnalysisInferenceSerializer | |
from .models import SentimentAnalysisInference | |
from .permissions import IsAuthenticatedAndOwnerOrDeny | |
class SentimentAnalysisInferenceListApiView(generics.ListAPIView): | |
queryset = SentimentAnalysisInference.objects.all() | |
serializer_class = SentimentAnalysisInferenceSerializer | |
permission_class = IsAuthenticatedAndOwnerOrDeny | |
def get_queryset(self): | |
qs = SentimentAnalysisInference.objects.filter(user=self.request.user) | |
return qs | |
class SentimentAnalysisInferenceCreateApiView(generics.CreateAPIView): | |
queryset = SentimentAnalysisInference.objects.all() | |
serializer_class = SentimentAnalysisInferenceSerializer | |
permission_class = IsAuthenticatedAndOwnerOrDeny | |
def perform_create(self,serializer): | |
return serializer.save(user=self.request.user) | |
class SentimentAnalysisInferenceDetailApiView(generics.RetrieveAPIView): | |
queryset = SentimentAnalysisInference.objects.all() | |
serializer_class = SentimentAnalysisInferenceSerializer | |
permission_class = IsAuthenticatedAndOwnerOrDeny | |
class SentimentAnalysisInferenceUpdateApiView(generics.UpdateAPIView): | |
queryset = SentimentAnalysisInference.objects.all() | |
serializer_class = SentimentAnalysisInferenceSerializer | |
permission_class = IsAuthenticatedAndOwnerOrDeny | |
class SentimentAnalysisInferenceDeleteApiView(generics.DestroyAPIView): | |
queryset = SentimentAnalysisInference.objects.all() | |
serializer_class = SentimentAnalysisInferenceSerializer | |
permission_class = IsAuthenticatedAndOwnerOrDeny |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment