Implement updating network registration
This commit is contained in:
@@ -59,7 +59,6 @@ class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
||||
def get(self, request, net):
|
||||
network = threshold.get_irc_network(net)
|
||||
context = {"network": network}
|
||||
print("CON", context)
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
@@ -72,7 +71,7 @@ class ThresholdIRCNetworkInfoEdit(SuperUserRequiredMixin, APIView):
|
||||
Return the form to edit a network.
|
||||
"""
|
||||
network = threshold.get_irc_network(net)
|
||||
editable = ["auth", "host", "last", "port", "security"]
|
||||
editable = ["auth", "host", "last", "port", "security", "chanlimit"]
|
||||
context = {
|
||||
"net": net,
|
||||
"network": {k: v for k, v in network.items() if k in editable},
|
||||
@@ -287,6 +286,61 @@ class ThresholdIRCActionsAddNetwork(SuperUserRequiredMixin, APIView):
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||
template_name = "manage/threshold/irc/network/modals/registration.html"
|
||||
parser_classes = [FormParser]
|
||||
|
||||
def get(self, request, net=None):
|
||||
"""
|
||||
Get registration modal
|
||||
"""
|
||||
unreg = threshold.irc_get_unreg(net)
|
||||
message = None
|
||||
message_class = None
|
||||
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 = {
|
||||
"net": net,
|
||||
"message": message,
|
||||
"class": message_class,
|
||||
}
|
||||
if not message_class == "danger":
|
||||
context["unreg"] = unreg["unreg"]
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
def put(self, request, net=None):
|
||||
"""
|
||||
Confirm registration for networks.
|
||||
"""
|
||||
if request.resolver_match.url_name == "threshold_irc_actions_registration_net":
|
||||
template_name = "manage/threshold/irc/network/actions.html"
|
||||
else:
|
||||
template_name = "manage/threshold/irc/overview/actions.html"
|
||||
updated = threshold.irc_confirm_accounts(request.data)
|
||||
|
||||
message = "Registration confirmed successfully."
|
||||
message_class = "success"
|
||||
|
||||
if not updated["success"]:
|
||||
message = updated["reason"]
|
||||
message_class = "danger"
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
"message": message,
|
||||
"class": message_class,
|
||||
}
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class ThresholdIRCAliasesEdit(SuperUserRequiredMixin, APIView):
|
||||
template_name = "manage/threshold/irc/overview/modals/edit-aliases.html"
|
||||
parser_classes = [FormParser]
|
||||
@@ -483,7 +537,6 @@ class ThresholdIRCSendMessage(SuperUserRequiredMixin, APIView):
|
||||
self.template_name,
|
||||
{"message": message, "class": message_class},
|
||||
)
|
||||
print("IRC", nick)
|
||||
if nick:
|
||||
messaged = threshold.send_irc_message(
|
||||
net, num, channel, request.data["msg"], nick=nick
|
||||
@@ -501,7 +554,6 @@ class ThresholdIRCSendMessage(SuperUserRequiredMixin, APIView):
|
||||
else:
|
||||
message = messaged["reason"]
|
||||
message_class = "danger"
|
||||
print("ERROR", message)
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
|
||||
Reference in New Issue
Block a user