2018-11-26 17:22:38 +00:00
|
|
|
"""passbook LDAP Forms"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
from django import forms
|
2019-03-10 17:34:09 +00:00
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
2019-02-21 15:06:57 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
from passbook.admin.forms.source import SOURCE_FORM_FIELDS
|
2019-03-10 18:45:16 +00:00
|
|
|
from passbook.core.forms.policies import GENERAL_FIELDS
|
2019-10-07 14:33:48 +00:00
|
|
|
from passbook.sources.ldap.models import LDAPGroupMembershipPolicy, LDAPSource
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
class LDAPSourceForm(forms.ModelForm):
|
|
|
|
"""LDAPSource Form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = LDAPSource
|
|
|
|
fields = SOURCE_FORM_FIELDS + ['server_uri', 'bind_cn', 'bind_password',
|
2018-11-30 14:50:45 +00:00
|
|
|
'type', 'domain', 'base_dn', 'create_user',
|
2019-02-21 15:06:57 +00:00
|
|
|
'reset_password']
|
2018-11-26 21:09:04 +00:00
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'server_uri': forms.TextInput(),
|
|
|
|
'bind_cn': forms.TextInput(),
|
|
|
|
'bind_password': forms.TextInput(),
|
|
|
|
'domain': forms.TextInput(),
|
|
|
|
'base_dn': forms.TextInput(),
|
2019-03-10 17:34:09 +00:00
|
|
|
'policies': FilteredSelectMultiple(_('policies'), False)
|
2018-11-26 21:09:04 +00:00
|
|
|
}
|
2019-02-21 15:06:57 +00:00
|
|
|
labels = {
|
|
|
|
'server_uri': _('Server URI'),
|
|
|
|
'bind_cn': _('Bind CN'),
|
|
|
|
'base_dn': _('Base DN'),
|
|
|
|
}
|
2018-11-26 17:22:38 +00:00
|
|
|
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2019-03-10 18:45:16 +00:00
|
|
|
class LDAPGroupMembershipPolicyForm(forms.ModelForm):
|
|
|
|
"""LDAPGroupMembershipPolicy Form"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2019-03-10 18:45:16 +00:00
|
|
|
class Meta:
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2019-03-10 18:45:16 +00:00
|
|
|
model = LDAPGroupMembershipPolicy
|
|
|
|
fields = GENERAL_FIELDS + ['dn', ]
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'dn': forms.TextInput(),
|
|
|
|
}
|
|
|
|
labels = {
|
|
|
|
'dn': _('DN')
|
|
|
|
}
|