Compare commits
No commits in common. "0570a9a32ff2e7eaf753226f169748c57c496c6d" and "4f20a94f60dd0da3b43caae6f991592d701e58e5" have entirely different histories.
0570a9a32f
...
4f20a94f60
|
@ -2,23 +2,20 @@
|
||||||
|
|
||||||
Provides routes used to manage users
|
Provides routes used to manage users
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from http.client import CREATED
|
from http.client import CREATED
|
||||||
|
from flask import Blueprint, request, jsonify, make_response, after_this_request, Response
|
||||||
from flask import Blueprint, Response, after_this_request, jsonify, make_response, request
|
|
||||||
from werkzeug.exceptions import BadRequest, Forbidden, MethodNotAllowed
|
from werkzeug.exceptions import BadRequest, Forbidden, MethodNotAllowed
|
||||||
|
from datetime import datetime
|
||||||
from flaschengeist import logger
|
|
||||||
from flaschengeist.config import config
|
|
||||||
from flaschengeist.controller import userController
|
|
||||||
from flaschengeist.models import User
|
|
||||||
from flaschengeist.plugins import Plugin
|
|
||||||
from flaschengeist.utils.datetime import from_iso_format
|
|
||||||
from flaschengeist.utils.decorators import extract_session, headers, login_required
|
|
||||||
from flaschengeist.utils.HTTP import created, no_content
|
|
||||||
|
|
||||||
from . import permissions
|
from . import permissions
|
||||||
|
from flaschengeist import logger
|
||||||
|
from flaschengeist.config import config
|
||||||
|
from flaschengeist.plugins import Plugin
|
||||||
|
from flaschengeist.models import User
|
||||||
|
from flaschengeist.utils.decorators import login_required, extract_session, headers
|
||||||
|
from flaschengeist.controller import userController
|
||||||
|
from flaschengeist.utils.HTTP import created, no_content
|
||||||
|
from flaschengeist.utils.datetime import from_iso_format
|
||||||
|
|
||||||
|
|
||||||
class UsersPlugin(Plugin):
|
class UsersPlugin(Plugin):
|
||||||
|
@ -61,7 +58,7 @@ def register():
|
||||||
|
|
||||||
@UsersPlugin.blueprint.route("/users", methods=["GET"])
|
@UsersPlugin.blueprint.route("/users", methods=["GET"])
|
||||||
@login_required()
|
@login_required()
|
||||||
# @headers({"Cache-Control": "private, must-revalidate, max-age=3600"})
|
@headers({"Cache-Control": "private, must-revalidate, max-age=3600"})
|
||||||
def list_users(current_session):
|
def list_users(current_session):
|
||||||
"""List all existing users
|
"""List all existing users
|
||||||
|
|
||||||
|
@ -263,21 +260,3 @@ def shortcuts(userid, current_session):
|
||||||
user.set_attribute("users_link_shortcuts", data)
|
user.set_attribute("users_link_shortcuts", data)
|
||||||
userController.persist()
|
userController.persist()
|
||||||
return no_content()
|
return no_content()
|
||||||
|
|
||||||
|
|
||||||
@UsersPlugin.blueprint.route("/users/<userid>/setting/<setting>", methods=["GET", "PUT"])
|
|
||||||
@login_required()
|
|
||||||
def settings(userid, setting, current_session):
|
|
||||||
if userid != current_session.user_.userid:
|
|
||||||
raise Forbidden
|
|
||||||
user = userController.get_user(userid)
|
|
||||||
if request.method == "GET":
|
|
||||||
retVal = user.get_attribute(setting, None)
|
|
||||||
logger.debug(f"Get setting >>{setting}<< for user >>{user.userid}<< with >>{retVal}<<")
|
|
||||||
return jsonify(retVal)
|
|
||||||
else:
|
|
||||||
data = request.get_json()
|
|
||||||
logger.debug(f"Set setting >>{setting}<< for user >>{user.userid}<< to >>{data}<<")
|
|
||||||
user.set_attribute(setting, data)
|
|
||||||
userController.persist()
|
|
||||||
return no_content()
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
license = MIT
|
license = MIT
|
||||||
version = 2.1.0
|
version = 2.0.0
|
||||||
name = flaschengeist
|
name = flaschengeist
|
||||||
author = Tim Gröger
|
author = Tim Gröger
|
||||||
author_email = flaschengeist@wu5.de
|
author_email = flaschengeist@wu5.de
|
||||||
|
@ -39,7 +39,7 @@ install_requires =
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
argon = argon2-cffi
|
argon = argon2-cffi
|
||||||
ldap = flask_ldapconn @ git+https://github.com/rroemhild/flask-ldapconn.git; ldap3
|
ldap = flask_ldapconn; ldap3
|
||||||
tests = pytest; pytest-depends; coverage
|
tests = pytest; pytest-depends; coverage
|
||||||
mysql =
|
mysql =
|
||||||
PyMySQL;platform_system=='Windows'
|
PyMySQL;platform_system=='Windows'
|
||||||
|
|
Loading…
Reference in New Issue