diff --git a/app/__init__.py b/app/__init__.py index 1f5687d..326654c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -39,7 +39,7 @@ def enable_github_oauth(GITHUB_ENABLE): consumer_key=app.config['GITHUB_OAUTH_KEY'], consumer_secret=app.config['GITHUB_OAUTH_SECRET'], request_token_params={'scope': app.config['GITHUB_OAUTH_SCOPE']}, - base_url=app.config['GITHUB_OAUTH_URL'], + base_url=app.config['GITHUB_OAUTH_URL'], # API URL request_token_url=None, access_token_method='POST', access_token_url=app.config['GITHUB_OAUTH_TOKEN'], diff --git a/app/models.py b/app/models.py index 974518e..e939343 100644 --- a/app/models.py +++ b/app/models.py @@ -1774,18 +1774,47 @@ class Setting(db.Model): id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(64)) value = db.Column(db.String(256)) + view = db.Column(db.String(64)) - # default settings (serves as list of known settings too): - # Note: booleans must be strings because of the way they are stored and used defaults = { - 'maintenance': 'False', - 'fullscreen_layout': 'True', - 'record_helper': 'True', - 'login_ldap_first': 'True', + 'maintenance': False, + 'fullscreen_layout': True, + 'record_helper': True, + 'login_ldap_first': True, 'default_record_table_size': 15, 'default_domain_table_size': 10, - 'auto_ptr': 'False', - 'allow_quick_edit': 'True' + 'auto_ptr': False, + 'allow_quick_edit': True, + 'pdns_api_url': '', + 'pdns_api_key': '', + 'pdns_version': '4.1.1', + 'local_db_enabled': True, + 'signup_enabled': True, + 'ldap_enabled': False, + 'ldap_type': 'ldap', + 'ldap_uri': '', + 'ldap_admin_username': '', + 'ldap_admin_password': '', + 'ldap_filter_basic': '', + 'ldap_filter_username': '', + 'ldap_sg_enabled': False, + 'ldap_admin_group': False, + 'ldap_user_group': False, + 'github_oauth_enabled': False, + 'github_oauth_key': '', + 'github_oauth_secret': '', + 'github_oauth_scope': 'email', + 'github_oauth_api_url': 'https://api.github.com/user', + 'github_oauth_token_url': 'https://github.com/login/oauth/access_token', + 'github_oauth_authorize_url': 'https://github.com/login/oauth/authorize', + 'google_oauth_enabled': False, + 'google_oauth_client_id':'', + 'google_oauth_client_secret':'', + 'google_redirect_uri': '/user/authorized', + 'google_token_url': 'https://accounts.google.com/o/oauth2/token', + 'google_token_params': {'scope': 'email profile'}, + 'google_authorize_url':'https://accounts.google.com/o/oauth2/auth', + 'google_base_url':'https://www.googleapis.com/oauth2/v1/', } def __init__(self, id=None, name=None, value=None): @@ -1804,7 +1833,7 @@ class Setting(db.Model): if maintenance is None: value = self.defaults['maintenance'] - maintenance = Setting(name='maintenance', value=value) + maintenance = Setting(name='maintenance', value=str(value)) db.session.add(maintenance) mode = str(mode) @@ -1825,7 +1854,7 @@ class Setting(db.Model): if current_setting is None: value = self.defaults[setting] - current_setting = Setting(name=setting, value=value) + current_setting = Setting(name=setting, value=str(value)) db.session.add(current_setting) try: @@ -1864,12 +1893,20 @@ class Setting(db.Model): if setting in self.defaults: result = self.query.filter(Setting.name == setting).first() if result is not None: - return result.value + return strtobool(result.value) if result.value in ['True', 'False'] else result.value else: return self.defaults[setting] else: logging.error('Unknown setting queried: {0}'.format(setting)) + def get_view(self, view): + r = {} + settings = Setting.query.filter(Setting.view == view).all() + for setting in settings: + d = setting.__dict__ + r[d['name']] = d['value'] + return r + class DomainTemplate(db.Model): __tablename__ = "domain_template" diff --git a/app/templates/admin.html b/app/templates/admin.html index c229bc0..8677b9d 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set active_page = "admin_console" %} {% block title %}DNS Control Panel - Admin Console{% endblock %} {% block dashboard_stat %} diff --git a/app/templates/admin_editaccount.html b/app/templates/admin_editaccount.html index 1f31650..68be658 100644 --- a/app/templates/admin_editaccount.html +++ b/app/templates/admin_editaccount.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set active_page = "admin_accounts" %} {% block title %}DNS Control Panel - Edit Account{% endblock %} {% block dashboard_stat %} diff --git a/app/templates/admin_edituser.html b/app/templates/admin_edituser.html index 83e861d..7e10445 100644 --- a/app/templates/admin_edituser.html +++ b/app/templates/admin_edituser.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set active_page = "admin_users" %} {% block title %}DNS Control Panel - Edit User{% endblock %} {% block dashboard_stat %} diff --git a/app/templates/admin_history.html b/app/templates/admin_history.html index c146d52..a515d02 100644 --- a/app/templates/admin_history.html +++ b/app/templates/admin_history.html @@ -1,4 +1,6 @@ -{% extends "base.html" %} {% block title %} +{% extends "base.html" %} +{% set active_page = "admin_history" %} +{% block title %} DNS Control Panel - History {% endblock %} {% block dashboard_stat %} diff --git a/app/templates/admin_manageaccount.html b/app/templates/admin_manageaccount.html index 7af5125..d439ba9 100644 --- a/app/templates/admin_manageaccount.html +++ b/app/templates/admin_manageaccount.html @@ -1,4 +1,6 @@ -{% extends "base.html" %} {% block title %} +{% extends "base.html" %} +{% set active_page = "admin_accounts" %} +{% block title %} DNS Control Panel - Account Management {% endblock %} {% block dashboard_stat %}
diff --git a/app/templates/admin_manageuser.html b/app/templates/admin_manageuser.html index 24d70e9..005060c 100644 --- a/app/templates/admin_manageuser.html +++ b/app/templates/admin_manageuser.html @@ -1,4 +1,6 @@ -{% extends "base.html" %} {% block title %} +{% extends "base.html" %} +{% set active_page = "admin_users" %} +{% block title %} DNS Control Panel - User Management {% endblock %} {% block dashboard_stat %}
diff --git a/app/templates/admin_setting_authentication.html b/app/templates/admin_setting_authentication.html new file mode 100644 index 0000000..4be5437 --- /dev/null +++ b/app/templates/admin_setting_authentication.html @@ -0,0 +1,271 @@ +{% extends "base.html" %} +{% set active_page = "admin_settings" %} +{% block title %} +DNS Control Panel - Authentication Settings +{% endblock %} {% block dashboard_stat %} + +
+

