Univention Bugzilla – Bug 41987
Import impossible without class assignment via CSV import
Last modified: 2016-10-04 13:24:53 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.']}
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
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
Fix: OK, could import teacher/staff via UMC module YAML: OK
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.