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
b55ed9db
There was a problem fetching the pipeline summary.
Commit
b55ed9db
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[teams] Closes issue
#406
parent
1902bcf8
No related branches found
No related tags found
1 merge request
!206
Issue 406
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/team/api.py
+6
-1
6 additions, 1 deletion
beat/web/team/api.py
beat/web/team/models.py
+26
-0
26 additions, 0 deletions
beat/web/team/models.py
with
32 additions
and
1 deletion
beat/web/team/api.py
+
6
−
1
View file @
b55ed9db
...
...
@@ -42,7 +42,7 @@ from .serializers import TeamUpdateSerializer
from
.models
import
Team
from
.permissions
import
IsOwner
,
HasPrivacyLevel
from
..common.responses
import
BadRequestResponse
from
..common.responses
import
BadRequestResponse
,
ForbiddenResponse
from
..common.mixins
import
CommonContextMixin
...
...
@@ -117,6 +117,11 @@ class TeamDetailView(CommonContextMixin, generics.RetrieveUpdateDestroyAPIView):
def
delete
(
self
,
request
,
owner_name
,
team_name
):
team
=
self
.
get_queryset
()
# Check that the team can still be deleted
if
not
(
team
.
deletable
()):
return
ForbiddenResponse
(
"
The team isn
'
t deletable (it has been used to share %d objects with its members)
"
%
team
.
total_shares
())
team
.
delete
()
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
...
...
This diff is collapsed.
Click to expand it.
beat/web/team/models.py
+
26
−
0
View file @
b55ed9db
...
...
@@ -93,6 +93,32 @@ class Team(models.Model):
return
(
self
.
owner
.
username
,
self
.
name
)
def
total_shares
(
self
):
used_at
=
0
used_at
+=
self
.
shared_algorithms
.
count
()
used_at
+=
self
.
shared_databases
.
count
()
used_at
+=
self
.
shared_dataformats
.
count
()
used_at
+=
self
.
shared_environment
.
count
()
used_at
+=
self
.
shared_experiments
.
count
()
used_at
+=
self
.
shared_librarys
.
count
()
used_at
+=
self
.
shared_plotterparameters
.
count
()
used_at
+=
self
.
shared_plotters
.
count
()
used_at
+=
self
.
shared_searchs
.
count
()
used_at
+=
self
.
shared_toolchains
.
count
()
used_at
+=
self
.
usable_algorithm
.
count
()
used_at
+=
self
.
usable_library
.
count
()
used_at
+=
self
.
usable_plotterparameters
.
count
()
used_at
+=
self
.
usable_plotters
.
count
()
return
used_at
def
deletable
(
self
):
return
not
self
.
total_shares
()
#_____ Overrides __________
def
__unicode__
(
self
):
...
...
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