WIP: Draft: Include fields of non-ExtensibleModel relations in syncable fields #2760

Closed
magicfelix wants to merge 1 commit from 751-include-fields-of-non-extensible-model-in-syncable-fields into master
Member

Closes #751

Closes #751
Author
Member

This is to temporarily work around a strange error, I couldn't fix yet.

Cell In [2], line 1
----> 1 read_model_from_ldap(Person, "uid=felix,ou=People,dc=magicfelix,dc=de")

File ~/src/AlekSIS/apps/official/AlekSIS-App-LDAP/aleksis/apps/ldap/util/ldap_sync.py:232, in read_model_from_ldap(model, dn, force)
    230 else:
    231     field = model._meta.get_field(field_name)
--> 232 value = from_ldap(value, field, dn, ldap_attribute)
    233 model_fields[field_name] = value
    235 if field_mapping.match:

File ~/src/AlekSIS/apps/official/AlekSIS-App-LDAP/aleksis/apps/ldap/util/ldap_sync.py:80, in from_ldap(value, field, dn, ldap_field, instance)
     77     return fieldfile
     79 # Finally, use field's conversion method as default
---> 80 return field.to_python(value)

File ~/src/AlekSIS/apps/official/AlekSIS-Core/aleksis/core/mixins.py:341, in ExtensibleModel.syncable_fields.<locals>.<lambda>(v)
    332         print(f"SUBFIELD: {subfield}")
    333         print(f"SUBFIELD_DICT: {subfield.__dict__}")
    334         fields.append(
    335             type(
    336                 "FakeRelatedProxyField",
    337                 (),
    338                 {
    339                     "name": name,
    340                     "verbose_name": verbose_name,
--> 341                     "to_python": lambda v: subfield.to_python(v),
    342                 },
    343             )
    344         )
    345 elif field.editable and not field.auto_created:
    346     fields.append(field)

File ~/.cache/pypoetry/virtualenvs/aleksis-core-qqij0Gkv-py3.10/lib/python3.10/site-packages/django/db/models/fields/__init__.py:1388, in DateTimeField.to_python(self, value)
   1381 except ValueError:
   1382     raise exceptions.ValidationError(
   1383         self.error_messages['invalid_date'],
   1384         code='invalid_date',
   1385         params={'value': value},
   1386     )
-> 1388 raise exceptions.ValidationError(
   1389     self.error_messages['invalid'],
   1390     code='invalid',
   1391     params={'value': value},
   1392 )

ValidationError: ['“felix” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
This is to temporarily work around a strange error, I couldn't fix yet. ``` Cell In [2], line 1 ----> 1 read_model_from_ldap(Person, "uid=felix,ou=People,dc=magicfelix,dc=de") File ~/src/AlekSIS/apps/official/AlekSIS-App-LDAP/aleksis/apps/ldap/util/ldap_sync.py:232, in read_model_from_ldap(model, dn, force) 230 else: 231 field = model._meta.get_field(field_name) --> 232 value = from_ldap(value, field, dn, ldap_attribute) 233 model_fields[field_name] = value 235 if field_mapping.match: File ~/src/AlekSIS/apps/official/AlekSIS-App-LDAP/aleksis/apps/ldap/util/ldap_sync.py:80, in from_ldap(value, field, dn, ldap_field, instance) 77 return fieldfile 79 # Finally, use field's conversion method as default ---> 80 return field.to_python(value) File ~/src/AlekSIS/apps/official/AlekSIS-Core/aleksis/core/mixins.py:341, in ExtensibleModel.syncable_fields.<locals>.<lambda>(v) 332 print(f"SUBFIELD: {subfield}") 333 print(f"SUBFIELD_DICT: {subfield.__dict__}") 334 fields.append( 335 type( 336 "FakeRelatedProxyField", 337 (), 338 { 339 "name": name, 340 "verbose_name": verbose_name, --> 341 "to_python": lambda v: subfield.to_python(v), 342 }, 343 ) 344 ) 345 elif field.editable and not field.auto_created: 346 fields.append(field) File ~/.cache/pypoetry/virtualenvs/aleksis-core-qqij0Gkv-py3.10/lib/python3.10/site-packages/django/db/models/fields/__init__.py:1388, in DateTimeField.to_python(self, value) 1381 except ValueError: 1382 raise exceptions.ValidationError( 1383 self.error_messages['invalid_date'], 1384 code='invalid_date', 1385 params={'value': value}, 1386 ) -> 1388 raise exceptions.ValidationError( 1389 self.error_messages['invalid'], 1390 code='invalid', 1391 params={'value': value}, 1392 ) ValidationError: ['“felix” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.'] ```
Author
Member

added 1 commit

  • e308eb72 - Include fields of non-ExtensibleModel relations in syncable fields

Compare with previous version

added 1 commit <ul><li>e308eb72 - Include fields of non-ExtensibleModel relations in syncable fields</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/1115/diffs?diff_id=25523&start_sha=36f49c61faa9c75a88bcde1fd7caac48b1f98490)
Author
Member

added 4 commits

  • e308eb72...dd746d75 - 3 commits from branch master
  • 989c7f9a - Include fields of non-ExtensibleModel relations in syncable fields

Compare with previous version

added 4 commits <ul><li>e308eb72...dd746d75 - 3 commits from branch <code>master</code></li><li>989c7f9a - Include fields of non-ExtensibleModel relations in syncable fields</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/1115/diffs?diff_id=25652&start_sha=e308eb72ac21a6125cacda9287658e60c209d4d7)
Owner

assigned to @nik

assigned to @nik
Owner

Syncable fields are not used anymore.

Syncable fields are not used anymore.
nik closed this pull request 2023-01-24 21:26:17 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-Core!2760
No description provided.