Bug 41987 - Import impossible without class assignment via CSV import
Import impossible without class assignment via CSV import
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.1 R2
Other Linux
: P5 major (vote)
: UCS@school 4.1 R2 vXXX
Assigned To: Daniel Tröder
Florian Best
: interim-1
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-12 17:50 CEST by Sönke Schwardt-Krummrich
Modified: 2016-10-04 13:24 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 4: Will affect most installed domains
How will those affected feel about the bug?: 4: A User would return the product
User Pain: 0.457
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2016081221000528
Bug group (optional): External feedback
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2016-08-12 17:50:02 CEST
Ticket#2016081221000528

With UCS@school 4.1R2v3 it is not possible to import users via CSV-Import UMC module without an assigned class (e.g. teachers or staff). See traceback below.

Workaround: import users with an assigned class and remove the class assignment afterwards via "assign teachers" UMC module.

It is currently untested, if this problem is already fixed by latest dev version of ucs-school-lib.

29.07.16 15:35:32.170  MODULE      ( PROCESS ) : Going to create CSVTeachersAndStaff gl.dcoroly
29.07.16 15:35:32.173  MODULE      ( PROCESS ) : Creating CSVTeachersAndStaff(name='gl.dcoroly', school='gsmitte', dn='uid=gl.dcoroly,cn=lehrer und mitarbeiter,cn=users,ou=gsmitte,dc=nstx,dc=local')
29.07.16 15:35:32.227  MODULE      ( PROCESS ) : Creating SchoolClass(name='gsmitte-', school='gsmitte', dn='cn=gsmitte-,cn=klassen,cn=schueler,cn=groups,ou=gsmitte,dc=nstx,dc=local')
29.07.16 15:35:32.228  MODULE      ( WARN    ) : Something went wrong. Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolcsvimport/util.py", line 229, in commit
    self.create(lo, validate=False)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 417, in create
    success = self.create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 443, in create_without_hooks
    self.do_create(udm_obj, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 226, in do_create
    udm_obj['groups'] = self.groups_used(lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 496, in groups_used
    self.get_or_create_group_udm_object(group_dn, lo, self.school)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 509, in get_or_create_group_udm_object
    group.create(lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 417, in create
    success = self.create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 200, in create_without_hooks
    success = super(SchoolClass, self).create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 430, in create_without_hooks
    raise ValidationError(self.errors.copy())
ValidationError: {'name': ['Der Wert darf nur Zahlen, Buchstaben und Punkte enthalten.']}
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2016-09-15 17:50:31 CEST
Reproducible by importing user with Role "Teacher and Staff" and only specify username, firstname and lastname via UMC CSV module.

Hint: there is already a ucs-test script for testing the UMC CSV module:
73_CSV_import_module
Comment 2 Daniel Tröder univentionstaff 2016-09-16 14:57:57 CEST
The ucsschool.lib allows the creation of all User types without specifying a class:

for cls in [Student, Staff, Teachers, TeachersAndStaff]:
  rand_str = "".join([random.choice(string.ascii_letters) for _x in range(5)])
  kwargs = {
    'school': school_name,
    'schools': [school_name],
    'name': "un_{}".format(rand_str),
    'firstname': "fn_{}".format(rand_str),
    'lastname': "ln_{}".format(rand_str),
    'school_classes': {},
    'email': "mail.{}@uni.dtr".format(rand_str),
    'password': "univention",
    'disabled': 'none'
  }
  cls(**kwargs).create(lo)

→ 4*True

It is JS-code in the UMC-CSV-module that created a bad argument to the ucsschool.lib.User constructor if no classes were specified:
{.., 'school_classes': {'schulezwei': ['']}, ..}


r72643: allow import without classes in CSV
Comment 3 Florian Best univentionstaff 2016-09-20 14:03:08 CEST
Fix: OK, could import teacher/staff via UMC module
YAML: OK
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2016-10-04 13:24:53 CEST
UCS@school 4.1 R2 v5 has been released.

http://docs.software-univention.de/changelog-ucsschool-4.1R2v5-de.html

If this error occurs again, please clone this bug.