From 3911935e3be4faa2b6e602303fdb408e0035d049 Mon Sep 17 00:00:00 2001 From: "SIPOS, Peter" Date: Mon, 21 Nov 2016 13:44:47 +0100 Subject: [PATCH] Add an extra check into reverse domain creation and also import strtobool --- app/models.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models.py b/app/models.py index bfa57c4..f81a529 100644 --- a/app/models.py +++ b/app/models.py @@ -11,6 +11,7 @@ import re import dns.reversename from datetime import datetime +from distutils.util import strtobool from distutils.version import StrictVersion from flask_login import AnonymousUserMixin @@ -609,10 +610,18 @@ class Domain(db.Model): Check the existing reverse lookup domain, if not exists create a new one automatically """ + domain_obj = Domain.query.filter(Domain.name == domain).first() + domain_auto_ptr = DomainSetting.query.filter(DomainSetting.domain == domain_obj).filter(DomainSetting.setting == 'auto_ptr').first() + domain_auto_ptr = strtobool(domain_auto_ptr.value) if domain_auto_ptr else False + system_auto_ptr = Setting.query.filter(Setting.name == 'auto_ptr').first() + system_auto_ptr = strtobool(system_auto_ptr.value) self.name = domain_name domain_id = self.get_id_by_name(domain_reverse_name) - if None == domain_id and app.config['AUTOMATIC_REVERSE_PTR']: - result = self.add(domain_reverse_name, 'Master', 'INCEPTION_INCREMENT', '', '') + if None == domain_id and \ + ( + system_auto_ptr or \ + domain_auto_ptr + ): result = self.add(domain_reverse_name, 'Master', 'INCEPTION-INCREMENT', '', '') self.update() if result['status'] == 'ok':