Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
77cc651e
Commit
77cc651e
authored
4 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[team][api] Replace custom delete with perform_destroy hook
parent
564205a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!327
Refactor update creation api
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/team/api.py
+7
-12
7 additions, 12 deletions
beat/web/team/api.py
with
7 additions
and
12 deletions
beat/web/team/api.py
+
7
−
12
View file @
77cc651e
...
...
@@ -32,8 +32,8 @@ from django.db.models import Q
from
rest_framework
import
generics
from
rest_framework
import
permissions
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
rest_framework.reverse
import
reverse
from
rest_framework
import
exceptions
as
drf_exceptions
from
.serializers
import
FullTeamSerializer
from
.serializers
import
SimpleTeamSerializer
...
...
@@ -42,7 +42,7 @@ from .serializers import TeamUpdateSerializer
from
.models
import
Team
from
.permissions
import
IsOwner
,
HasPrivacyLevel
from
..common.responses
import
BadRequestResponse
,
ForbiddenResponse
from
..common.responses
import
BadRequestResponse
from
..common.mixins
import
CommonContextMixin
...
...
@@ -122,18 +122,13 @@ class TeamDetailView(CommonContextMixin, generics.RetrieveUpdateDestroyAPIView):
context
[
"
user
"
]
=
self
.
request
.
user
return
context
def
delete
(
self
,
request
,
owner_name
,
team_name
):
team
=
self
.
get_object
()
# Check that the team can still be deleted
if
not
(
team
.
deletable
()):
return
ForbiddenResponse
(
def
perform_destroy
(
self
,
instance
):
if
not
instance
.
deletable
():
raise
drf_exceptions
.
PermissionDenied
(
"
The team isn
'
t deletable (it has been used to share %d objects with its members)
"
%
team
.
total_shares
()
%
instance
.
total_shares
()
)
team
.
delete
()
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
return
super
().
perform_destroy
(
instance
)
def
update
(
self
,
request
,
owner_name
,
team_name
):
team
=
self
.
get_object
()
...
...
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