From 2d6acb628142a91aabe7a3d83be84020bb1d72a2 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Fri, 13 Nov 2015 20:33:47 +0000 Subject: [PATCH] Fixed comments bug --- api/auth.py | 8 +++++++- api/serializers.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/auth.py b/api/auth.py index 47772fb..0bf5ec4 100644 --- a/api/auth.py +++ b/api/auth.py @@ -16,6 +16,12 @@ from social.apps.django_app.utils import psa logger = logging.getLogger('dss') +BACKENDS = { + 'google': 'google-oauth2', + 'facebook': 'facebook', + 'twitter': 'twitter' +} + @psa() def auth_by_token(request, backend): @@ -31,7 +37,7 @@ class SocialLoginHandler(APIView): def post(self, request, format=None): auth_token = request.data.get('access_token', None) - backend = request.data.get('backend', None) + backend = BACKENDS.get(request.data.get('backend', None), 'facebook') if auth_token and backend: try: diff --git a/api/serializers.py b/api/serializers.py index 57ce2bc..1477bb2 100755 --- a/api/serializers.py +++ b/api/serializers.py @@ -402,7 +402,7 @@ class CommentSerializer(serializers.HyperlinkedModelSerializer): def get_can_edit(self, obj): user = self.context['request'].user - if user is not None and user.is_authenticated(): + if user is not None and obj.user is not None and user.is_authenticated(): return user.is_staff or obj.user.id == user.userprofile.id return False