diff --git a/app/models.py b/app/models.py index ff7d3eb..2c18969 100644 --- a/app/models.py +++ b/app/models.py @@ -458,18 +458,29 @@ class Domain(db.Model): logging.error('Can not update domain table.' + str(e)) return {'status': 'error', 'msg': 'Can not update domain table'} - def add(self, domain_name, domain_type, domain_ns=[], domain_master_ips=[]): + def add(self, domain_name, domain_type, soa_edit_api, domain_ns=[], domain_master_ips=[]): """ Add a domain to power dns """ headers = {} headers['X-API-Key'] = PDNS_API_KEY - post_data = { - "name": domain_name, - "kind": domain_type, - "masters": domain_master_ips, - "nameservers": domain_ns - } + + if soa_edit_api == 'OFF': + post_data = { + "name": domain_name, + "kind": domain_type, + "masters": domain_master_ips, + "nameservers": domain_ns, + } + else: + post_data = { + "name": domain_name, + "kind": domain_type, + "masters": domain_master_ips, + "nameservers": domain_ns, + "soa_edit_api": soa_edit_api + } + try: jdata = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, '/servers/localhost/zones'), headers=headers, method='POST', data=post_data) if 'error' in jdata.keys(): diff --git a/app/templates/domain_add.html b/app/templates/domain_add.html index 90290c4..d7e3644 100644 --- a/app/templates/domain_add.html +++ b/app/templates/domain_add.html @@ -68,7 +68,7 @@
- +
@@ -102,6 +102,73 @@
+
+ +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
diff --git a/app/views.py b/app/views.py index a0462df..c90db22 100644 --- a/app/views.py +++ b/app/views.py @@ -159,6 +159,7 @@ def domain_add(): try: domain_name = request.form.getlist('domain_name')[0] domain_type = request.form.getlist('radio_type')[0] + soa_edit_api = request.form.getlist('radio_type_soa_edit_api')[0] if ' ' in domain_name or not domain_name or not domain_type: return render_template('400.html', msg="Please correct your input"), 400 @@ -171,7 +172,7 @@ def domain_add(): else: domain_master_ips = [] d = Domain() - result = d.add(domain_name=domain_name, domain_type=domain_type, domain_master_ips=domain_master_ips) + result = d.add(domain_name=domain_name, domain_type=domain_type, soa_edit_api=soa_edit_api, domain_master_ips=domain_master_ips) if result['status'] == 'ok': history = History(msg='Add domain %s' % domain_name, detail=str({'domain_type': domain_type, 'domain_master_ips': domain_master_ips}), created_by=current_user.username) history.add() @@ -231,6 +232,7 @@ def domain_management(domain_name): return redirect(url_for('domain_management', domain_name=domain_name)) + @app.route('/domain//apply', methods=['POST'], strict_slashes=False) @login_required def record_apply(domain_name): @@ -291,7 +293,6 @@ def record_update(domain_name): return make_response(jsonify( {'status': 'error', 'msg': 'Error when applying new changes'} ), 500) - @app.route('/domain//record//type//delete', methods=['GET']) @login_required @admin_role_required @@ -444,7 +445,6 @@ def user_avatar(filename): @login_required def index(): return redirect(url_for('dashboard')) - #return make_response(jsonify( { 'status': 'ok', 'msg': 'This is a test page' } ), 200) # END VIEWS