Fix UserWarning in SocialAccountListView and SocialAccountDisconnectView

Django was raising "is not compatible with schema generation" user warning at startup
This commit is contained in:
François Rossigneux 2018-03-31 00:20:58 +02:00
parent a3057b7aa1
commit 47b43a5235

View File

@ -154,7 +154,10 @@ class SocialAccountListView(ListAPIView):
permission_classes = (IsAuthenticated,) permission_classes = (IsAuthenticated,)
def get_queryset(self): def get_queryset(self):
return SocialAccount.objects.filter(user=self.request.user) if self.request:
return SocialAccount.objects.filter(user=self.request.user)
else:
return SocialAccount.objects.none()
class SocialAccountDisconnectView(GenericAPIView): class SocialAccountDisconnectView(GenericAPIView):
@ -166,7 +169,10 @@ class SocialAccountDisconnectView(GenericAPIView):
permission_classes = (IsAuthenticated,) permission_classes = (IsAuthenticated,)
def get_queryset(self): def get_queryset(self):
return SocialAccount.objects.filter(user=self.request.user) if self.request:
return SocialAccount.objects.filter(user=self.request.user)
else:
return SocialAccount.objects.none()
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
accounts = self.get_queryset() accounts = self.get_queryset()