Commit 95b82bbb by Bence Dányi

firewall_gui: fix keyerror when id not available

parent 5930bc7f
......@@ -452,10 +452,10 @@ def set_field(object, attr, errors, **kwargs):
@user_passes_test(req_staff)
def save_rule(request):
data = json.loads(request.body)
if data['id']:
if 'id' in data:
rule = get_object_or_404(Rule, id=data['id'])
else:
rule = Rule.objects.create()
rule = Rule()
errors = {}
rule.direction = data['direction']['value']
rule.description = data['description']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment