-
Notifications
You must be signed in to change notification settings - Fork 24
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 group member api #3309
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
6553d89
Extend group api to update group perms and retrieve all group info.
jkmarx e8d769e
Add unit tests.
jkmarx 397603e
Refactor and add utils method.
jkmarx 621bd48
Fix method name and comments for clarity.
jkmarx 3fb5ac8
Refactor other view sets to use helper. (#3286)
jkmarx 65722cf
Resolve merge conflict.
jkmarx 964bd37
Refactor email address in tests.
jkmarx 8e52d31
Update return statuses for clarity
jkmarx 4c5aabd
Limit group returns by user membership.
jkmarx b987154
Remove unused groupManagementResource.
jkmarx 694872c
Extend api to create groups.
jkmarx faa52d1
Resolve merge conflict.
jkmarx 8dc2e47
Add unit tests.
jkmarx 30e4eca
Merge branch 'develop' of https://github.com/refinery-platform/refine…
jkmarx 88446c8
Extend api to return all member groups.
jkmarx e423606
Add unit tests.
jkmarx 9deb3ed
Merge branch 'develop' of https://github.com/refinery-platform/refine…
jkmarx c40d450
Add unit tests.
jkmarx b5774a5
Extend group API to destroy.
jkmarx cc3ed54
Add unit tests.
jkmarx 41d9a0a
Fix typo.
jkmarx 0ec7315
Update client.
jkmarx 9dde810
Extend api to return can_edit field.
jkmarx 27f9405
Add group unit tests.
jkmarx b260db1
Avoid unneccessary api call.
jkmarx 8c1d0e5
Adjust fields to accomodate current client.
jkmarx b9d12f2
Add unit tests.
jkmarx 34c4f56
Resolve merge conflicts.
jkmarx 1688a71
Move helper to model method.
jkmarx c07b901
Add unit tests.
jkmarx 55f0969
Fix flake issue with line break.
jkmarx b03f733
Update client to group memebers api v2. (#3310)
jkmarx be9d803
Fix method name.
jkmarx File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,7 @@ def partial_update(self, instance, validated_data): | |
|
||
|
||
class ExtendedGroupSerializer(serializers.ModelSerializer): | ||
manager_group_uuid = serializers.SerializerMethodField() | ||
member_list = serializers.SerializerMethodField() | ||
perm_list = serializers.SerializerMethodField() | ||
can_edit = serializers.SerializerMethodField() | ||
|
@@ -128,6 +129,11 @@ class ExtendedGroupSerializer(serializers.ModelSerializer): | |
validators=[UniqueValidator(queryset=ExtendedGroup.objects.all())] | ||
) | ||
|
||
def get_manager_group_uuid(self, group): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems redundant. Doesn't appear to be used anywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a field the client expects. |
||
if group.is_manager_group(): | ||
return '' | ||
return group.manager_group.uuid | ||
|
||
def get_can_edit(self, group): | ||
user = self.context.get('user') | ||
if user is None: | ||
|
@@ -145,7 +151,18 @@ def get_member_list(self, group): | |
users = group.user_set.all().filter(is_active=True).exclude( | ||
username=settings.ANONYMOUS_USER_NAME | ||
) | ||
return UserSerializer(users, many=True).data | ||
user_data = UserSerializer(users, many=True).data | ||
for user in user_data: | ||
if group.is_manager_group(): | ||
user['is_manager'] = user.get('id') in \ | ||
group.user_set.all().values_list( | ||
'id', flat=True | ||
) | ||
else: | ||
user['is_manager'] = user.get('id') in \ | ||
group.manager_group.user_set.all()\ | ||
.values_list('id', flat=True) | ||
return user_data | ||
return [] | ||
|
||
def get_perm_list(self, group): | ||
|
@@ -162,7 +179,8 @@ def get_uuid(self, group): | |
|
||
class Meta: | ||
model = ExtendedGroup | ||
fields = ('can_edit', 'name', 'id', 'uuid', 'member_list', 'perm_list') | ||
fields = ('can_edit', 'name', 'id', 'uuid', 'manager_group_uuid', | ||
'member_list', 'perm_list') | ||
|
||
|
||
class SiteVideoSerializer(serializers.ModelSerializer): | ||
|
@@ -248,7 +266,7 @@ class UserSerializer(serializers.ModelSerializer): | |
|
||
class Meta: | ||
model = User | ||
fields = ('first_name', 'last_name', 'profile', 'username') | ||
fields = ('first_name', 'id', 'last_name', 'profile', 'username') | ||
|
||
|
||
class WorkflowSerializer(serializers.HyperlinkedModelSerializer): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sounds like it should be a method on the User model.