From 1184fa8b540b1fef205fd87e3a8f0a8a2c702d76 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 08:57:19 +0300 Subject: Register "group_management" blueprint --- wqflask/wqflask/__init__.py | 2 ++ wqflask/wqflask/group_manager.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index 98416b41..05e040ed 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -12,6 +12,7 @@ from utility import formatting from gn3.authentication import DataRole, AdminRole from wqflask.group_manager import group_management +from wqflask.resource_manager import resource_management from wqflask.metadata_edits import metadata_edit from wqflask.api.markdown import glossary_blueprint @@ -66,6 +67,7 @@ app.register_blueprint(jupyter_notebooks, url_prefix="/jupyter_notebooks") app.register_blueprint(resource_management, url_prefix="/resource-management") app.register_blueprint(metadata_edit, url_prefix="/datasets/") +app.register_blueprint(group_management, url_prefix="/group-management") @app.before_request def before_request(): diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index e69de29b..4edafc66 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -0,0 +1,31 @@ +import redis + +from flask import current_app +from flask import Blueprint +from flask import g +from flask import render_template +from gn3.authentication import get_groups_by_user_uid +from wqflask.decorators import login_required + +group_management = Blueprint("group_management", __name__) + + +@group_management.route("/groups") +@login_required +def view_groups(): + groups = get_groups_by_user_uid( + user_uid=(g.user_session.record.get(b"user_id", + b"").decode("utf-8") or + g.user_session.record.get("user_id", "")), + conn=redis.from_url( + current_app.config["REDIS_URL"], + decode_responses=True)) + return render_template("admin/group_manager.html", + admin_groups=groups.get("admin"), + member_groups=groups.get("member")) + + +@group_management.route("/groups/create", methods=("GET",)) +@login_required +def view_create_group_page(): + return render_template("admin/create_group.html") -- cgit v1.2.3