sources/ldap: move labels from form to models
This commit is contained in:
parent
bdd1863177
commit
75b687ecbe
|
@ -45,14 +45,6 @@ class LDAPSourceForm(forms.ModelForm):
|
|||
"policies": FilteredSelectMultiple(_("policies"), False),
|
||||
"property_mappings": FilteredSelectMultiple(_("Property Mappings"), False),
|
||||
}
|
||||
labels = {
|
||||
"server_uri": _("Server URI"),
|
||||
"bind_cn": _("Bind CN"),
|
||||
"start_tls": _("Enable Start TLS"),
|
||||
"base_dn": _("Base DN"),
|
||||
"additional_user_dn": _("Addition User DN"),
|
||||
"additional_group_dn": _("Addition Group DN"),
|
||||
}
|
||||
|
||||
|
||||
class LDAPPropertyMappingForm(forms.ModelForm):
|
||||
|
|
|
@ -13,8 +13,9 @@ def create_default_ad_property_mappings(apps: Apps, schema_editor):
|
|||
"sAMAccountName": "username",
|
||||
"mail": "email",
|
||||
}
|
||||
db_alias = schema_editor.connection.alias
|
||||
for ldap_property, object_field in mapping.items():
|
||||
LDAPPropertyMapping.objects.get_or_create(
|
||||
LDAPPropertyMapping.objects.using(db_alias).get_or_create(
|
||||
ldap_property=ldap_property,
|
||||
object_field=object_field,
|
||||
defaults={
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
# Generated by Django 2.2.9 on 2020-02-16 11:16
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("passbook_sources_ldap", "0005_auto_20191011_1059"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="ldappropertymapping",
|
||||
name="ldap_property",
|
||||
field=models.TextField(verbose_name="LDAP Property"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="additional_group_dn",
|
||||
field=models.TextField(
|
||||
help_text="Prepended to Base DN for Group-queries.",
|
||||
verbose_name="Addition Group DN",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="additional_user_dn",
|
||||
field=models.TextField(
|
||||
help_text="Prepended to Base DN for User-queries.",
|
||||
verbose_name="Addition User DN",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="base_dn",
|
||||
field=models.TextField(verbose_name="Base DN"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="bind_cn",
|
||||
field=models.TextField(verbose_name="Bind CN"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="server_uri",
|
||||
field=models.TextField(
|
||||
validators=[
|
||||
django.core.validators.URLValidator(schemes=["ldap", "ldaps"])
|
||||
],
|
||||
verbose_name="Server URI",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="ldapsource",
|
||||
name="start_tls",
|
||||
field=models.BooleanField(default=False, verbose_name="Enable Start TLS"),
|
||||
),
|
||||
]
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from django.core.validators import URLValidator
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from passbook.core.models import Group, PropertyMapping, Source
|
||||
|
||||
|
@ -10,17 +10,22 @@ from passbook.core.models import Group, PropertyMapping, Source
|
|||
class LDAPSource(Source):
|
||||
"""LDAP Authentication source"""
|
||||
|
||||
server_uri = models.TextField(validators=[URLValidator(schemes=["ldap", "ldaps"])])
|
||||
bind_cn = models.TextField()
|
||||
server_uri = models.TextField(
|
||||
validators=[URLValidator(schemes=["ldap", "ldaps"])],
|
||||
verbose_name=_("Server URI"),
|
||||
)
|
||||
bind_cn = models.TextField(verbose_name=_("Bind CN"))
|
||||
bind_password = models.TextField()
|
||||
start_tls = models.BooleanField(default=False)
|
||||
start_tls = models.BooleanField(default=False, verbose_name=_("Enable Start TLS"))
|
||||
|
||||
base_dn = models.TextField()
|
||||
base_dn = models.TextField(verbose_name=_("Base DN"))
|
||||
additional_user_dn = models.TextField(
|
||||
help_text=_("Prepended to Base DN for User-queries.")
|
||||
help_text=_("Prepended to Base DN for User-queries."),
|
||||
verbose_name=_("Addition User DN"),
|
||||
)
|
||||
additional_group_dn = models.TextField(
|
||||
help_text=_("Prepended to Base DN for Group-queries.")
|
||||
help_text=_("Prepended to Base DN for Group-queries."),
|
||||
verbose_name=_("Addition Group DN"),
|
||||
)
|
||||
|
||||
user_object_filter = models.TextField(
|
||||
|
@ -54,7 +59,7 @@ class LDAPSource(Source):
|
|||
class LDAPPropertyMapping(PropertyMapping):
|
||||
"""Map LDAP Property to User or Group object"""
|
||||
|
||||
ldap_property = models.TextField()
|
||||
ldap_property = models.TextField(verbose_name=_("LDAP Property"))
|
||||
object_field = models.TextField()
|
||||
|
||||
form = "passbook.sources.ldap.forms.LDAPPropertyMappingForm"
|
||||
|
|
Reference in New Issue