Merge pull request #77 from jallakim/default-settings

Settings: Default domain table size + LDAP first/selected if both LDAP+Basic
This commit is contained in:
Khanh Ngo 2016-07-06 09:30:56 +07:00 committed by GitHub
commit ff842f66e2
4 changed files with 33 additions and 6 deletions

View File

@ -215,13 +215,22 @@
"info" : false, "info" : false,
"autoWidth" : false "autoWidth" : false
}); });
// set up domain list
$("#tbl_domain_list").DataTable({ $("#tbl_domain_list").DataTable({
"paging" : true, "paging" : true,
"lengthChange" : true, "lengthChange" : true,
"searching" : true, "searching" : true,
"ordering" : true, "ordering" : true,
"info" : false, "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() { $(document.body).on('click', '.history-info-button', function() {
var modal = $("#modal_history_info"); var modal = $("#modal_history_info");

View File

@ -63,7 +63,11 @@
<div class="form-group"> <div class="form-group">
<select class="form-control" name="auth_method"> <select class="form-control" name="auth_method">
<option value="LOCAL">LOCAL Authentication</option> <option value="LOCAL">LOCAL Authentication</option>
{% if login_ldap_first_setting %}
<option value="LDAP" selected="selected">LDAP Authentication</option>
{% else %}
<option value="LDAP">LDAP Authentication</option> <option value="LDAP">LDAP Authentication</option>
{% endif %}
</select> </select>
</div> </div>
{% elif ldap_enabled and not basic_enabled %} {% elif ldap_enabled and not basic_enabled %}

View File

@ -41,11 +41,21 @@ def inject_record_helper_setting():
record_helper_setting = Setting.query.filter(Setting.name == 'record_helper').first() record_helper_setting = Setting.query.filter(Setting.name == 'record_helper').first()
return dict(record_helper_setting=strtobool(record_helper_setting.value)) 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 @app.context_processor
def inject_default_record_table_size_setting(): def inject_default_record_table_size_setting():
default_record_table_size_setting = Setting.query.filter(Setting.name == 'default_record_table_size').first() 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) 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 # START USER AUTHENTICATION HANDLER
@app.before_request @app.before_request
def before_request(): def before_request():

View File

@ -12,13 +12,17 @@ user_role = Role('User', 'User')
maintenance_setting = Setting('maintenance', 'False') maintenance_setting = Setting('maintenance', 'False')
fullscreen_layout_setting = Setting('fullscreen_layout', 'True') fullscreen_layout_setting = Setting('fullscreen_layout', 'True')
record_helper_setting = Setting('record_helper', 'True') record_helper_setting = Setting('record_helper', 'True')
default_table_size_setting = Setting('default_record_table_size', '15') 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) db.session.add(admin_role)
db.session.add(user_role) db.session.add(user_role)
db.session.add(maintenance_setting) db.session.add(maintenance_setting)
db.session.add(fullscreen_layout_setting) db.session.add(fullscreen_layout_setting)
db.session.add(record_helper_setting) db.session.add(record_helper_setting)
db.session.add(default_table_size_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() db.session.commit()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')