diff --git a/app/urls.py b/app/urls.py index f1f861c..3b303c9 100644 --- a/app/urls.py +++ b/app/urls.py @@ -25,6 +25,7 @@ from core.views import Billing, Cancel, Home, Order, Portal, Signup from core.views.callbacks import Callback from core.views.manage.threshold.irc import ( ThresholdIRCAliases, + ThresholdIRCAliasesEdit, ThresholdIRCNetworkActions, ThresholdIRCNetworkActionsRelay, ThresholdIRCNetworkChannels, @@ -35,7 +36,6 @@ from core.views.manage.threshold.irc import ( ThresholdIRCNetworkRelayStatus, ThresholdIRCNetworks, ThresholdIRCStats, - ThresholdIRCAliasesEdit, ) # Management stuff diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 0e987ab..f4d2efa 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -104,3 +104,10 @@ def del_relay(net, num): payload = {} deleted = threshold_request(url, payload, method="DELETE") return deleted + + +def update_aliases(aliases): + url = "aliases" + payload = aliases + deleted = threshold_request(url, payload, method="POST") + return deleted diff --git a/core/lib/threshold.py b/core/lib/threshold.py index 0a6fe17..a885ddb 100644 --- a/core/lib/threshold.py +++ b/core/lib/threshold.py @@ -51,13 +51,14 @@ def sort_data(data): data[item] = OrderedDict({k: v for k, v in sorted_item}) -def threshold_request(url, data, method="POST"): +def threshold_request(url, data, method="POST", esc=False): headers = { "ApiKey": settings.THRESHOLD_API_KEY, "Token": settings.THRESHOLD_API_TOKEN, } - for key in data: - data[key] = escape(data[key]) + if esc: + for key in data: + data[key] = escape(data[key]) if method == "POST": method = requests.post @@ -96,7 +97,7 @@ def threshold_request(url, data, method="POST"): def get_chans(net, query): url = "chans" payload = {"net": net, "query": query} - channels = threshold_request(url, payload) + channels = threshold_request(url, payload, esc=True) if not channels: return [] return channels["chans"] @@ -105,7 +106,7 @@ def get_chans(net, query): def get_users(net, query): url = "users" payload = {"net": net, "query": query} - users = threshold_request(url, payload) + users = threshold_request(url, payload, esc=True) if not users: return [] return users["users"] @@ -114,7 +115,7 @@ def get_users(net, query): def annotate_online(net, query): url = "online" payload = {"net": net, "query": query} - online_info = threshold_request(url, payload) + online_info = threshold_request(url, payload, esc=True) if not online_info: return {} return online_info @@ -123,7 +124,7 @@ def annotate_online(net, query): def annotate_num_users(net, query): url = "num_users" payload = {"net": net, "query": query} - user_num_map = threshold_request(url, payload) + user_num_map = threshold_request(url, payload, esc=True) if not user_num_map: return {} return user_num_map @@ -132,7 +133,7 @@ def annotate_num_users(net, query): def annotate_num_chans(net, query): url = "num_chans" payload = {"net": net, "query": query} - chan_num_map = threshold_request(url, payload) + chan_num_map = threshold_request(url, payload, esc=True) if not chan_num_map: return {} return chan_num_map diff --git a/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html b/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html index 8d94cff..a86dbd4 100644 --- a/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html +++ b/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html @@ -1,6 +1,6 @@ {% load index %} {% load static %} -{% load joinsep %} +{% load nsep %}