2019-10-11 10:53:48 +00:00
|
|
|
# Generated by Django 2.2.6 on 2019-10-11 08:25
|
|
|
|
|
|
|
|
from django.apps.registry import Apps
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
|
|
|
|
def create_default_ad_property_mappings(apps: Apps, schema_editor):
|
2019-12-31 11:51:16 +00:00
|
|
|
LDAPPropertyMapping = apps.get_model("passbook_sources_ldap", "LDAPPropertyMapping")
|
2019-10-11 10:53:48 +00:00
|
|
|
mapping = {
|
2019-12-31 11:51:16 +00:00
|
|
|
"name": "name",
|
|
|
|
"givenName": "first_name",
|
|
|
|
"sn": "last_name",
|
|
|
|
"sAMAccountName": "username",
|
|
|
|
"mail": "email",
|
2019-10-11 10:53:48 +00:00
|
|
|
}
|
|
|
|
for ldap_property, object_field in mapping.items():
|
|
|
|
LDAPPropertyMapping.objects.get_or_create(
|
|
|
|
ldap_property=ldap_property,
|
|
|
|
object_field=object_field,
|
|
|
|
defaults={
|
2019-12-31 11:51:16 +00:00
|
|
|
"name": f"Autogenerated LDAP Mapping: {ldap_property} -> {object_field}"
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-10-11 10:53:48 +00:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2019-12-31 11:51:16 +00:00
|
|
|
("passbook_sources_ldap", "0002_auto_20191011_0825"),
|
2019-10-11 10:53:48 +00:00
|
|
|
]
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
operations = [migrations.RunPython(create_default_ad_property_mappings)]
|