2021-06-26 21:57:54 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# ScoDoc
|
|
|
|
#
|
|
|
|
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
Module users: interface gestion utilisateurs
|
|
|
|
ré-écriture pour Flask ScoDoc7 / ZScoUsers.py
|
|
|
|
|
|
|
|
Vues s'appuyant sur auth et sco_users
|
|
|
|
|
|
|
|
Emmanuel Viennet, 2021
|
|
|
|
"""
|
|
|
|
|
|
|
|
from flask import g
|
2021-06-27 12:11:39 +02:00
|
|
|
from flask import current_app, request
|
2021-06-26 21:57:54 +02:00
|
|
|
|
|
|
|
from app.auth.models import Permission
|
|
|
|
from app.auth.models import User
|
|
|
|
from app.decorators import (
|
|
|
|
scodoc7func,
|
|
|
|
ScoDoc7Context,
|
|
|
|
permission_required,
|
|
|
|
admin_required,
|
|
|
|
login_required,
|
2021-06-27 12:11:39 +02:00
|
|
|
ZRequest,
|
2021-06-26 21:57:54 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
from app.scodoc import sco_users
|
2021-06-27 12:11:39 +02:00
|
|
|
from app.scodoc import sco_utils as scu
|
2021-06-26 21:57:54 +02:00
|
|
|
|
|
|
|
from app.views import users_bp as bp
|
|
|
|
|
|
|
|
|
|
|
|
context = ScoDoc7Context("users") # sco8
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/")
|
|
|
|
@bp.route("/index_html")
|
|
|
|
@permission_required(Permission.ScoUsersView)
|
|
|
|
@scodoc7func(context)
|
2021-06-27 12:11:39 +02:00
|
|
|
def index_html(context, REQUEST, all_depts=False, with_inactives=False, format="html"):
|
2021-06-26 21:57:54 +02:00
|
|
|
return sco_users.index_html(
|
|
|
|
context,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
all_depts=all_depts,
|
2021-06-27 12:11:39 +02:00
|
|
|
with_inactives=with_inactives,
|
2021-06-26 21:57:54 +02:00
|
|
|
format=format,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-06-27 12:11:39 +02:00
|
|
|
@bp.route("/user_info")
|
|
|
|
@permission_required(Permission.ScoUsersView)
|
|
|
|
@scodoc7func(context)
|
|
|
|
def user_info(user_name, format="json", REQUEST=None):
|
|
|
|
info = sco_users.user_info(user_name=user_name)
|
|
|
|
return scu.sendResult(REQUEST, info, name="user", format=format)
|
|
|
|
|
|
|
|
|
2021-06-26 21:57:54 +02:00
|
|
|
@bp.route("/create_user_form")
|
|
|
|
def create_user_form():
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/import_users_form")
|
|
|
|
def import_users_form():
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2021-06-27 12:11:39 +02:00
|
|
|
@bp.route("/user_info_page")
|
|
|
|
@scodoc7func(context)
|
|
|
|
def user_info_page(user_name, REQUEST=None):
|
|
|
|
return sco_users.user_info_page(context, user_name=user_name, REQUEST=REQUEST)
|