From 225dc112e7ed60207aab9ee0ec891ba513b01a27 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 26 Nov 2018 18:22:38 +0100 Subject: [PATCH] ldap: add Source Creation form --- passbook/ldap/forms.py | 17 +++++++++++++---- passbook/ldap/models.py | 4 ++-- passbook/oauth_client/forms.py | 6 ++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/passbook/ldap/forms.py b/passbook/ldap/forms.py index 99504805f..84eb7655a 100644 --- a/passbook/ldap/forms.py +++ b/passbook/ldap/forms.py @@ -1,11 +1,20 @@ -# """Supervisr Mod LDAP Forms""" +"""passbook LDAP Forms""" -# from django import forms -# from django.utils.translation import ugettext_lazy as _ +from django import forms -# from supervisr.core.forms.settings import SettingsForm +from passbook.admin.forms.source import SOURCE_FORM_FIELDS +from passbook.ldap.models import LDAPSource +class LDAPSourceForm(forms.ModelForm): + """LDAPSource Form""" + + class Meta: + + model = LDAPSource + fields = SOURCE_FORM_FIELDS + ['server_uri', 'bind_cn', 'bind_password', + 'type', 'domain', 'base_dn', 'create_user', 'reset_password'] + # class GeneralSettingsForm(SettingsForm): # """general settings form""" # MODE_AUTHENTICATION_BACKEND = 'auth_backend' diff --git a/passbook/ldap/models.py b/passbook/ldap/models.py index d8999af85..e743af105 100644 --- a/passbook/ldap/models.py +++ b/passbook/ldap/models.py @@ -3,8 +3,6 @@ from django.db import models from django.utils.translation import gettext as _ -# from passbook.core.models import (CreatedUpdatedModel, ProductExtension, -# UUIDModel) from passbook.core.models import Source @@ -28,6 +26,8 @@ class LDAPSource(Source): create_user = models.BooleanField(default=False) reset_password = models.BooleanField(default=True) + form = 'passbook.ldap.forms.LDAPSourceForm' + class Meta: verbose_name = _('LDAP Source') diff --git a/passbook/oauth_client/forms.py b/passbook/oauth_client/forms.py index d2f6785b6..1a582fcec 100644 --- a/passbook/oauth_client/forms.py +++ b/passbook/oauth_client/forms.py @@ -2,6 +2,7 @@ from django import forms +from passbook.admin.forms.source import SOURCE_FORM_FIELDS from passbook.oauth_client.models import OAuthSource @@ -11,5 +12,6 @@ class OAuthSourceForm(forms.ModelForm): class Meta: model = OAuthSource - # pylint: disable=modelform-uses-exclude - exclude = [] + fields = SOURCE_FORM_FIELDS + ['provider_type', 'request_token_url', 'authorization_url', + 'access_token_url', 'profile_url', 'consumer_key', + 'consumer_secret']