From 9f7e3035d13b286238d878a0baa45cb4c1708cee Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Nov 2021 16:19:40 +0300 Subject: Fix URL --- wqflask/wqflask/templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index ab8b644f..6e922f24 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -87,7 +87,7 @@
  • Systems Genetics PheWAS
  • Genome Browser
  • BXD Power Calculator
  • -
  • Jupyter Notebook Launcher
  • +
  • Jupyter Notebook Launcher
  • Interplanetary File System
  • -- cgit v1.2.3 From 14f3d5da0de60dea8b0a24f68c2e658d92268e3a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Nov 2021 16:40:22 +0300 Subject: Add some styling for the Jupyter links --- wqflask/wqflask/static/new/css/jupyter_notebooks.css | 12 ++++++++++++ wqflask/wqflask/templates/jupyter_notebooks.html | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 wqflask/wqflask/static/new/css/jupyter_notebooks.css (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/css/jupyter_notebooks.css b/wqflask/wqflask/static/new/css/jupyter_notebooks.css new file mode 100644 index 00000000..b916f03b --- /dev/null +++ b/wqflask/wqflask/static/new/css/jupyter_notebooks.css @@ -0,0 +1,12 @@ +.jupyter-links .main-link:nth-of-type(2n) { + background: #EEEEEE; +} + +.jupyter-links .main-link { + font-size: larger; + display: block; +} + +.jupyter-links .src-link { + font-size: smaller; +} diff --git a/wqflask/wqflask/templates/jupyter_notebooks.html b/wqflask/wqflask/templates/jupyter_notebooks.html index 4dce0f27..da250b2a 100644 --- a/wqflask/wqflask/templates/jupyter_notebooks.html +++ b/wqflask/wqflask/templates/jupyter_notebooks.html @@ -4,6 +4,10 @@ Jupyter Notebooks {%endblock%} +{%block css%} + +{%endblock} + {%block content%}
    -- cgit v1.2.3 From c63d10c565f82413ae8b5e553b1f00485439530a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Nov 2021 16:43:50 +0300 Subject: Fix syntax error --- wqflask/wqflask/templates/jupyter_notebooks.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/jupyter_notebooks.html b/wqflask/wqflask/templates/jupyter_notebooks.html index da250b2a..afc95a15 100644 --- a/wqflask/wqflask/templates/jupyter_notebooks.html +++ b/wqflask/wqflask/templates/jupyter_notebooks.html @@ -6,7 +6,7 @@ Jupyter Notebooks {%block css%} -{%endblock} +{%endblock%} {%block content%} -- cgit v1.2.3 From 5a14bbc53dafd7b85c3e903a3dcb2dab87a6fed2 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Nov 2021 16:45:05 +0300 Subject: Fix styling of divs --- wqflask/wqflask/static/new/css/jupyter_notebooks.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/css/jupyter_notebooks.css b/wqflask/wqflask/static/new/css/jupyter_notebooks.css index b916f03b..663d1746 100644 --- a/wqflask/wqflask/static/new/css/jupyter_notebooks.css +++ b/wqflask/wqflask/static/new/css/jupyter_notebooks.css @@ -1,4 +1,4 @@ -.jupyter-links .main-link:nth-of-type(2n) { +.jupyter-links:nth-of-type(2n) { background: #EEEEEE; } -- cgit v1.2.3 From a2f2d89a5fbe720d3c1f1ac9655adca8b2ff503d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Nov 2021 16:48:32 +0300 Subject: Add some padding --- wqflask/wqflask/static/new/css/jupyter_notebooks.css | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/css/jupyter_notebooks.css b/wqflask/wqflask/static/new/css/jupyter_notebooks.css index 663d1746..db972a17 100644 --- a/wqflask/wqflask/static/new/css/jupyter_notebooks.css +++ b/wqflask/wqflask/static/new/css/jupyter_notebooks.css @@ -1,3 +1,7 @@ +.jupyter-links { + padding: 1.5em; +} + .jupyter-links:nth-of-type(2n) { background: #EEEEEE; } -- cgit v1.2.3 From 2fcf4d0343244936d6b066e85a1a06ebb33adf26 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 9 Nov 2021 19:29:52 +0000 Subject: Temporary fix to get temp trait submission working again; maybe should be dealt with in GN3 in some way --- wqflask/wqflask/show_trait/show_trait.py | 10 ++++++---- wqflask/wqflask/templates/show_trait_details.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 6020bc16..678e3132 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -40,10 +40,15 @@ ONE_YEAR = 60 * 60 * 24 * 365 class ShowTrait: def __init__(self, user_id, kw): + self.admin_status = None if 'trait_id' in kw and kw['dataset'] != "Temp": self.temp_trait = False self.trait_id = kw['trait_id'] helper_functions.get_species_dataset_trait(self, kw) + self.admin_status = get_highest_user_access_role( + user_id=user_id, + resource_id=(self.resource_id or ""), + gn_proxy_url=GN_PROXY_URL) elif 'group' in kw: self.temp_trait = True self.trait_id = "Temp_" + kw['species'] + "_" + kw['group'] + \ @@ -73,10 +78,7 @@ class ShowTrait: self.trait_vals = Redis.get(self.trait_id).split() self.resource_id = get_resource_id(self.dataset, self.trait_id) - self.admin_status = get_highest_user_access_role( - user_id=user_id, - resource_id=(self.resource_id or ""), - gn_proxy_url=GN_PROXY_URL) + # ZS: Get verify/rna-seq link URLs try: blatsequence = self.this_trait.blatseq diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index 3e59a3ee..6b125221 100644 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -234,7 +234,7 @@ {% endif %} {% endif %} - {% if admin_status.get('metadata', DataRole.VIEW) > DataRole.VIEW %} + {% if admin_status != None and admin_status.get('metadata', DataRole.VIEW) > DataRole.VIEW %} {% if this_trait.dataset.type == 'Publish' %} {% endif %} -- cgit v1.2.3 From fe549317a5e0996cec246a011eb044b065f7ed8c Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 9 Nov 2021 22:04:24 +0000 Subject: Fixed error mistakenly introduced by the last commit --- wqflask/wqflask/show_trait/show_trait.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 678e3132..93f95852 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -45,6 +45,8 @@ class ShowTrait: self.temp_trait = False self.trait_id = kw['trait_id'] helper_functions.get_species_dataset_trait(self, kw) + self.resource_id = get_resource_id(self.dataset, + self.trait_id) self.admin_status = get_highest_user_access_role( user_id=user_id, resource_id=(self.resource_id or ""), @@ -76,8 +78,6 @@ class ShowTrait: name=self.trait_id, cellid=None) self.trait_vals = Redis.get(self.trait_id).split() - self.resource_id = get_resource_id(self.dataset, - self.trait_id) # ZS: Get verify/rna-seq link URLs try: -- cgit v1.2.3 From 721a45006697830c5bf780133c03d909c35b63a3 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 08:55:02 +0300 Subject: Apply pep-8 to file --- wqflask/wqflask/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index fbf1c9f5..98416b41 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -10,8 +10,8 @@ from urllib.parse import urlparse from utility import formatting from gn3.authentication import DataRole, AdminRole -from wqflask.resource_manager import resource_management +from wqflask.group_manager import group_management from wqflask.metadata_edits import metadata_edit from wqflask.api.markdown import glossary_blueprint @@ -65,7 +65,6 @@ app.register_blueprint(news_blueprint, url_prefix="/news") 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.before_request -- cgit v1.2.3 From d330150c71deb27c29c29bfce8f14856e49ca157 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 08:56:53 +0300 Subject: Delete all methods in group_manager.py --- wqflask/wqflask/group_manager.py | 175 --------------------------------------- 1 file changed, 175 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index 04a100ba..e69de29b 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -1,175 +0,0 @@ -import random -import string - -from flask import (Flask, g, render_template, url_for, request, make_response, - redirect, flash) - -from wqflask import app -from wqflask.user_login import send_verification_email, send_invitation_email, basic_info, set_password - -from utility.redis_tools import get_user_groups, get_group_info, save_user, create_group, delete_group, add_users_to_group, remove_users_from_group, \ - change_group_name, save_verification_code, check_verification_code, get_user_by_unique_column, get_resources, get_resource_info - -from utility.logger import getLogger -logger = getLogger(__name__) - - -@app.route("/groups/manage", methods=('GET', 'POST')) -def manage_groups(): - params = request.form if request.form else request.args - if "add_new_group" in params: - return redirect(url_for('add_group')) - else: - admin_groups, member_groups = get_user_groups(g.user_session.user_id) - return render_template("admin/group_manager.html", admin_groups=admin_groups, member_groups=member_groups) - - -@app.route("/groups/view", methods=('GET', 'POST')) -def view_group(): - params = request.form if request.form else request.args - group_id = params['id'] - group_info = get_group_info(group_id) - admins_info = [] - user_is_admin = False - if g.user_session.user_id in group_info['admins']: - user_is_admin = True - for user_id in group_info['admins']: - if user_id: - user_info = get_user_by_unique_column("user_id", user_id) - admins_info.append(user_info) - members_info = [] - for user_id in group_info['members']: - if user_id: - user_info = get_user_by_unique_column("user_id", user_id) - members_info.append(user_info) - - # ZS: This whole part might not scale well with many resources - resources_info = [] - all_resources = get_resources() - for resource_id in all_resources: - resource_info = get_resource_info(resource_id) - group_masks = resource_info['group_masks'] - if group_id in group_masks: - this_resource = {} - privileges = group_masks[group_id] - this_resource['id'] = resource_id - this_resource['name'] = resource_info['name'] - this_resource['data'] = privileges['data'] - this_resource['metadata'] = privileges['metadata'] - this_resource['admin'] = privileges['admin'] - resources_info.append(this_resource) - - return render_template("admin/view_group.html", group_info=group_info, admins=admins_info, members=members_info, user_is_admin=user_is_admin, resources=resources_info) - - -@app.route("/groups/remove", methods=('POST',)) -def remove_groups(): - group_ids_to_remove = request.form['selected_group_ids'] - for group_id in group_ids_to_remove.split(":"): - delete_group(g.user_session.user_id, group_id) - - return redirect(url_for('manage_groups')) - - -@app.route("/groups/remove_users", methods=('POST',)) -def remove_users(): - group_id = request.form['group_id'] - admin_ids_to_remove = request.form['selected_admin_ids'] - member_ids_to_remove = request.form['selected_member_ids'] - - remove_users_from_group(g.user_session.user_id, admin_ids_to_remove.split( - ":"), group_id, user_type="admins") - remove_users_from_group(g.user_session.user_id, member_ids_to_remove.split( - ":"), group_id, user_type="members") - - return redirect(url_for('view_group', id=group_id)) - - -@app.route("/groups/add_", methods=('POST',)) -def add_users(user_type='members'): - group_id = request.form['group_id'] - if user_type == "admins": - user_emails = request.form['admin_emails_to_add'].split(",") - add_users_to_group(g.user_session.user_id, group_id, - user_emails, admins=True) - elif user_type == "members": - user_emails = request.form['member_emails_to_add'].split(",") - add_users_to_group(g.user_session.user_id, group_id, - user_emails, admins=False) - - return redirect(url_for('view_group', id=group_id)) - - -@app.route("/groups/change_name", methods=('POST',)) -def change_name(): - group_id = request.form['group_id'] - new_name = request.form['new_name'] - group_info = change_group_name(g.user_session.user_id, group_id, new_name) - - return new_name - - -@app.route("/groups/create", methods=('GET', 'POST')) -def add_or_edit_group(): - params = request.form if request.form else request.args - if "group_name" in params: - member_user_ids = set() - admin_user_ids = set() - # ZS: Always add the user creating the group as an admin - admin_user_ids.add(g.user_session.user_id) - if "admin_emails_to_add" in params: - admin_emails = params['admin_emails_to_add'].split(",") - for email in admin_emails: - user_details = get_user_by_unique_column( - "email_address", email) - if user_details: - admin_user_ids.add(user_details['user_id']) - #send_group_invites(params['group_id'], user_email_list = admin_emails, user_type="admins") - if "member_emails_to_add" in params: - member_emails = params['member_emails_to_add'].split(",") - for email in member_emails: - user_details = get_user_by_unique_column( - "email_address", email) - if user_details: - member_user_ids.add(user_details['user_id']) - #send_group_invites(params['group_id'], user_email_list = user_emails, user_type="members") - - create_group(list(admin_user_ids), list( - member_user_ids), params['group_name']) - return redirect(url_for('manage_groups')) - else: - return render_template("admin/create_group.html") - -# ZS: Will integrate this later, for now just letting users be added directly - - -def send_group_invites(group_id, user_email_list=[], user_type="members"): - for user_email in user_email_list: - user_details = get_user_by_unique_column("email_address", user_email) - if user_details: - group_info = get_group_info(group_id) - # ZS: Probably not necessary since the group should normally always exist if group_id is being passed here, - # but it's technically possible to hit it if Redis is cleared out before submitting the new users or something - if group_info: - # ZS: Don't add user if they're already an admin or if they're being added a regular user and are already a regular user, - # but do add them if they're a regular user and are added as an admin - if (user_details['user_id'] in group_info['admins']) or \ - ((user_type == "members") and (user_details['user_id'] in group_info['members'])): - continue - else: - send_verification_email(user_details, template_name="email/group_verification.txt", - key_prefix="verification_code", subject="You've been invited to join a GeneNetwork user group") - else: - temp_password = ''.join(random.choice( - string.ascii_uppercase + string.digits) for _ in range(6)) - user_details = { - 'user_id': str(uuid.uuid4()), - 'email_address': user_email, - 'registration_info': basic_info(), - 'password': set_password(temp_password), - 'confirmed': 0 - } - save_user(user_details, user_details['user_id']) - send_invitation_email(user_email, temp_password) - -# @app.route() -- cgit v1.2.3 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 From 8766b3104be9cdbe00f594c936442b76f3b9a83e Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 08:57:57 +0300 Subject: Update "create_group" endpoint in template --- wqflask/wqflask/templates/admin/group_manager.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html index 692a7abc..c5000869 100644 --- a/wqflask/wqflask/templates/admin/group_manager.html +++ b/wqflask/wqflask/templates/admin/group_manager.html @@ -12,7 +12,11 @@

    Manage Groups

    {% if admin_groups|length != 0 or member_groups|length != 0 %}
    - + + +
    {% endif %} @@ -23,7 +27,11 @@ {% if admin_groups|length == 0 and member_groups|length == 0 %}

    You currently aren't a member or admin of any groups.


    - + + + {% else %}

    Admin Groups


    @@ -119,11 +127,6 @@ return $("#groups_form").submit(); }; - $("#create_group").on("click", function() { - url = $(this).data("url") - return submit_special(url) - }); - $("#remove_groups").on("click", function() { url = $(this).data("url") groups = [] -- cgit v1.2.3 From a70b6421221db391a1774ae1133a0a244f00f248 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 09:12:31 +0300 Subject: Replace "var" with "let" --- wqflask/wqflask/static/new/javascript/group_manager.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/group_manager.js b/wqflask/wqflask/static/new/javascript/group_manager.js index 4c172cbf..cd56133a 100644 --- a/wqflask/wqflask/static/new/javascript/group_manager.js +++ b/wqflask/wqflask/static/new/javascript/group_manager.js @@ -16,23 +16,22 @@ $('#clear_members').click(function(){ function add_emails(user_type){ - var email_address = $('input[name=user_email]').val(); - var email_list_string = $('input[name=' + user_type + '_emails_to_add]').val().trim() - console.log(email_list_string) + let email_address = $('input[name=user_email]').val(); + let email_list_string = $('input[name=' + user_type + '_emails_to_add]').val().trim() if (email_list_string == ""){ - var email_set = new Set(); + let email_set = new Set(); } else { - var email_set = new Set(email_list_string.split(",")) + let email_set = new Set(email_list_string.split(",")) } email_set.add(email_address) $('input[name=' + user_type + '_emails_to_add]').val(Array.from(email_set).join(',')) - var emails_display_string = Array.from(email_set).join('\n') + let emails_display_string = Array.from(email_set).join('\n') $('.added_' + user_type + 's').val(emails_display_string) } function clear_emails(user_type){ $('input[name=' + user_type + '_emails_to_add]').val("") $('.added_' + user_type + 's').val("") -} \ No newline at end of file +} -- cgit v1.2.3 From f8bdd6cabd97a66bd3e3f8eeff910a0a9a79cf55 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 09:12:51 +0300 Subject: Remove empty JavaScript script-block --- wqflask/wqflask/templates/admin/create_group.html | 6 ------ 1 file changed, 6 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/create_group.html b/wqflask/wqflask/templates/admin/create_group.html index 21ef5653..7332ca77 100644 --- a/wqflask/wqflask/templates/admin/create_group.html +++ b/wqflask/wqflask/templates/admin/create_group.html @@ -73,17 +73,11 @@
    - - - {% endblock %} {% block js %} - - {% endblock %} -- cgit v1.2.3 From 42a0bd960095e96b536a51249f2355e82b59fd30 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 15:41:00 +0300 Subject: group_manager.py: Add methods for creating and deleting groups --- wqflask/wqflask/group_manager.py | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index 4edafc66..3434eab9 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -1,10 +1,16 @@ +import json import redis from flask import current_app from flask import Blueprint from flask import g from flask import render_template +from flask import request +from flask import redirect +from flask import url_for from gn3.authentication import get_groups_by_user_uid +from gn3.authentication import get_user_info_by_key +from gn3.authentication import create_group from wqflask.decorators import login_required group_management = Blueprint("group_management", __name__) @@ -29,3 +35,56 @@ def view_groups(): @login_required def view_create_group_page(): return render_template("admin/create_group.html") + + +@group_management.route("/groups/create", methods=("POST",)) +@login_required +def create_new_group(): + conn = redis.from_url(current_app.config["REDIS_URL"], + decode_responses=True) + if group_name := request.form.get("group_name"): + members_uid, admins_uid = set(), set() + admins_uid.add(user_uid := ( + g.user_session.record.get( + b"user_id", + b"").decode("utf-8") or + g.user_session.record.get("user_id", ""))) + if admin_string := request.form.get("admin_emails_to_add"): + for email in admin_string.split(","): + user_info = get_user_info_by_key(key="email_address", + value=email, + conn=conn) + if user_uid := user_info.get("user_id"): + admins_uid.add(user_uid) + if member_string := request.form.get("member_emails_to_add"): + for email in member_string.split(","): + user_info = get_user_info_by_key(key="email_address", + value=email, + conn=conn) + if user_uid := user_info.get("user_id"): + members_uid.add(user_uid) + + # Create the new group: + create_group(conn=conn, + group_name=group_name, + member_user_uids=list(members_uid), + admin_user_uids=list(admins_uid)) + return redirect(url_for('group_management.view_groups')) + return redirect(url_for('group_management.create_groups')) + + +@group_management.route("/groups/delete", methods=("POST",)) +@login_required +def delete_groups(): + conn = redis.from_url(current_app.config["REDIS_URL"], + decode_responses=True) + user_uid = (g.user_session.record.get(b"user_id", b"").decode("utf-8") or + g.user_session.record.get("user_id", "")) + current_app.logger.info(request.form.get("selected_group_ids")) + for group_uid in request.form.get("selected_group_ids", "").split(":"): + if group_info := conn.hget("groups", group_uid): + group_info = json.loads(group_info) + # A user who is an admin can delete things + if user_uid in group_info.get("admins"): + conn.hdel("groups", group_uid) + return redirect(url_for('group_management.view_groups')) -- cgit v1.2.3 From 5763744f5044710066b3c94efed0413061412689 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 15:41:25 +0300 Subject: Update URL for removing groups in template --- wqflask/wqflask/templates/admin/group_manager.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html index c5000869..c62cac20 100644 --- a/wqflask/wqflask/templates/admin/group_manager.html +++ b/wqflask/wqflask/templates/admin/group_manager.html @@ -17,7 +17,10 @@ Create Group - + {% endif %} -- cgit v1.2.3 From 965c25016c25256a1074131ac4c2c79b9ee97161 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Nov 2021 15:41:45 +0300 Subject: Update URL for creating a new group --- wqflask/wqflask/templates/admin/create_group.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/create_group.html b/wqflask/wqflask/templates/admin/create_group.html index 7332ca77..b1d214ea 100644 --- a/wqflask/wqflask/templates/admin/create_group.html +++ b/wqflask/wqflask/templates/admin/create_group.html @@ -6,7 +6,8 @@ -
    +
    -- cgit v1.2.3 From c11ac641592da44a823fdf41c0b81cd7bc7971f1 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:05:48 +0300 Subject: Update URL for viewing a particular group --- wqflask/wqflask/templates/admin/group_manager.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html index c62cac20..eedfe138 100644 --- a/wqflask/wqflask/templates/admin/group_manager.html +++ b/wqflask/wqflask/templates/admin/group_manager.html @@ -58,11 +58,12 @@ {{ loop.index }} - {{ group.name }} + {% set group_url = url_for('group_management.view_group', group_id=group.uuid) %} + {{ group.name }} {{ group.admins|length + group.members|length }} {{ group.created_timestamp }} {{ group.changed_timestamp }} - {{ group.id }} + {{ group.uuid }} {% endfor %} @@ -92,7 +93,8 @@ {{ loop.index }} - {{ group.name }} + {% set group_url = url_for('group_management.view_group', group_id=group.uuid) %} + {{ group.name }} {{ group.admins|length + group.members|length }} {{ group.created_timestamp }} {{ group.changed_timestamp }} -- cgit v1.2.3 From e0be9d3d6685b76a01c376655556295606ffea4e Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:06:50 +0300 Subject: Rename "view_groups" to "display_groups" --- wqflask/wqflask/group_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index 3434eab9..0e1fa56e 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -18,7 +18,7 @@ group_management = Blueprint("group_management", __name__) @group_management.route("/groups") @login_required -def view_groups(): +def display_groups(): groups = get_groups_by_user_uid( user_uid=(g.user_session.record.get(b"user_id", b"").decode("utf-8") or @@ -69,7 +69,7 @@ def create_new_group(): group_name=group_name, member_user_uids=list(members_uid), admin_user_uids=list(admins_uid)) - return redirect(url_for('group_management.view_groups')) + return redirect(url_for('group_management.display_groups')) return redirect(url_for('group_management.create_groups')) -- cgit v1.2.3 From e7fb408c3ab09b3aed5c862848f02d28d1a25f35 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:52:55 +0300 Subject: view_group.html: Remove redundant bool check --- wqflask/wqflask/templates/admin/view_group.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/view_group.html b/wqflask/wqflask/templates/admin/view_group.html index 26692fe8..b14fd14e 100644 --- a/wqflask/wqflask/templates/admin/view_group.html +++ b/wqflask/wqflask/templates/admin/view_group.html @@ -14,7 +14,7 @@ - {% if user_is_admin == true %} + {% if is_admin %}
    @@ -51,7 +51,7 @@ {% endfor %} - {% if user_is_admin == true %} + {% if is_admin %}
    E-mail of user to add to admins (multiple e-mails can be added separated by commas): @@ -88,7 +88,7 @@ {% endfor %} - {% if user_is_admin == true %} + {% if is_admin %}
    E-mail of user to add to members (multiple e-mails can be added separated by commas): @@ -99,7 +99,7 @@ {% endif %} {% else %} There are currently no members in this group. - {% if user_is_admin == true %} + {% if is_admin %}
    E-mail of user to add to members (multiple e-mails can be added separated by commas): -- cgit v1.2.3 From 61270336f52d93eb1312fe27760962f927fc97c8 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:53:10 +0300 Subject: view_group.html: Add html indentation --- wqflask/wqflask/templates/admin/view_group.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/view_group.html b/wqflask/wqflask/templates/admin/view_group.html index b14fd14e..abbdcf0e 100644 --- a/wqflask/wqflask/templates/admin/view_group.html +++ b/wqflask/wqflask/templates/admin/view_group.html @@ -1,9 +1,9 @@ {% extends "base.html" %} {% block title %}View and Edit Group{% endblock %} {% block css %} - - - + + + {% endblock %} {% block content %} -- cgit v1.2.3 From 1fe23d19c099305a7f3fe8afa1477964038e57a7 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:54:05 +0300 Subject: view_group.html: Use GROUP_URL for adding admins and users --- wqflask/wqflask/templates/admin/view_group.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/view_group.html b/wqflask/wqflask/templates/admin/view_group.html index abbdcf0e..a89ec54d 100644 --- a/wqflask/wqflask/templates/admin/view_group.html +++ b/wqflask/wqflask/templates/admin/view_group.html @@ -7,6 +7,7 @@ {% endblock %} {% block content %} +{% set GROUP_URL = url_for('group_management.view_group', group_id=guid) %}
    - +
    {% endif %}
    @@ -94,7 +95,7 @@
    - +
    {% endif %} {% else %} @@ -230,7 +231,7 @@ new_name = $('input[name=new_group_name]').val() $.ajax({ type: "POST", - url: "/groups/change_name", + url: "{{ GROUP_URL }} ", data: { group_id: $('input[name=group_id]').val(), new_name: new_name -- cgit v1.2.3 From c2ca2dc66ec1b6be726eafde187eee561f074ad4 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:54:53 +0300 Subject: view_group.html: Display the group's UID if the user is an admin --- wqflask/wqflask/templates/admin/view_group.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/view_group.html b/wqflask/wqflask/templates/admin/view_group.html index a89ec54d..a7d80388 100644 --- a/wqflask/wqflask/templates/admin/view_group.html +++ b/wqflask/wqflask/templates/admin/view_group.html @@ -38,6 +38,9 @@ Name Email Address Organization + {% if is_admin %} + UID + {% endif %} @@ -48,6 +51,9 @@ {% if 'full_name' in admin %}{{ admin.full_name }}{% elif 'name' in admin %}{{ admin.name }}{% else %}N/A{% endif %} {% if 'email_address' in admin %}{{ admin.email_address }}{% else %}N/A{% endif %} {% if 'organization' in admin %}{{ admin.organization }}{% else %}N/A{% endif %} + {% if is_admin %} + {{admin.user_id}} + {% endif %} {% endfor %} @@ -75,6 +81,9 @@ Name Email Address Organization + {% if is_admin %} + UID + {% endif %} @@ -85,6 +94,10 @@ {% if 'full_name' in member %}{{ member.full_name }}{% elif 'name' in admin %}{{ admin.name }}{% else %}N/A{% endif %} {% if 'email_address' in member %}{{ member.email_address }}{% else %}N/A{% endif %} {% if 'organization' in member %}{{ member.organization }}{% else %}N/A{% endif %} + {% if is_admin %} + {{ member }} + {% endif %} + {% endfor %} -- cgit v1.2.3 From b4ed3cb7beca79b89ee05117daae264487d442cb Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 9 Nov 2021 12:55:41 +0300 Subject: view_group.html: Prepend "Name" before the group name --- wqflask/wqflask/templates/admin/view_group.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/admin/view_group.html b/wqflask/wqflask/templates/admin/view_group.html index a7d80388..b4bac7d2 100644 --- a/wqflask/wqflask/templates/admin/view_group.html +++ b/wqflask/wqflask/templates/admin/view_group.html @@ -11,8 +11,8 @@
    diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index 7b103305..cfb1bed4 100755 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -193,10 +193,40 @@
    +
    -
    -
    diff --git a/wqflask/wqflask/templates/tutorials.html b/wqflask/wqflask/templates/tutorials.html index 8f3447e3..edec803c 100644 --- a/wqflask/wqflask/templates/tutorials.html +++ b/wqflask/wqflask/templates/tutorials.html @@ -56,9 +56,7 @@ -

    Webinar #01 - Introduction to Quantitative Trait Loci (QTL) Analysis

    -

    Friday, May 8th, 2020
    - 10am PDT/ 11am MDT/ 12pm CDT/ 1pm EDT

    +

    Introduction to Quantitative Trait Loci (QTL) Analysis

    Goals of this webinar (trait variance to QTL):