mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Delete blank comments. Fix for ngoduykhanh/PowerDNS-Admin#919 (#920)
This commit is contained in:
parent
f3a98eb692
commit
32983635c6
@ -311,13 +311,26 @@ class Record(object):
|
|||||||
new_rrsets, del_rrsets = self.compare(domain_name, submitted_records)
|
new_rrsets, del_rrsets = self.compare(domain_name, submitted_records)
|
||||||
|
|
||||||
# Remove blank comments from rrsets for compatibility with some backends
|
# Remove blank comments from rrsets for compatibility with some backends
|
||||||
|
def remove_blank_comments(rrset):
|
||||||
|
if not rrset['comments']:
|
||||||
|
del rrset['comments']
|
||||||
|
elif isinstance(rrset['comments'], list):
|
||||||
|
# Merge all non-blank comment values into a list
|
||||||
|
merged_comments = [
|
||||||
|
v
|
||||||
|
for c in rrset['comments']
|
||||||
|
for v in c.values()
|
||||||
|
if v
|
||||||
|
]
|
||||||
|
# Delete comment if all values are blank (len(merged_comments) == 0)
|
||||||
|
if not merged_comments:
|
||||||
|
del rrset['comments']
|
||||||
|
|
||||||
for r in new_rrsets['rrsets']:
|
for r in new_rrsets['rrsets']:
|
||||||
if not r['comments']:
|
remove_blank_comments(r)
|
||||||
del r['comments']
|
|
||||||
|
|
||||||
for r in del_rrsets['rrsets']:
|
for r in del_rrsets['rrsets']:
|
||||||
if not r['comments']:
|
remove_blank_comments(r)
|
||||||
del r['comments']
|
|
||||||
|
|
||||||
# Submit the changes to PDNS API
|
# Submit the changes to PDNS API
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user