Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Paul Milleville
SCODOC_R6A06
Commits
c279fcd0
Commit
c279fcd0
authored
3 months ago
by
ilona
Browse files
Options
Downloads
Patches
Plain Diff
New command line: user-edit
parent
ea6307ac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scodoc.py
+85
-0
85 additions, 0 deletions
scodoc.py
with
85 additions
and
0 deletions
scodoc.py
+
85
−
0
View file @
c279fcd0
...
...
@@ -430,6 +430,91 @@ def user_change_login(user_name, new_user_name):
user
.
change_user_name
(
new_user_name
)
@app.cli.command
()
@click.argument
(
"
username
"
)
@click.option
(
"
-d
"
,
"
--deactivate
"
,
"
deactivate
"
,
is_flag
=
True
,
help
=
"
désactive ce compte
"
,
)
@click.option
(
"
-a
"
,
"
--activate
"
,
"
activate
"
,
is_flag
=
True
,
help
=
"
(ré)active ce compte
"
,
)
@click.option
(
"
-c
"
,
"
--cas-id
"
,
"
cas_id
"
)
@click.option
(
"
--allow-cas-login
"
,
"
allow_cas_login
"
,
is_flag
=
True
,
help
=
"
autorise login via CAS
"
,
)
@click.option
(
"
--disable-cas-login
"
,
"
disable_cas_login
"
,
is_flag
=
True
,
help
=
"
interdit login via CAS
"
,
)
@click.option
(
"
--allow-scodoc-login
"
,
"
allow_scodoc_login
"
,
is_flag
=
True
,
help
=
"
autorise login via ScoDoc
"
,
)
@click.option
(
"
--disable-scodoc-login
"
,
"
disable_scodoc_login
"
,
is_flag
=
True
,
help
=
"
interdit login via ScoDoc
"
,
)
@click.option
(
"
-v
"
,
"
--verbose
"
,
"
verbose
"
,
is_flag
=
True
,
help
=
"
verbose: affiche l
'
état après modif.
"
,
)
def
user_edit
(
username
,
cas_id
:
str
=
None
,
allow_cas_login
=
None
,
allow_scodoc_login
=
None
,
disable_cas_login
=
None
,
disable_scodoc_login
=
None
,
activate
=
None
,
deactivate
=
None
,
verbose
=
False
,
):
"""
Add or remove a role to the given user in the given dept
"""
user
:
User
=
User
.
query
.
filter_by
(
user_name
=
username
).
first
()
if
not
user
:
sys
.
stderr
.
write
(
f
"
user_role: user
{
username
}
does not exists
\n
"
)
return
1
if
cas_id
:
user
.
cas_id
=
cas_id
if
allow_cas_login
:
user
.
cas_allow_login
=
True
if
disable_cas_login
:
user
.
cas_allow_login
=
False
if
allow_scodoc_login
:
user
.
cas_allow_scodoc_login
=
True
if
disable_scodoc_login
:
user
.
cas_allow_scodoc_login
=
False
if
activate
:
user
.
active
=
True
if
deactivate
:
user
.
active
=
False
db
.
session
.
add
(
user
)
db
.
session
.
commit
()
if
verbose
:
for
k
,
v
in
sorted
(
user
.
to_dict
().
items
()):
print
(
f
"
{
k
}
:
{
v
}
"
)
def
abort_if_false
(
ctx
,
param
,
value
):
if
not
value
:
ctx
.
abort
()
...
...
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