From 0b16990d169718d2aab6139c36655e042fb0f234 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 27 Aug 2020 15:13:14 -0500 Subject: Added function for sending an invitation e-mail * wqflask/wqflask/user_login.py - Added send_invitation_email function, which does what it says --- wqflask/wqflask/user_login.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index cfee0079..9331f369 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -139,6 +139,12 @@ def send_verification_email(user_details, template_name = "email/user_verificati send_email(recipient, subject, body) return {"recipient": recipient, "subject": subject, "body": body} +def send_invitation_email(user_email, temp_password, template_name = "email/user_invitation.txt", subject = "You've been added to a GeneNetwork user group"): + recipient = user_email + body = render_template(template_name, temp_password) + send_email(recipient, subject, body) + return {"recipient": recipient, "subject": subject, "body": body} + @app.route("/manage/verify_email") def verify_email(): if 'code' in request.args: -- cgit v1.2.3 From dbc07d3f16b7c5337747af40a4d24c2ef27d2145 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 27 Aug 2020 15:15:05 -0500 Subject: Added logic that creates a user account if an e-mail is added to a group that isn't already associated with a GN2 account and sends the user an e-mail; still need to test * wqflask/wqflask/group_manager.py - Added logic sending an invitation e-mail if user_details aren't found for any of the e-mails provided when adding users to a group --- wqflask/wqflask/group_manager.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index 24848ed8..99d5db26 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -1,13 +1,15 @@ from __future__ import print_function, division, absolute_import +import random, 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 +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, create_group, delete_group, add_users_to_group, remove_users_from_group, \ +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 @@ -141,5 +143,16 @@ def send_group_invites(group_id, user_email_list = [], user_type="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() \ No newline at end of file -- cgit v1.2.3 From 58e621c4853a24fa2e87a06616286c64ef38dfa8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Sat, 29 Aug 2020 13:24:53 -0500 Subject: Fixed issue with exporting traits from multiple different groups from the collection page (the filename wasn't being set) * wqflask/wqflask/views.py - Set filename to "collection_(datetime)" in export_traits_csv because it wasn't being set before --- wqflask/wqflask/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index dde22bf7..a898de43 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -417,6 +417,9 @@ def export_traits_csv(): file_list = export_traits.export_search_results_csv(request.form) if len(file_list) > 1: + now = datetime.datetime.now() + time_str = now.strftime('%H:%M_%d%B%Y') + filename = "collection_{}".format(time_str) memory_file = StringIO.StringIO() with ZipFile(memory_file, mode='w', compression=ZIP_DEFLATED) as zf: for the_file in file_list: @@ -924,8 +927,6 @@ def browser_inputs(): return flask.jsonify(file_contents) - - ########################################################################## def json_default_handler(obj): -- cgit v1.2.3 From dba31ef2aa9e3f89621848fdb79b915dbd3c56e2 Mon Sep 17 00:00:00 2001 From: zsloan Date: Sat, 29 Aug 2020 13:47:52 -0500 Subject: Fixed issue where exporting traits would throw an error if a dataset's group didn't have an InbredSetCode set in the DB * wqflask/utility/authentication_tools.py - Changed get_group_code to return an empty string instead of None if InbredSetCode doesn't exist for a dataset group * wqflask/wqflask/views.py - Changed zipped export filename to "export_(datetime)" instead of "collection_(datetime)" since this export can occur from both the collection page and the global search page --- wqflask/utility/authentication_tools.py | 6 ++++-- wqflask/wqflask/views.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py index ece7022c..3553b92b 100644 --- a/wqflask/utility/authentication_tools.py +++ b/wqflask/utility/authentication_tools.py @@ -76,8 +76,10 @@ def add_new_resource(dataset, trait_id=None): def get_group_code(dataset): results = g.db.execute("SELECT InbredSetCode from InbredSet where Name='{}'".format(dataset.group.name)).fetchone() - - return results[0] + if results[0]: + return results[0] + else: + return "" def check_admin(resource_id=None): the_url = "http://localhost:8080/available?resource={}&user={}".format(resource_id, g.user_session.user_id) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index a898de43..91d1a279 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -419,7 +419,7 @@ def export_traits_csv(): if len(file_list) > 1: now = datetime.datetime.now() time_str = now.strftime('%H:%M_%d%B%Y') - filename = "collection_{}".format(time_str) + filename = "export_{}".format(time_str) memory_file = StringIO.StringIO() with ZipFile(memory_file, mode='w', compression=ZIP_DEFLATED) as zf: for the_file in file_list: -- cgit v1.2.3