mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-07 19:05:39 +00:00
Adjustment to add multiple records which have same name and type. Add trailing dot in the record's content
This commit is contained in:
parent
fb51bce1f8
commit
b0e863863c
@ -814,7 +814,27 @@ class Record(object):
|
|||||||
# Adjustment to add multiple records which described in https://github.com/ngoduykhanh/PowerDNS-Admin/issues/5#issuecomment-181637576
|
# Adjustment to add multiple records which described in https://github.com/ngoduykhanh/PowerDNS-Admin/issues/5#issuecomment-181637576
|
||||||
final_records = []
|
final_records = []
|
||||||
if NEW_SCHEMA:
|
if NEW_SCHEMA:
|
||||||
final_records = records
|
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
||||||
|
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"])):
|
||||||
|
new_record = {
|
||||||
|
"name": key[0],
|
||||||
|
"type": key[1],
|
||||||
|
"ttl": records[0]['ttl'],
|
||||||
|
"changetype": "REPLACE",
|
||||||
|
"records": []
|
||||||
|
}
|
||||||
|
for item in group:
|
||||||
|
temp_content = item['records'][0]['content']
|
||||||
|
temp_disabled = item['records'][0]['disabled']
|
||||||
|
if key[1] in ['MX', 'CNAME', 'SRV', 'NS']:
|
||||||
|
if temp_content.strip()[-1:] != '.':
|
||||||
|
temp_content += '.'
|
||||||
|
|
||||||
|
new_record['records'].append({
|
||||||
|
"content": temp_content,
|
||||||
|
"disabled": temp_disabled
|
||||||
|
})
|
||||||
|
final_records.append(new_record)
|
||||||
else:
|
else:
|
||||||
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
||||||
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"])):
|
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"])):
|
||||||
|
@ -198,8 +198,9 @@ def domain(domain_name):
|
|||||||
records = []
|
records = []
|
||||||
for jr in jrecords:
|
for jr in jrecords:
|
||||||
if jr['type'] in app.config['RECORDS_ALLOW_EDIT']:
|
if jr['type'] in app.config['RECORDS_ALLOW_EDIT']:
|
||||||
record = Record(name=jr['name'], type=jr['type'], status='Disabled' if jr['disabled'] else 'Active', ttl=jr['ttl'], data=jr['content'])
|
for subrecord in jr['records']:
|
||||||
records.append(record)
|
record = Record(name=jr['name'], type=jr['type'], status='Disabled' if subrecord['disabled'] else 'Active', ttl=jr['ttl'], data=subrecord['content'])
|
||||||
|
records.append(record)
|
||||||
return render_template('domain.html', domain=domain, records=records, editable_records=app.config['RECORDS_ALLOW_EDIT'])
|
return render_template('domain.html', domain=domain, records=records, editable_records=app.config['RECORDS_ALLOW_EDIT'])
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('error', code=404))
|
return redirect(url_for('error', code=404))
|
||||||
@ -550,4 +551,3 @@ def index():
|
|||||||
return redirect(url_for('dashboard'))
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
# END VIEWS
|
# END VIEWS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user