From ea42c78b9aa2db446d316c1c4f980b8065a08164 Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Tue, 5 Jul 2016 15:14:41 +0000 Subject: [PATCH 1/2] default_domain_table_size setting. --- app/templates/dashboard.html | 13 +++++++++++-- app/views.py | 5 +++++ create_db.py | 6 ++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 2f8dbc0..18063cf 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -214,14 +214,23 @@ "ordering" : false, "info" : false, "autoWidth" : false - }); + }); + // set up domain list $("#tbl_domain_list").DataTable({ "paging" : true, "lengthChange" : true, "searching" : true, "ordering" : true, "info" : false, - "autoWidth" : false + "autoWidth" : false, + {% if default_domain_table_size_setting 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"]], + {% endif %} + "pageLength": {{ default_domain_table_size_setting }} }); $(document.body).on('click', '.history-info-button', function() { var modal = $("#modal_history_info"); diff --git a/app/views.py b/app/views.py index fa517ac..df4c899 100644 --- a/app/views.py +++ b/app/views.py @@ -45,6 +45,11 @@ def inject_default_record_table_size_setting(): default_record_table_size_setting = Setting.query.filter(Setting.name == 'default_record_table_size').first() return dict(default_record_table_size_setting=default_record_table_size_setting.value) +@app.context_processor +def inject_default_domain_table_size_setting(): + default_domain_table_size_setting = Setting.query.filter(Setting.name == 'default_domain_table_size').first() + return dict(default_domain_table_size_setting=default_domain_table_size_setting.value) + # START USER AUTHENTICATION HANDLER @app.before_request def before_request(): diff --git a/create_db.py b/create_db.py index a82d228..572d1f3 100755 --- a/create_db.py +++ b/create_db.py @@ -12,13 +12,15 @@ user_role = Role('User', 'User') maintenance_setting = Setting('maintenance', 'False') fullscreen_layout_setting = Setting('fullscreen_layout', 'True') record_helper_setting = Setting('record_helper', 'True') -default_table_size_setting = Setting('default_record_table_size', '15') +default_record_table_size_setting = Setting('default_record_table_size', '15') +default_domain_table_size_setting = Setting('default_domain_table_size', '10') db.session.add(admin_role) db.session.add(user_role) db.session.add(maintenance_setting) db.session.add(fullscreen_layout_setting) db.session.add(record_helper_setting) -db.session.add(default_table_size_setting) +db.session.add(default_record_table_size_setting) +db.session.add(default_domain_table_size_setting) db.session.commit() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') From 9dc3c3ff98cf99392a0910ada7373100aaaa215c Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Tue, 5 Jul 2016 15:28:02 +0000 Subject: [PATCH 2/2] Set LDAP as source if both LDAP and Basic is enabled. --- app/templates/login.html | 8 ++++++-- app/views.py | 5 +++++ create_db.py | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/templates/login.html b/app/templates/login.html index 9cf3030..a495f24 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -63,8 +63,12 @@
+ {% if login_ldap_first_setting %} + + {% else %} + + {% endif %} +
{% elif ldap_enabled and not basic_enabled %}
diff --git a/app/views.py b/app/views.py index df4c899..66cb100 100644 --- a/app/views.py +++ b/app/views.py @@ -40,6 +40,11 @@ def inject_record_helper_setting(): record_helper_setting = Setting.query.filter(Setting.name == 'record_helper').first() return dict(record_helper_setting=strtobool(record_helper_setting.value)) +@app.context_processor +def inject_login_ldap_first_setting(): + login_ldap_first_setting = Setting.query.filter(Setting.name == 'login_ldap_first').first() + return dict(login_ldap_first_setting=strtobool(login_ldap_first_setting.value)) + @app.context_processor def inject_default_record_table_size_setting(): default_record_table_size_setting = Setting.query.filter(Setting.name == 'default_record_table_size').first() diff --git a/create_db.py b/create_db.py index 572d1f3..c004749 100755 --- a/create_db.py +++ b/create_db.py @@ -12,6 +12,7 @@ user_role = Role('User', 'User') maintenance_setting = Setting('maintenance', 'False') fullscreen_layout_setting = Setting('fullscreen_layout', 'True') record_helper_setting = Setting('record_helper', 'True') +login_ldap_first_setting = Setting('login_ldap_first', 'True') default_record_table_size_setting = Setting('default_record_table_size', '15') default_domain_table_size_setting = Setting('default_domain_table_size', '10') db.session.add(admin_role) @@ -19,6 +20,7 @@ db.session.add(user_role) db.session.add(maintenance_setting) db.session.add(fullscreen_layout_setting) db.session.add(record_helper_setting) +db.session.add(login_ldap_first_setting) db.session.add(default_record_table_size_setting) db.session.add(default_domain_table_size_setting) db.session.commit()