*: propertymapping template -> expression

This commit is contained in:
Jens Langhammer
2020-02-17 20:38:14 +01:00
parent bc4b7ef44d
commit 3aa2f1e892
12 changed files with 42 additions and 23 deletions

View File

@ -35,7 +35,7 @@ class LDAPPropertyMappingSerializer(ModelSerializer):
class Meta:
model = LDAPPropertyMapping
fields = ["pk", "name", "template", "object_field"]
fields = ["pk", "name", "expression", "object_field"]
class LDAPSourceViewSet(ModelViewSet):

View File

@ -155,7 +155,7 @@ class Connector:
properties = {"attributes": {}}
for mapping in self._source.property_mappings.all().select_subclasses():
mapping: LDAPPropertyMapping
properties[mapping.object_field] = mapping.render(
properties[mapping.object_field] = mapping.evaluate(
user=None, request=None, ldap=attributes
)
if self._source.object_uniqueness_field in attributes:

View File

@ -55,7 +55,7 @@ class LDAPPropertyMappingForm(forms.ModelForm):
class Meta:
model = LDAPPropertyMapping
fields = ["name", "object_field", "template"]
fields = ["name", "object_field", "expression"]
widgets = {
"name": forms.TextInput(),
"ldap_property": forms.TextInput(),

View File

@ -22,12 +22,12 @@ def create_default_ad_property_mappings(apps: Apps, schema_editor):
"email": "{{ ldap.mail }}",
}
db_alias = schema_editor.connection.alias
for object_field, template in mapping.items():
for object_field, expression in mapping.items():
LDAPPropertyMapping.objects.using(db_alias).get_or_create(
template=template,
expression=expression,
object_field=object_field,
defaults={
"name": f"Autogenerated LDAP Mapping: {template} -> {object_field}"
"name": f"Autogenerated LDAP Mapping: {expression} -> {object_field}"
},
)
@ -36,6 +36,7 @@ class Migration(migrations.Migration):
dependencies = [
("passbook_sources_ldap", "0006_auto_20200216_1116"),
("passbook_core", "0007_auto_20200217_1934"),
]
operations = [

View File

@ -64,7 +64,7 @@ class LDAPPropertyMapping(PropertyMapping):
form = "passbook.sources.ldap.forms.LDAPPropertyMappingForm"
def __str__(self):
return f"LDAP Property Mapping {self.template} -> {self.object_field}"
return f"LDAP Property Mapping {self.expression} -> {self.object_field}"
class Meta: