Fix #613. Create domain from template with SOA record enabled

This commit is contained in:
Khanh Ngo 2019-12-19 21:43:53 +07:00
parent 59110432a0
commit 93cd64ac75
No known key found for this signature in database
GPG Key ID: A945965CD6351844
2 changed files with 24 additions and 8 deletions

View File

@ -249,7 +249,7 @@ class Record(object):
del_rrsets = {"rrsets": []}
for r in current_rrsets:
if r not in submitted_rrsets and r['type'] in Setting(
).get_records_allow_to_edit():
).get_records_allow_to_edit() and r['type'] != 'SOA':
r['changetype'] = 'DELETE'
del_rrsets["rrsets"].append(r)
@ -286,7 +286,11 @@ class Record(object):
current_app.logger.error(
'Cannot apply record changes with deleting rrsets step. PDNS error: {}'
.format(jdata1['error']))
return {'status': 'error', 'msg': jdata1['error']}
print(jdata1['error'])
return {
'status': 'error',
'msg': jdata1['error'].replace("'", "")
}
if new_rrsets["rrsets"]:
jdata2 = utils.fetch_json(
@ -301,7 +305,10 @@ class Record(object):
current_app.logger.error(
'Cannot apply record changes with adding rrsets step. PDNS error: {}'
.format(jdata2['error']))
return {'status': 'error', 'msg': jdata2['error']}
return {
'status': 'error',
'msg': jdata2['error'].replace("'", "")
}
self.auto_ptr(domain_name, new_rrsets, del_rrsets)
self.update_db_serial(domain_name)

View File

@ -199,16 +199,25 @@ def add():
result = r.apply(domain_name, record_data)
if result['status'] == 'ok':
history = History(
msg=
'Applying template {0} to {1}, created records successfully.'
.format(template.name, domain_name),
detail=str(result),
msg='Applying template {0} to {1} successfully.'.
format(template.name, domain_name),
detail=str(
json.dumps({
"domain":
domain_name,
"template":
template.name,
"add_rrests":
result['data'][0]['rrsets'],
"del_rrests":
result['data'][1]['rrsets']
})),
created_by=current_user.username)
history.add()
else:
history = History(
msg=
'Applying template {0} to {1}, FAILED to created records.'
'Failed to apply template {0} to {1}.'
.format(template.name, domain_name),
detail=str(result),
created_by=current_user.username)