Skip to content
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

Merged
merged 7 commits into from Jun 18, 2018
Merged

Jkmarx/add primary group api #2820

merged 7 commits into from Jun 18, 2018

Conversation

jkmarx
Copy link
Member

@jkmarx jkmarx commented Jun 15, 2018

-API to support user-profile updates, specifically the primary-group
Ref #2781

@jkmarx jkmarx requested a review from scottx611x June 15, 2018 15:32
@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #2820 into develop will decrease coverage by 3.96%.
The diff coverage is 43.33%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
refinery/core/urls.py 100% <ø> (ø) ⬆️
refinery/core/models.py 74.55% <100%> (-7.45%) ⬇️
refinery/core/views.py 40.18% <36.36%> (-1.57%) ⬇️
refinery/core/serializers.py 71.42% <44.44%> (-6.76%) ⬇️
refinery/file_store/tasks.py 34.58% <0%> (-18.75%) ⬇️
...nery/data_set_manager/single_file_column_parser.py 80.81% <0%> (-10.29%) ⬇️
refinery/file_store/utils.py 85.71% <0%> (-7.15%) ⬇️
refinery/data_set_manager/views.py 44.04% <0%> (-6.85%) ⬇️
refinery/data_set_manager/utils.py 76.21% <0%> (-5.65%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 972c153...84c9b54. Read the comment docs.

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

Copy link
Member

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]
Copy link
Member

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

Copy link
Member Author

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.

'User is not a member of group, %s', group
)

if group.name != 'Public':
Copy link
Member

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



class UserProfileViewSet(APIView):
"""API endpoint that allows for UserProfiles to be edits.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be edited

http_method_names = ["patch"]

def patch(self, request, uuid):
if not request.user.is_anonymous():
Copy link
Member

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
    )

@jkmarx jkmarx merged commit ef22e8e into develop Jun 18, 2018
@jkmarx jkmarx deleted the jkmarx/add-primary-group-api branch June 18, 2018 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants