Bug 41609 - cannot move staff to different school
cannot move staff to different school
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.1 R2
Other Linux
: P5 normal (vote)
: UCS@school 4.1 R2 vXXX
Assigned To: Daniel Tröder
Florian Best
: interim-1
: 41993 42365 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-06-20 12:56 CEST by Daniel Tröder
Modified: 2016-10-06 08:54 CEST (History)
3 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?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Error handling, External feedback
Max CVSS v3 score:


Attachments
patch (492 bytes, patch)
2016-07-18 20:21 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2016-06-20 12:56:52 CEST
Reproduce with:

st1 = Staff(name="astaff2", school="schule1", lastname="ln1", firstname="fn1")
st1.create(lo)
st1_from_ldap = Staff.from_dn(st1.dn, st1.school, lo)
st1_from_ldap.school_classes is None
→ True
st1_from_ldap.change_school("schule2", lo)

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in change_school(self, school, lo)
    562                 self.school = school
    563                 self.position = self.get_own_container()
--> 564                 return self.move(lo, force=True)
    565 
    566         def do_school_change(self, udm_obj, lo, old_school):

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in move(self, lo, udm_obj, force)
    522         def move(self, lo, udm_obj=None, force=False):
    523                 self.call_hooks('pre', 'move')
--> 524                 success = self.move_without_hooks(lo, udm_obj, force)
    525                 if success:
    526                         self.call_hooks('post', 'move')

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in move_without_hooks(self, lo, udm_obj, force)
    542                 if force or self._meta.allow_school_change:
    543                         try:
--> 544                                 self.do_move(udm_obj, lo)
    545                         finally:
    546                                 self.invalidate_cache()

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in do_move(self, udm_obj, lo)
    555                 udm_obj.move(self.dn, ignore_license=1)
    556                 if self.supports_school() and old_school and old_school != new_school:
--> 557                         self.do_school_change(udm_obj, lo, old_school)
    558 
    559         def change_school(self, school, lo):

/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.pyc in do_school_change(self, udm_obj, lo, old_school)
    288                 self.remove_from_groups_of_school(old_school, lo)
    289                 self._udm_obj_searched = False
--> 290                 self.school_classes.pop(old_school, None)
    291                 udm_obj = self.get_udm_object(lo)
    292                 udm_obj['primaryGroup'] = self.primary_group_dn(lo)

AttributeError: 'NoneType' object has no attribute 'pop'
Comment 1 Daniel Tröder univentionstaff 2016-06-20 13:43:01 CEST
Code: r70426
Advisory: r70428
Comment 2 Daniel Tröder univentionstaff 2016-06-20 13:53:02 CEST
Another piece of code was modified for the same reason:
code: 70429
yaml: 70430
Comment 3 Florian Best univentionstaff 2016-07-18 20:21:43 CEST
Created attachment 7814 [details]
patch

Maybe we should stick to this patch and remove all the workarounds we added.
Comment 4 Daniel Tröder univentionstaff 2016-07-19 11:43:46 CEST
Some code cleanup was done:
ucs-school-lib: 71080
ucs-school-import: 71081
advisories: 71083
Comment 5 Daniel Tröder univentionstaff 2016-07-20 15:41:51 CEST
Package ucs-school-umc-csv-import had to be adapted to the change to User.school_classes as well:

Code: 71115 71116
Advisory: 71115 71117 71118
Comment 6 Florian Best univentionstaff 2016-07-21 15:37:34 CEST
YAML: OK
ucs-school-lib: OK
ucs-school-umc-csv-import: OK
ucs-test: OK
Comment 7 Florian Best univentionstaff 2016-08-15 15:44:42 CEST
*** Bug 41993 has been marked as a duplicate of this bug. ***
Comment 8 Florian Best univentionstaff 2016-08-24 16:11:10 CEST
Version: 4.1-3 errata234 (Vahr)

Traceback(21d44cf46d75ce7f8ecac8d90549e9c7):
Die Ausführung des Kommandos schoolwizards/users/put schoolwizards/users ist fehlgeschlagen:

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 140, 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 273, in do_modify
    classes = self.school_classes[school_group.school]
TypeError: 'NoneType' object has no attribute '__getitem__'
Comment 9 Daniel Tröder univentionstaff 2016-09-08 11:28:55 CEST
Test for this bug is in 90_ucsschool/34_import-users_via_cli_v2 test_school_change().
Comment 10 Florian Best univentionstaff 2016-09-13 11:58:51 CEST
*** Bug 42365 has been marked as a duplicate of this bug. ***
Comment 11 Daniel Tröder univentionstaff 2016-09-15 09:56:20 CEST
This is also tested in 90_ucsschool/80_move_users_into_another_ou.
Comment 12 Sönke Schwardt-Krummrich univentionstaff 2016-10-04 13:24:49 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.