diff --git a/app/templates/main/index.html b/app/templates/main/index.html
index 61ec1a72d..179c1d6d9 100644
--- a/app/templates/main/index.html
+++ b/app/templates/main/index.html
@@ -23,18 +23,10 @@
formsemestre_status : a-t-on
le rôle EnsRT ?
- sco_exemple?etudid=E123 : test "scodoc", url
+ Notes/essai : test "notes", url
manuelle
- sco_exemple2 : test appel
- entre vues
-
-
- sco_get_version : test
- appel vers ScoDoc interne (arg. REQUEST positionnel).
-
-
- sco_get_version : vue
- protégée par perm. VIEW.
+ Notes/essai2 : permission
+ ScoImplement dans RT
diff --git a/app/views/notes.py b/app/views/notes.py
index f08239246..7234d26b7 100644
--- a/app/views/notes.py
+++ b/app/views/notes.py
@@ -160,7 +160,7 @@ def essai2(context):
return essai_(context, "sans request")
-sco_publish("/essai2", essai2, Permission.ScoView)
+sco_publish("/essai2", essai2, Permission.ScoImplement)
# ---------------------
diff --git a/scodoc.py b/scodoc.py
index 68b7b0e86..0ced10015 100755
--- a/scodoc.py
+++ b/scodoc.py
@@ -10,7 +10,7 @@
from __future__ import print_function
from pprint import pprint as pp
-
+import sys
import click
import flask
@@ -40,7 +40,7 @@ def make_shell_context():
@app.cli.command()
-def inituserdb():
+def user_db_init():
"""Initialize the users database."""
click.echo("Init the db")
# Create roles:
@@ -62,14 +62,59 @@ def inituserdb():
@app.cli.command()
-def clearuserdb():
+def user_db_clear():
"""Erase (drop) all tables of users database !"""
- click.echo("Erasing the db !")
- _cleardb()
+ click.echo("Erasing the users database !")
+ _clear_users_db()
-def _cleardb():
+def _clear_users_db():
"""Erase (drop) all tables of users database !"""
+ click.confirm("This will erase all users.\nDo you want to continue?", abort=True)
db.reflect()
db.drop_all()
db.session.commit()
+
+
+@app.cli.command()
+@click.argument("username")
+@click.argument("role")
+@click.argument("dept")
+def user_create(username, role, dept):
+ "Create a new user"
+ r = Role.get_named_role(role)
+ if not r:
+ sys.stderr.write("user_create: role {r} does not exists".format(r=r))
+ return 1
+ u = User.query.filter_by(username=username).first()
+ if u:
+ sys.stderr.write("user_create: user {u} already exists".format(u=u))
+ return 2
+ u = User(username=username)
+ u.add_role(r, dept)
+ db.session.add(u)
+ db.session.commit()
+ click.echo(
+ "created user, login: {u.username}, with role {r} in dept. {dept}".format(
+ u=u, r=r, dept=dept
+ )
+ )
+
+
+@app.cli.command()
+@click.argument("username")
+@click.password_option()
+def user_password(username, password=None):
+ "Set (or change) user's password"
+ if not password:
+ sys.stderr.write("user_password: missing password")
+ return 1
+ u = User.query.filter_by(username=username).first()
+ if not u:
+ sys.stderr.write("user_password: user {} does not exists".format(username))
+ return 1
+
+ u.set_password(password)
+ db.session.add(u)
+ db.session.commit()
+ click.echo("changed password for user {}".format(u))