From c456aa2e7afa4b4e3db3653cc5c70857bddeecdc Mon Sep 17 00:00:00 2001 From: Robert Kerr Date: Sat, 24 Nov 2018 12:45:14 +0000 Subject: [PATCH] Add ttl_options setting Adds a new setting to define the options in the TTL dropdown when editing a record. The setting is a comma separated string with the valid options. --- app/models.py | 9 +++++++-- app/static/custom/js/custom.js | 10 +++++++--- app/templates/domain.html | 1 + app/views.py | 8 +++++--- requirements.txt | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/models.py b/app/models.py index 7e87d08..dada209 100644 --- a/app/models.py +++ b/app/models.py @@ -12,6 +12,7 @@ import dns.reversename import dns.inet import dns.name import logging as logger +import pytimeparse from ast import literal_eval from datetime import datetime @@ -165,7 +166,7 @@ class User(db.Model): def ad_recursive_groups(self, groupDN): """ - Recursively list groups belonging to a group. It will allow checking deep in the Active Directory + Recursively list groups belonging to a group. It will allow checking deep in the Active Directory whether a user is allowed to enter or not """ LDAP_BASE_DN = Setting().get('ldap_base_dn') @@ -1424,7 +1425,7 @@ class Record(object): r_name = r['record_name'] r_data = domain if r_type == 'CNAME' and r['record_data'] in ['@', ''] else r['record_data'] - + record = { "name": r_name, "type": r_type, @@ -1889,6 +1890,7 @@ class Setting(db.Model): 'oidc_oauth_authorize_url': '', 'forward_records_allow_edit': {'A': True, 'AAAA': True, 'AFSDB': False, 'ALIAS': False, 'CAA': True, 'CERT': False, 'CDNSKEY': False, 'CDS': False, 'CNAME': True, 'DNSKEY': False, 'DNAME': False, 'DS': False, 'HINFO': False, 'KEY': False, 'LOC': True, 'MX': True, 'NAPTR': False, 'NS': True, 'NSEC': False, 'NSEC3': False, 'NSEC3PARAM': False, 'OPENPGPKEY': False, 'PTR': True, 'RP': False, 'RRSIG': False, 'SOA': False, 'SPF': True, 'SSHFP': False, 'SRV': True, 'TKEY': False, 'TSIG': False, 'TLSA': False, 'SMIMEA': False, 'TXT': True, 'URI': False}, 'reverse_records_allow_edit': {'A': False, 'AAAA': False, 'AFSDB': False, 'ALIAS': False, 'CAA': False, 'CERT': False, 'CDNSKEY': False, 'CDS': False, 'CNAME': False, 'DNSKEY': False, 'DNAME': False, 'DS': False, 'HINFO': False, 'KEY': False, 'LOC': True, 'MX': False, 'NAPTR': False, 'NS': True, 'NSEC': False, 'NSEC3': False, 'NSEC3PARAM': False, 'OPENPGPKEY': False, 'PTR': True, 'RP': False, 'RRSIG': False, 'SOA': False, 'SPF': False, 'SSHFP': False, 'SRV': False, 'TKEY': False, 'TSIG': False, 'TLSA': False, 'SMIMEA': False, 'TXT': True, 'URI': False}, + 'ttl_options': '1 minute,5 minutes,30 minutes,60 minutes,24 hours', } def __init__(self, id=None, name=None, value=None): @@ -1994,6 +1996,9 @@ class Setting(db.Model): r_name.sort() return r_name + def get_ttl_options(self): + return [ (pytimeparse.parse(ttl),ttl) for ttl in self.get('ttl_options').split(',') ] + class DomainTemplate(db.Model): __tablename__ = "domain_template" diff --git a/app/static/custom/js/custom.js b/app/static/custom/js/custom.js index 85e523d..759cdee 100644 --- a/app/static/custom/js/custom.js +++ b/app/static/custom/js/custom.js @@ -117,14 +117,18 @@ function editRow(oTable, nRow) { var aData = oTable.row(nRow).data(); var jqTds = oTable.cells(nRow,'').nodes(); var record_types = ""; + var ttl_opts = ""; for(var i = 0; i < records_allow_edit.length; i++) { var record_type = records_allow_edit[i]; record_types += ""; } + for(var i = 0; i < ttl_options.length; i++) { + ttl_opts += ""; + } jqTds[0].innerHTML = ''; - jqTds[1].innerHTML = ''; - jqTds[2].innerHTML = ''; - jqTds[3].innerHTML = ''; + jqTds[1].innerHTML = ''; + jqTds[2].innerHTML = ''; + jqTds[3].innerHTML = ''; jqTds[4].innerHTML = ''; jqTds[5].innerHTML = ''; jqTds[6].innerHTML = ''; diff --git a/app/templates/domain.html b/app/templates/domain.html index a9613a4..13139b1 100644 --- a/app/templates/domain.html +++ b/app/templates/domain.html @@ -106,6 +106,7 @@