Bug 42432 - schoolwizards are broken for users without ucsschoolSchool
schoolwizards are broken for users without ucsschoolSchool
Status: CLOSED DUPLICATE of bug 42441
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.1 R2
Other Linux
: P5 normal (vote)
: UCS@school 4.0 R2 Errata
Assigned To: Florian Best
Daniel Tröder
: interim-2
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-19 15:55 CEST by Florian Best
Modified: 2016-10-25 15:58 CEST (History)
4 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?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.257
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-09-19 15:55:15 CEST
The school wizards can't be used with users which doesn't have the ucsschoolSchool attribute set.
It seems the attribute is not set by the import script leading to such users.

Command to import users was:
/usr/share/ucs-school-import/scripts/ucs-school-import users.csv

users.csv:
A       Anton12 Lange   Anton   test    test-1B         Anton12@test2.intranet  0       1       0

HTTP request which causes the traceback:
curl 'http://Administrator:univention@10.200.36.100/univention-management-console/command/schoolwizards/users/put' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary '{"options":[{"object":{"school":"test","type":"student","firstname":"Anton","lastname":"Lange","name":"anton12","school_classes":{"test":["4B"]},"email":"anton12@test2.intranet","password":"","$dn$":"uid=anton12,cn=schueler,cn=users,ou=test,dc=test2,dc=intranet"},"options":null}],"flavor":"schoolwizards/users"}'

Current unrelease packages were used:
python-ucs-school 9.0.23-6.261.201609150827

Execution of command 'schoolwizards/users/put schoolwizards/users' has failed:

Traceback (most recent call last):
  File "%PY2.7%/univention/management/console/base.py", line 283, in execute
    function(self, request)
  File "%PY2.7%/univention/management/console/modules/schoolwizards/__init__.py", line 112, in _decorated
    ret = func(self, request, *a, **kw)
  File "%PY2.7%/ucsschool/lib/schoolldap.py", line 142, in wrapper_func
    return func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/schoolwizards/__init__.py", line 204, in _modify_obj
    obj.modify(ldap_user_write, validate=False)
  File "%PY2.7%/ucsschool/lib/models/base.py", line 471, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "%PY2.7%/ucsschool/lib/models/base.py", line 494, in modify_without_hooks
    self.do_modify(udm_obj, lo)
  File "%PY2.7%/ucsschool/lib/models/user.py", line 259, in do_modify
    mandatory_groups = self.groups_used(lo)
  File "%PY2.7%/ucsschool/lib/models/user.py", line 458, in groups_used
    group_dns = self.get_specific_groups(lo)
  File "%PY2.7%/ucsschool/lib/models/user.py", line 582, in get_specific_groups
    groups = super(Student, self).get_specific_groups(lo)
  File "%PY2.7%/ucsschool/lib/models/user.py", line 361, in get_specific_groups
    groups = self.get_domain_users_groups()
  File "%PY2.7%/ucsschool/lib/models/user.py", line 443, in get_domain_users_groups
    return [self.get_group_dn('Domain Users %s' % school, school) for school in self.schools]
TypeError: 'NoneType' object is not iterable
Comment 1 Daniel Tröder univentionstaff 2016-09-19 16:08:42 CEST
(In reply to Florian Best from comment #0)
> Command to import users was:
> /usr/share/ucs-school-import/scripts/ucs-school-import users.csv
I think the old-legacy user import is not supported.
"import_user" is the script that is in the documentation, and that is the new-legacy user import.
Comment 2 Florian Best univentionstaff 2016-09-20 13:14:56 CEST
*** Bug 42441 has been marked as a duplicate of this bug. ***
Comment 3 Florian Best univentionstaff 2016-09-20 13:17:42 CEST
I already got part of the patch. But this is not yet finished as it prevents the traceback but the values aren't stored as no changes are detected somehow.

diff --git a/ucs-school-lib/python/models/base.py b/ucs-school-lib/python/models/base.py
index de3be60..9b26276 100644
--- a/ucs-school-lib/python/models/base.py
+++ b/ucs-school-lib/python/models/base.py
@@ -249,8 +249,8 @@ class UCSSchoolHelperAbstractClass(object):
                self._udm_obj = None
                kwargs['name'] = name
                kwargs['school'] = school
-               for key in self._attributes:
-                       setattr(self, key, kwargs.get(key))
+               for key, attr in self._attributes.items():
+                       setattr(self, key, kwargs.get(key, [] if attr.value_list else ({} if attr.value_dict else None)))
                self.__position = None
                self.old_dn = None
                self.old_dn = self.dn
Comment 4 Florian Best univentionstaff 2016-09-20 13:18:18 CEST
(In reply to Florian Best from comment #3)
> I already got part of the patch. But this is not yet finished as it prevents
> the traceback but the values aren't stored as no changes are detected
> somehow.
"no changes" → no changes which schools the user belongs to.
Comment 5 Christina Scheinig univentionstaff 2016-09-21 12:04:51 CEST
An other traceback according to this issue happened, caused by changing the password via school-administration-module → users → select an user → type a new password. Saving the changes, the following traceback is shown up:

Die Ausführung des Kommandos schoolwizards/users/put schoolwizards/users ist fehlgeschlagen:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 283, in execute
    function(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolwizards/__init__.py", line 112, in _decorated
    ret = func(self, request, *a, **kw)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 140, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolwizards/__init__.py", line 204, in _modify_obj
    obj.modify(ldap_user_write, validate=False)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 471, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 494, in modify_without_hooks
    self.do_modify(udm_obj, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 273, in do_modify
    classes = self.school_classes[school_group.school]
TypeError: 'NoneType' object has no attribute '__getitem__'
Comment 6 Florian Best univentionstaff 2016-09-21 13:35:36 CEST
(In reply to Christina Scheinig from comment #5)
> An other traceback according to this issue happened, caused by changing the
> password via school-administration-module → users → select an user → type a
> new password. Saving the changes, the following traceback is shown up:
> 
That is Bug #42365
Comment 7 Florian Best univentionstaff 2016-09-26 14:23:19 CEST

*** This bug has been marked as a duplicate of bug 42441 ***
Comment 8 Florian Best univentionstaff 2016-10-25 15:58:59 CEST
UCS@school 4.1 R2 v6 has been released.

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

If this error occurs again, please clone this bug.