diff options
-rw-r--r-- | wqflask/utility/authentication_tools.py | 7 | ||||
-rw-r--r-- | wqflask/wqflask/group_manager.py | 17 | ||||
-rw-r--r-- | wqflask/wqflask/user_login.py | 6 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 5 |
4 files changed, 29 insertions, 6 deletions
diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py index 73c39399..68bbb276 100644 --- a/wqflask/utility/authentication_tools.py +++ b/wqflask/utility/authentication_tools.py @@ -77,7 +77,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) @@ -85,7 +88,7 @@ def check_admin(resource_id=None): response = json.loads(requests.get(the_url).content)['admin'] except: resource_info = get_resource_info(resource_id) - response = resource_info['default_mask']['admin'] +l response = resource_info['default_mask']['admin'] if 'edit-admins' in response: return "edit-admins" diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index e6079c3e..69ee9623 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -1,10 +1,12 @@ +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 @@ -138,5 +140,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() diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 10cb7319..28d58712 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -137,6 +137,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: diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 557ff523..0c8c23f3 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -413,6 +413,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 = "export_{}".format(time_str) memory_file = io.StringIO() with ZipFile(memory_file, mode='w', compression=ZIP_DEFLATED) as zf: for the_file in file_list: @@ -920,8 +923,6 @@ def browser_inputs(): return flask.jsonify(file_contents) - - ########################################################################## def json_default_handler(obj): |