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 %}