aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/utility/authentication_tools.py6
-rw-r--r--wqflask/wqflask/group_manager.py17
-rw-r--r--wqflask/wqflask/user_login.py6
-rw-r--r--wqflask/wqflask/views.py5
4 files changed, 28 insertions, 6 deletions
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/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
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:
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index dde22bf7..91d1a279 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 = "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:
@@ -924,8 +927,6 @@ def browser_inputs():
return flask.jsonify(file_contents)
-
-
##########################################################################
def json_default_handler(obj):