Fixed comments bug

This commit is contained in:
Fergal Moran
2015-11-13 20:33:47 +00:00
parent 9f03b916d7
commit 2d6acb6281
2 changed files with 8 additions and 2 deletions

View File

@@ -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:

View File

@@ -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