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): ...@@ -452,10 +452,10 @@ def set_field(object, attr, errors, **kwargs):
@user_passes_test(req_staff) @user_passes_test(req_staff)
def save_rule(request): def save_rule(request):
data = json.loads(request.body) data = json.loads(request.body)
if data['id']: if 'id' in data:
rule = get_object_or_404(Rule, id=data['id']) rule = get_object_or_404(Rule, id=data['id'])
else: else:
rule = Rule.objects.create() rule = Rule()
errors = {} errors = {}
rule.direction = data['direction']['value'] rule.direction = data['direction']['value']
rule.description = data['description'] 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