96 lines
2.6 KiB
Python
96 lines
2.6 KiB
Python
# -*- 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
|
|
from flask import current_app, request
|
|
|
|
from app.auth.models import Permission
|
|
from app.auth.models import User
|
|
from app.decorators import (
|
|
scodoc7func,
|
|
ScoDoc7Context,
|
|
permission_required,
|
|
admin_required,
|
|
login_required,
|
|
ZRequest,
|
|
)
|
|
|
|
from app.scodoc import sco_users
|
|
from app.scodoc import sco_utils as scu
|
|
|
|
from app.views import users_bp as bp
|
|
|
|
|
|
context = ScoDoc7Context("users") # sco8
|
|
|
|
|
|
@bp.route("/")
|
|
@bp.route("/index_html")
|
|
@permission_required(Permission.ScoUsersView)
|
|
@scodoc7func(context)
|
|
def index_html(context, REQUEST, all_depts=False, with_inactives=False, format="html"):
|
|
return sco_users.index_html(
|
|
context,
|
|
REQUEST=REQUEST,
|
|
all_depts=all_depts,
|
|
with_inactives=with_inactives,
|
|
format=format,
|
|
)
|
|
|
|
|
|
@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)
|
|
|
|
|
|
@bp.route("/create_user_form")
|
|
def create_user_form():
|
|
raise NotImplementedError()
|
|
|
|
|
|
@bp.route("/import_users_form")
|
|
def import_users_form():
|
|
raise NotImplementedError()
|
|
|
|
|
|
@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)
|