strip domain part from names while cloning a zone to a template

This commit is contained in:
Kees Monshouwer 2018-04-11 18:09:38 +02:00 committed by mind04
parent 84d4bfaed0
commit fc737cf61f
No known key found for this signature in database
GPG Key ID: 2698B1807E43953E

View File

@ -916,17 +916,18 @@ def create_template_from_zone():
if NEW_SCHEMA: if NEW_SCHEMA:
for jr in jrecords: for jr in jrecords:
name = '@' if jr['name'] == domain_name else jr['name']
if jr['type'] in app.config['RECORDS_ALLOW_EDIT']: if jr['type'] in app.config['RECORDS_ALLOW_EDIT']:
name = '@' if jr['name'] == domain_name else jr['name'].replace('.'+domain_name, '')
for subrecord in jr['records']: for subrecord in jr['records']:
record = DomainTemplateRecord(name=name, type=jr['type'], status=True if subrecord['disabled'] else False, ttl=jr['ttl'], data=subrecord['content']) record = DomainTemplateRecord(name=name, type=jr['type'], status=True if subrecord['disabled'] else False, ttl=jr['ttl'], data=subrecord['content'])
records.append(record) records.append(record)
else: else:
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']:
name = '@' if jr['name'] == domain_name else jr['name'].replace('.'+domain_name, '')
record = DomainTemplateRecord(name=name, type=jr['type'], status=True if jr['disabled'] else False, ttl=jr['ttl'], data=jr['content']) record = DomainTemplateRecord(name=name, type=jr['type'], status=True if jr['disabled'] else False, ttl=jr['ttl'], data=jr['content'])
records.append(record) records.append(record)
result_records = t.replace_records(records) result_records = t.replace_records(records)
if result_records['status'] == 'ok': if result_records['status'] == 'ok':