Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
a37baaad
Commit
a37baaad
authored
4 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Plain Diff
Merge branch 'stale-read-delete-admin' into 'master'
Prevent removing all admins of a group using the default DB Closes
#644
See merge request
!1207
parents
2e0b31de
051d8f3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1207
Prevent removing all admins of a group using the default DB
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/users/api.py
+2
-2
2 additions, 2 deletions
arkindex/users/api.py
with
2 additions
and
2 deletions
arkindex/users/api.py
+
2
−
2
View file @
a37baaad
...
...
@@ -641,11 +641,11 @@ class MembershipDetails(RetrieveUpdateDestroyAPIView):
)
def
perform_destroy
(
self
,
instance
):
# At l
i
st one admin member must exist except for workers which depends on their repositories
# At l
ea
st one admin member must exist except for workers which depends on their repositories
if
(
instance
.
content_type
!=
ContentType
.
objects
.
get_for_model
(
Worker
)
and
instance
.
level
>=
Role
.
Admin
.
value
and
instance
.
content_object
.
memberships
.
filter
(
level__gte
=
Role
.
Admin
.
value
).
count
()
<
2
and
instance
.
content_object
.
memberships
.
using
(
'
default
'
).
filter
(
level__gte
=
Role
.
Admin
.
value
).
count
()
<
2
):
raise
ValidationError
({
'
detail
'
:
[
'
Removing all memberships with an admin privilege is not possible.
'
]})
return
super
().
perform_destroy
(
instance
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment