2019-02-26 13:07:47 +00:00
|
|
|
# """passbook LDAP Views"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
# from django.contrib import messages
|
|
|
|
# from django.contrib.auth.decorators import login_required, user_passes_test
|
|
|
|
# from django.http import HttpRequest, HttpResponse
|
|
|
|
# from django.shortcuts import redirect, render
|
|
|
|
# from django.urls import reverse
|
|
|
|
# from django.utils.translation import ugettext as _
|
|
|
|
|
2019-10-07 14:33:48 +00:00
|
|
|
# from passbook.sources.ldap.forms import (AuthenticationBackendSettings,
|
2018-11-11 12:41:48 +00:00
|
|
|
# ConnectionSettings,
|
|
|
|
# CreateUsersSettings,
|
|
|
|
# GeneralSettingsForm)
|
|
|
|
|
|
|
|
|
|
|
|
# @login_required
|
|
|
|
# @user_passes_test(lambda u: u.is_superuser)
|
|
|
|
# def admin_settings(request: HttpRequest) -> HttpResponse:
|
|
|
|
# """Default view for modules without admin view"""
|
|
|
|
# form_classes = {
|
|
|
|
# 'general': GeneralSettingsForm,
|
|
|
|
# 'connection': ConnectionSettings,
|
|
|
|
# 'authentication': AuthenticationBackendSettings,
|
|
|
|
# 'create_users': CreateUsersSettings,
|
|
|
|
# }
|
|
|
|
# render_data = {}
|
|
|
|
# for form_key, form_class in form_classes.items():
|
|
|
|
# render_data[form_key] = form_class(request.POST if request.method == 'POST' else None)
|
|
|
|
# if request.method == 'POST':
|
|
|
|
# update_count = 0
|
|
|
|
# for form_key, form_class in form_classes.items():
|
|
|
|
# form = form_class(request.POST)
|
|
|
|
# if form.is_valid():
|
|
|
|
# update_count += form.save()
|
|
|
|
# messages.success(request, _('Successfully updated %d settings.' % update_count))
|
2019-02-26 13:07:47 +00:00
|
|
|
# return redirect(reverse('passbook_ldap:admin_settings'))
|
2018-11-11 12:41:48 +00:00
|
|
|
# return render(request, 'ldap/settings.html', render_data)
|