Skip to content
Snippets Groups Projects
Verified Commit add547e5 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Dynamically generate LDAPMatchingFields preference

parent a6be0405
No related branches found
No related tags found
1 merge request!28Resolve "Allow match of users to persons by other fields in AlekSIS and LDAP"
......@@ -35,21 +35,6 @@ class LDAPSyncCreateMissingPersons(BooleanPreference):
verbose_name = _("Create missing persons for LDAP users")
@site_preferences_registry.register
class LDAPMatchingFields(ChoicePreference):
section = ldap
name = "matching_fields"
default = ""
required = False
verbose_name = _("LDAP sync matching fields")
choices = [
("", "-----"),
("match-email", _("Match only on email")),
("match-name", _("Match only on name")),
("match-email-name", _("Match on email and name")),
]
@site_preferences_registry.register
class EnableLDAPGroupSync(BooleanPreference):
section = ldap
......
......@@ -10,7 +10,7 @@ from django.db.models.fields.files import FileField
from django.utils.text import slugify
from django.utils.translation import gettext as _
from dynamic_preferences.types import StringPreference
from dynamic_preferences.types import MultipleChoicePreference, StringPreference
from tqdm import tqdm
from aleksis.core.registries import site_preferences_registry
......@@ -101,6 +101,15 @@ def update_dynamic_preferences():
required = False
default = ""
@site_preferences_registry.register
class LDAPMatchingFields(MultipleChoicePreference):
section = section_ldap
name = "matching_fields"
default = []
required = False
verbose_name = _("LDAP sync matching fields")
choices = [("", "-----")} + [(field.name, field.name) for field in Perosn.syncable_fields()]
def apply_templates(value, patterns, templates, separator="|"):
"""Regex-replace patterns in value in order."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment