From 46614c97c824b0a5e1d3dc492e8fabd52426cd81 Mon Sep 17 00:00:00 2001
From: Terrtia
Date: Wed, 7 Nov 2018 11:42:31 +0100
Subject: [PATCH] chg: [terms_management] delete email
---
.../modules/PasteSubmit/Flask_PasteSubmit.py | 18 +++++----
var/www/modules/terms/Flask_terms.py | 21 +++++++----
.../terms/templates/terms_management.html | 37 +++++++++++++++++--
3 files changed, 58 insertions(+), 18 deletions(-)
diff --git a/var/www/modules/PasteSubmit/Flask_PasteSubmit.py b/var/www/modules/PasteSubmit/Flask_PasteSubmit.py
index 79aea450..cc38de77 100644
--- a/var/www/modules/PasteSubmit/Flask_PasteSubmit.py
+++ b/var/www/modules/PasteSubmit/Flask_PasteSubmit.py
@@ -605,15 +605,19 @@ def disable_hive_auto_alert():
@PasteSubmit.route("/PasteSubmit/add_push_tag")
def add_push_tag():
tag = request.args.get('tag')
- #limit tag length
- if len(tag) > 49:
- tag = tag[0:48]
+ if tag is not None:
- r_serv_db.sadd('list_export_tags', tag)
+ #limit tag length
+ if len(tag) > 49:
+ tag = tag[0:48]
- to_return = {}
- to_return["tag"] = tag
- return jsonify(to_return)
+ r_serv_db.sadd('list_export_tags', tag)
+
+ to_return = {}
+ to_return["tag"] = tag
+ return jsonify(to_return)
+ else:
+ return 'None args', 400
@PasteSubmit.route("/PasteSubmit/delete_push_tag")
def delete_push_tag():
diff --git a/var/www/modules/terms/Flask_terms.py b/var/www/modules/terms/Flask_terms.py
index 1f0bbfb3..d1a067da 100644
--- a/var/www/modules/terms/Flask_terms.py
+++ b/var/www/modules/terms/Flask_terms.py
@@ -169,7 +169,7 @@ def terms_management():
trackReg_list_num_of_paste = []
for tracked_regex in r_serv_term.smembers(TrackedRegexSet_Name):
- notificationEMailTermMapping[tracked_regex] = "\n".join( (r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_regex)) )
+ notificationEMailTermMapping[tracked_regex] = r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_regex)
notificationTagsTermMapping[tracked_regex] = r_serv_term.smembers(TrackedTermsNotificationTagsPrefix_Name + tracked_regex)
if tracked_regex not in notificationEnabledDict:
@@ -196,7 +196,7 @@ def terms_management():
for tracked_set in r_serv_term.smembers(TrackedSetSet_Name):
tracked_set = tracked_set
- notificationEMailTermMapping[tracked_set] = "\n".join( (r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_set)) )
+ notificationEMailTermMapping[tracked_set] = r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_set)
notificationTagsTermMapping[tracked_set] = r_serv_term.smembers(TrackedTermsNotificationTagsPrefix_Name + tracked_set)
if tracked_set not in notificationEnabledDict:
@@ -222,7 +222,7 @@ def terms_management():
track_list_num_of_paste = []
for tracked_term in r_serv_term.smembers(TrackedTermsSet_Name):
- notificationEMailTermMapping[tracked_term] = "\n".join( r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_term))
+ notificationEMailTermMapping[tracked_term] = r_serv_term.smembers(TrackedTermsNotificationEmailsPrefix_Name + tracked_term)
notificationTagsTermMapping[tracked_term] = r_serv_term.smembers(TrackedTermsNotificationTagsPrefix_Name + tracked_term)
if tracked_term not in notificationEnabledDict:
@@ -334,11 +334,8 @@ def terms_management_action():
if section == "followTerm":
if action == "add":
- # Strip all whitespace
- notificationEmailsParam = "".join(notificationEmailsParam.split())
-
# Make a list of all passed email addresses
- notificationEmails = notificationEmailsParam.split(",")
+ notificationEmails = notificationEmailsParam.split()
validNotificationEmails = []
# check for valid email addresses
@@ -443,6 +440,16 @@ def terms_management_action():
to_return["term"] = term
return jsonify(to_return)
+@terms.route("/terms_management/delete_terms_email", methods=['GET'])
+def delete_terms_email():
+ term = request.args.get('term')
+ email = request.args.get('email')
+
+ if term is not None and email is not None:
+ r_serv_term.srem(TrackedTermsNotificationEmailsPrefix_Name + term, email)
+ return 'sucess'
+ else:
+ return 'None args', 400
@terms.route("/terms_plot_tool/")
diff --git a/var/www/modules/terms/templates/terms_management.html b/var/www/modules/terms/templates/terms_management.html
index fc92946a..6acc5735 100644
--- a/var/www/modules/terms/templates/terms_management.html
+++ b/var/www/modules/terms/templates/terms_management.html
@@ -36,6 +36,9 @@
white-space:pre-wrap;
word-wrap:break-word;
}
+ .mouse_pointer{
+ cursor: pointer;
+ }
@@ -98,7 +101,7 @@
-
+
@@ -140,7 +143,13 @@
- {{ notificationEMailTermMapping[set] }} |
+
+ {% for email in notificationEMailTermMapping[set] %}
+
+ {{ email }}
+
+ {% endfor %}
+ |
{% endfor %}
@@ -166,7 +175,13 @@
- {{ notificationEMailTermMapping[regex] }} |
+
+ {% for email in notificationEMailTermMapping[regex] %}
+
+ {{ email }}
+
+ {% endfor %}
+ |
{% endfor %}
@@ -192,7 +207,13 @@
- {{ notificationEMailTermMapping[term] }} |
+
+ {% for email in notificationEMailTermMapping[term] %}
+
+ {{ email }}
+
+ {% endfor %}
+ |
{% endfor %}
@@ -428,4 +449,12 @@ function perform_operation(){
});
}
}
+
+function delete_email(term, email){
+ $.get("{{ url_for('terms.delete_terms_email') }}", { term: term, email: email }, function(data, status){
+ if(status == "success") {
+ window.location.reload(false);
+ }
+ });
+}