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

[PR #674/b1725ad6 backport][2.10] Fix group related creation hooks if no user #676

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/673.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed group related creation hooks that failed if no current user could be identified.
10 changes: 5 additions & 5 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ def create_namespace_group(self, permissions, parameters):
group = Group.objects.create(
name="{}.{}.{}".format("container.namespace", group_type, self.name)
)
current_user = get_current_authenticated_user()
owners_group = Group.objects.get(
name="{}.{}".format("container.namespace.owners", self.name)
)
assign_perm("core.change_group", owners_group, group)
assign_perm("core.view_group", owners_group, group)
if add_user_to_group:
current_user = get_current_authenticated_user()
if current_user and add_user_to_group:
current_user.groups.add(group)
self.add_for_groups(permissions, group.name)

Expand Down Expand Up @@ -434,7 +434,7 @@ def add_perms_to_distribution_group(self, permissions, parameters):
name="{}.{}.{}".format("container.distribution", group_type, suffix)
)
current_user = get_current_authenticated_user()
if add_user_to_group:
if current_user and add_user_to_group:
current_user.groups.add(group)
self.add_for_groups(permissions, group.name)

Expand Down Expand Up @@ -516,13 +516,13 @@ def create_distribution_group(self, permissions, parameters):
group = Group.objects.create(
name="{}.{}.{}".format("container.distribution", group_type, self.pk)
)
current_user = get_current_authenticated_user()
owners_group = Group.objects.get(
name="{}.{}".format("container.distribution.owners", self.pk)
)
assign_perm("core.change_group", owners_group, group)
assign_perm("core.view_group", owners_group, group)
if add_user_to_group:
current_user = get_current_authenticated_user()
if current_user and add_user_to_group:
current_user.groups.add(group)
self.add_for_groups(permissions, group.name)

Expand Down