Commit 14348bfb by Bence Dányi

firewall_gui: create new domain

parent 73000026
...@@ -524,20 +524,33 @@ def show_record(request, id=None): ...@@ -524,20 +524,33 @@ def show_record(request, id=None):
} }
return HttpResponse(json.dumps(record), content_type='application/json') return HttpResponse(json.dumps(record), content_type='application/json')
def show_domain(request, id): def show_domain(request, id=None):
domain = get_object_or_404(Domain, id=id) try:
domain = { domain = Domain.objects.get(id=id)
'id': domain.id, domain = {
'name': domain.name, 'id': domain.id,
'owner': { 'name': domain.name,
'id': domain.owner.id, 'owner': {
'name': domain.owner.username, 'id': domain.owner.id,
}, 'name': domain.owner.username,
'created_at': domain.created_at.isoformat(), },
'modified_at': domain.modified_at.isoformat(), 'created_at': domain.created_at.isoformat(),
'ttl': domain.ttl, 'modified_at': domain.modified_at.isoformat(),
'description': domain.description 'ttl': domain.ttl,
} 'description': domain.description
}
except:
domain = {
'id': None,
'name': None,
'owner': {
'name': None,
},
'created_at': None,
'modified_at': None,
'ttl': None,
'description': ''
}
return HttpResponse(json.dumps(domain), content_type='application/json') return HttpResponse(json.dumps(domain), content_type='application/json')
def make_autocomplete(entity, name='name'): def make_autocomplete(entity, name='name'):
......
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