+ Settings PowerDNS-Admin settings +

+ +
+{% endblock %} +{% block content %} +
+
+
+
+
+

Authentication Settings

+
+
+ + +
+
+
+
+
+{% endblock %} +{% block extrascripts %} + + +{% endblock %} diff --git a/app/templates/admin_settings.html b/app/templates/admin_setting_basic.html similarity index 70% rename from app/templates/admin_settings.html rename to app/templates/admin_setting_basic.html index 3eafc46..a885d12 100644 --- a/app/templates/admin_settings.html +++ b/app/templates/admin_setting_basic.html @@ -1,5 +1,7 @@ -{% extends "base.html" %} {% block title %} -DNS Control Panel - Settings +{% extends "base.html" %} +{% set active_page = "admin_settings" %} +{% block title %} +DNS Control Panel - Basic Settings {% endblock %} {% block dashboard_stat %}
@@ -7,9 +9,9 @@ Settings PowerDNS-Admin settings
{% endblock %} {% block content %} @@ -18,7 +20,7 @@
-

Settings Management

+

Basic Settings

@@ -30,21 +32,21 @@ - {% for setting_name, setting_value in settings.items() %} + {% for setting in settings %} - - {% if setting_value == "True" or setting_value == "False" %} - + + {% if setting.value == "True" or setting.value == "False" %} + {% else %} - + {% endif %}
{{ setting_name }}{{ setting_value }}{{ setting.name }}{{ setting.value }} - {% if setting_value == "True" or setting_value == "False" %} - {% else %} - {% endif %} @@ -76,14 +78,14 @@ }); $(document.body).on('click', '.setting-toggle-button', function() { var setting = $(this).prop('id'); - applyChanges('', $SCRIPT_ROOT + '/admin/setting/' + setting + '/toggle', false, true) + applyChanges('', $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/toggle', false, true) }); $(document.body).on('click', '.setting-save-button', function() { var setting = $(this).prop('id'); var value = $(this).parents('tr').find('#value')[0].value; var postdata = {'value': value}; - applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/' + setting + '/edit', false, true) + applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/edit', false, true) }); {% endblock %} diff --git a/app/templates/admin_setting_pdns.html b/app/templates/admin_setting_pdns.html new file mode 100644 index 0000000..ba77b65 --- /dev/null +++ b/app/templates/admin_setting_pdns.html @@ -0,0 +1,75 @@ +{% extends "base.html" %} +{% set active_page = "admin_settings" %} +{% block title %} +DNS Control Panel - PDNS Settings +{% endblock %} {% block dashboard_stat %} + +
+

+ Settings PowerDNS-Admin settings +

+ +
+{% endblock %} +{% block content %} +
+
+
+
+
+

PDNS Settings

+
+ + +
+ +
+ {% if error %} +
+ +

Error!

+ {{ error }} +
+ {{ error }} + {% endif %} +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+
+
+

Help

+
+
+

Fill in all the fields to the in the form to the left.

+
+
+
+
+
+{% endblock %} +{% block extrascripts %} +{% endblock %} \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index 432274b..ed9022c 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -21,7 +21,7 @@ {% endblock %} - +
{% block pageheader %}
@@ -105,17 +105,44 @@ {% endif %} @@ -146,7 +173,7 @@
{% block scripts %} {% assets "js_main" -%} diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 6ce2180..cf771fc 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set active_page = "dashboard" %} {% block title %}DNS Control Panel - HOME{% endblock %} {% block dashboard_stat %} @@ -188,14 +189,14 @@ "ajax" : "{{ url_for('dashboard_domains') }}", "info" : false, "autoWidth" : false, - {% if default_domain_table_size_setting in ['10','25','50','100'] %} + {% if SETTING.get('default_domain_table_size') in ['10','25','50','100'] %} "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], {% else %} - "lengthMenu": [ [10, 25, 50, 100, {{ default_domain_table_size_setting }}, -1], - [10, 25, 50, 100, {{ default_domain_table_size_setting }}, "All"]], + "lengthMenu": [ [10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, -1], + [10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, "All"]], {% endif %} - "pageLength": {{ default_domain_table_size_setting }} + "pageLength": {{ SETTING.get('default_domain_table_size') }} }); $(document.body).on('click', '.history-info-button', function() { var modal = $("#modal_history_info"); diff --git a/app/templates/domain.html b/app/templates/domain.html index 5769b2f..c6f62be 100644 --- a/app/templates/domain.html +++ b/app/templates/domain.html @@ -118,14 +118,14 @@ "ordering" : true, "info" : true, "autoWidth" : false, - {% if default_record_table_size_setting in ['5','15','20'] %} + {% if SETTING.get('default_record_table_size') in ['5','15','20'] %} "lengthMenu": [ [5, 15, 20, -1], [5, 15, 20, "All"]], {% else %} - "lengthMenu": [ [5, 15, 20, {{ default_record_table_size_setting }}, -1], - [5, 15, 20, {{ default_record_table_size_setting }}, "All"]], + "lengthMenu": [ [5, 15, 20, {{ SETTING.get('default_record_table_size') }}, -1], + [5, 15, 20, {{ SETTING.get('default_record_table_size') }}, "All"]], {% endif %} - "pageLength": {{ default_record_table_size_setting }}, + "pageLength": {{ SETTING.get('default_record_table_size') }}, "language": { "lengthMenu": " _MENU_ records" }, @@ -267,7 +267,7 @@ applyChanges({'domain': domain}, $SCRIPT_ROOT + '/domain/' + domain + '/update'); }); - {% if record_helper_setting %} + {% if SETTING.get('record_helper_setting') %} //handle wacky record types $(document.body).on("focus", "#current_edit_record_data", function (e) { var record_type = $(this).parents("tr").find('#record_type').val(); diff --git a/app/templates/domain_add.html b/app/templates/domain_add.html index 64ed76c..516fbd1 100644 --- a/app/templates/domain_add.html +++ b/app/templates/domain_add.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set active_page = "new_domain" %} {% block title %}DNS Control Panel - Add Domain{% endblock %} {% block dashboard_stat %} @@ -45,7 +46,7 @@