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