Commit 3ed3adb8 by Bence Dányi

firewall_gui: fix saving issues

parent 0393bf07
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<td>{{rule.description}}</td> <td>{{rule.description}}</td>
<td> <td>
<a class="btn" href="#/rules/{{rule.id}}/">Szerkesztés</a> <a class="btn" href="#/rules/{{rule.id}}/">Szerkesztés</a>
<a class="btn btn-danger" href="#/rules/{{rule.id}}/delete/">Törlés</a> <button class="btn btn-danger" ng-click="deleteEntity(rule.id)">Törlés</button>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -481,7 +481,7 @@ def set_field(object, attr, errors, **kwargs): ...@@ -481,7 +481,7 @@ 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 'id' in data: if 'id' in data and data['id']:
rule = get_object_or_404(Rule, id=data['id']) rule = get_object_or_404(Rule, id=data['id'])
else: else:
rule = Rule() rule = Rule()
...@@ -495,6 +495,7 @@ def save_rule(request): ...@@ -495,6 +495,7 @@ def save_rule(request):
rule.accept = data['accept'] rule.accept = data['accept']
rule.nat = data['nat'] rule.nat = data['nat']
rule.nat_dport = data['nat_dport'] rule.nat_dport = data['nat_dport']
rule.r_type = data['target']['type']
set_field(rule, 'owner', errors, username=data['owner']['name']) set_field(rule, 'owner', errors, username=data['owner']['name'])
for attr in ['host', 'hostgroup', 'vlan', 'vlangroup', 'firewall']: for attr in ['host', 'hostgroup', 'vlan', 'vlangroup', 'firewall']:
searchBy = 'name' if attr != 'host' else 'hostname' searchBy = 'name' if attr != 'host' else 'hostname'
...@@ -510,7 +511,7 @@ def save_rule(request): ...@@ -510,7 +511,7 @@ def save_rule(request):
if len(errors) > 0: if len(errors) > 0:
return HttpResponse(json.dumps(errors), content_type='application/json', status=400) return HttpResponse(json.dumps(errors), content_type='application/json', status=400)
rule.save() rule.save()
return HttpResponse('KTHXBYE') return HttpResponse(rule.id)
@user_passes_test(req_staff) @user_passes_test(req_staff)
def save_host(request): def save_host(request):
......
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