Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
c8c0479c
Commit
c8c0479c
authored
Jun 06, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改清理用户组脚本
parent
30afcecf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
clean_duplicate_user_groups.py
utils/clean_duplicate_user_groups.py
+6
-1
No files found.
utils/clean_duplicate_user_groups.py
View file @
c8c0479c
...
...
@@ -17,9 +17,14 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
django
.
setup
()
from
users.models
import
UserGroup
from
django.core.exceptions
import
FieldError
def
clean_group
(
interactive
=
True
):
try
:
UserGroup
.
objects
.
all
()
.
filter
(
is_discard
=
True
)
.
delete
()
except
FieldError
:
pass
groups
=
UserGroup
.
objects
.
all
()
groups_name_list
=
groups
.
values_list
(
'name'
,
flat
=
True
)
groups_with_info
=
groups
.
annotate
(
Count
(
'users'
))
\
...
...
@@ -50,7 +55,7 @@ def clean_group(interactive=True):
"Delete user group <{}>, create at {}? ([y]/n)"
.
format
(
name
,
group
.
date_created
)
)
if
confirm
.
lower
()
==
"y"
:
if
confirm
.
lower
()
in
[
"y"
,
""
]
:
confirm
=
True
break
elif
confirm
.
lower
()
==
"n"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment