New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jkmarx/add primary group api #2820
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2820 +/- ##
===========================================
- Coverage 61.3% 57.33% -3.97%
===========================================
Files 423 420 -3
Lines 30523 26474 -4049
Branches 1300 1258 -42
===========================================
- Hits 18711 15178 -3533
+ Misses 11811 11296 -515
+ Partials 1 0 -1
Continue to review full report at Codecov.
|
@@ -1,19 +1,18 @@ | |||
# -*- coding: utf-8 -*- | |||
from __future__ import unicode_literals | |||
|
|||
from django.db import models, migrations | |||
from django.db import migrations | |||
from django.utils import timezone | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add from guardian.shortcuts import get_groups_with_perms
@@ -22,7 +21,9 @@ def create_initial_site_statistics(apps, schema_editor): | |||
[dataset for dataset in DataSet.objects.all() if dataset.shared] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_groups_with_perms(dataset)
instead of dataset.shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I forgot to push my update.
refinery/core/serializers.py
Outdated
'User is not a member of group, %s', group | ||
) | ||
|
||
if group.name != 'Public': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.REFINERY_PUBLIC_GROUP_NAME
refinery/core/views.py
Outdated
|
||
|
||
class UserProfileViewSet(APIView): | ||
"""API endpoint that allows for UserProfiles to be edits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be edited
refinery/core/views.py
Outdated
http_method_names = ["patch"] | ||
|
||
def patch(self, request, uuid): | ||
if not request.user.is_anonymous(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about flipping the first ifs logic here:
def patch(self, request, uuid):
if request.user.is_anonymous():
return Response(
self.user, status=status.HTTP_401_UNAUTHORIZED
)
serializer = UserProfileSerializer(request.user.profile,
data=request.data,
partial=True,
context={'request': request})
if serializer.is_valid():
serializer.save()
return Response(
serializer.data, status=status.HTTP_202_ACCEPTED
)
return Response(
serializer.errors, status=status.HTTP_400_BAD_REQUEST
)
-API to support user-profile updates, specifically the primary-group
Ref #2781