Fix passing registration status to modal
This commit is contained in:
parent
bfd9c03c82
commit
dbb12bc8ff
|
@ -52,7 +52,7 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% if unreg %}
|
{% if unreg is not None %}
|
||||||
<form
|
<form
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
hx-put="{% url 'threshold_irc_actions_registration_net' net %}"
|
hx-put="{% url 'threshold_irc_actions_registration_net' net %}"
|
||||||
|
@ -60,14 +60,18 @@
|
||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
{% for network, items in unreg.items %}
|
{% for network, items in unreg.items %}
|
||||||
<h4 class="title is-4">{{ network }}</h4>
|
<h4 class="title is-4">{{ network }}</h4>
|
||||||
{% for nick, num in items %}
|
{% if items is not False %}
|
||||||
<div class="field">
|
{% for nick, num in items %}
|
||||||
<label class="label">{{ nick }}/{{ num }}</label>
|
<div class="field">
|
||||||
<div class="control">
|
<label class="label">{{ nick }}/{{ num }}</label>
|
||||||
<input class="input" type="text" name="{{ network }}|{{ num }}" placeholder="Enter token">
|
<div class="control">
|
||||||
|
<input class="input" type="text" name="{{ network }}|{{ num }}" placeholder="Enter token">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endfor %}
|
||||||
{% endfor %}
|
{% else %}
|
||||||
|
<p>Error getting information for {{ network }}.</p>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
|
@ -418,7 +418,7 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||||
"message": message,
|
"message": message,
|
||||||
"class": message_class,
|
"class": message_class,
|
||||||
}
|
}
|
||||||
if not message_class == "danger":
|
if "unreg" in unreg:
|
||||||
context["unreg"] = unreg["unreg"]
|
context["unreg"] = unreg["unreg"]
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
@ -426,6 +426,8 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||||
"""
|
"""
|
||||||
Confirm registration for networks.
|
Confirm registration for networks.
|
||||||
"""
|
"""
|
||||||
|
message = None
|
||||||
|
message_class = None
|
||||||
if request.resolver_match.url_name == "threshold_irc_actions_registration_net":
|
if request.resolver_match.url_name == "threshold_irc_actions_registration_net":
|
||||||
template_name = "manage/threshold/irc/network/actions.html"
|
template_name = "manage/threshold/irc/network/actions.html"
|
||||||
else:
|
else:
|
||||||
|
@ -439,14 +441,23 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||||
message = updated["reason"]
|
message = updated["reason"]
|
||||||
message_class = "danger"
|
message_class = "danger"
|
||||||
unreg = threshold.irc_get_unreg(net)
|
unreg = threshold.irc_get_unreg(net)
|
||||||
|
if not unreg:
|
||||||
|
message = "Could not get registration status."
|
||||||
|
message_class = "danger"
|
||||||
|
elif not unreg["success"]:
|
||||||
|
if "reason" in unreg:
|
||||||
|
message = unreg["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
else:
|
||||||
|
message = "Getting registration status failed."
|
||||||
|
message_class = "danger"
|
||||||
context = {
|
context = {
|
||||||
"unreg": unreg,
|
"net": net,
|
||||||
"message": message,
|
"message": message,
|
||||||
"class": message_class,
|
"class": message_class,
|
||||||
}
|
}
|
||||||
if net:
|
if "unreg" in unreg:
|
||||||
if net != "None":
|
context["unreg"] = unreg["unreg"]
|
||||||
context["net"] = net
|
|
||||||
return render(request, template_name, context)
|
return render(request, template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
@ -467,18 +478,30 @@ class ThresholdIRCActionsRegistrationAuth(SuperUserRequiredMixin, APIView):
|
||||||
message = updated["reason"]
|
message = updated["reason"]
|
||||||
message_class = "danger"
|
message_class = "danger"
|
||||||
if "net" in request.data:
|
if "net" in request.data:
|
||||||
net = request.data["net"]
|
if request.data["net"] != "None":
|
||||||
|
net = request.data["net"]
|
||||||
|
else:
|
||||||
|
net = None
|
||||||
else:
|
else:
|
||||||
net = None
|
net = None
|
||||||
unreg = threshold.irc_get_unreg(net)
|
unreg = threshold.irc_get_unreg(net)
|
||||||
|
if not unreg:
|
||||||
|
message = "Could not get registration status."
|
||||||
|
message_class = "danger"
|
||||||
|
elif not unreg["success"]:
|
||||||
|
if "reason" in unreg:
|
||||||
|
message = unreg["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
else:
|
||||||
|
message = "Getting registration status failed."
|
||||||
|
message_class = "danger"
|
||||||
context = {
|
context = {
|
||||||
"unreg": unreg,
|
"net": net,
|
||||||
"message": message,
|
"message": message,
|
||||||
"class": message_class,
|
"class": message_class,
|
||||||
}
|
}
|
||||||
if "net" in request.data:
|
if "unreg" in unreg:
|
||||||
if request.data["net"] != "None":
|
context["unreg"] = unreg["unreg"]
|
||||||
context["net"] = request.data["net"]
|
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue