Implement deleeting relays and fix adding
This commit is contained in:
parent
d51e87b09f
commit
54b5561a75
17
api/views.py
17
api/views.py
|
@ -305,10 +305,25 @@ class API(object):
|
||||||
net_inst = main.network[net]
|
net_inst = main.network[net]
|
||||||
if num in net_inst.relays:
|
if num in net_inst.relays:
|
||||||
return dumps({"success": False, "reason": "network already has this relay."})
|
return dumps({"success": False, "reason": "network already has this relay."})
|
||||||
id, alias = net_inst.add_relay()
|
id, alias = net_inst.add_relay(num)
|
||||||
main.saveConf("network")
|
main.saveConf("network")
|
||||||
return dumps({"success": True, "id": id, "alias": alias})
|
return dumps({"success": True, "id": id, "alias": alias})
|
||||||
|
|
||||||
|
@app.route("/irc/network/<net>/<num>/", methods=["DELETE"])
|
||||||
|
@login_required
|
||||||
|
def irc_network_relay_del(self, request, net, num):
|
||||||
|
if net not in main.network.keys():
|
||||||
|
return dumps({"success": False, "reason": "no such net."})
|
||||||
|
if not num.isdigit():
|
||||||
|
return dumps({"success": False, "reason": "invalid num: not a number."})
|
||||||
|
num = int(num)
|
||||||
|
net_inst = main.network[net]
|
||||||
|
if num not in net_inst.relays:
|
||||||
|
return dumps({"success": False, "reason": "network does not have this relay."})
|
||||||
|
net_inst.delete_relay(num)
|
||||||
|
main.saveConf("network")
|
||||||
|
return dumps({"success": True})
|
||||||
|
|
||||||
@app.route("/irc/network/<net>/channels/", methods=["POST"])
|
@app.route("/irc/network/<net>/channels/", methods=["POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def irc_network_channels(self, request, net):
|
def irc_network_channels(self, request, net):
|
||||||
|
|
Loading…
Reference in New Issue