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,6 +60,7 @@
|
||||||
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>
|
||||||
|
{% if items is not False %}
|
||||||
{% for nick, num in items %}
|
{% for nick, num in items %}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">{{ nick }}/{{ num }}</label>
|
<label class="label">{{ nick }}/{{ num }}</label>
|
||||||
|
@ -68,6 +69,9 @@
|
||||||
</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:
|
||||||
|
if request.data["net"] != "None":
|
||||||
net = request.data["net"]
|
net = request.data["net"]
|
||||||
else:
|
else:
|
||||||
net = None
|
net = None
|
||||||
|
else:
|
||||||
|
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