Univention Bugzilla – Attachment 8029 Details for
Bug 42495
Membership of working groups or global groups get removed if user is modified via ucs-school-lib
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
42493.patch (text/plain), 4.25 KB, created by
Florian Best
on 2016-09-23 18:35:02 CEST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Florian Best
Created:
2016-09-23 18:35:02 CEST
Size:
4.25 KB
patch
obsolete
>diff --git a/ucs-school-lib/python/models/group.py b/ucs-school-lib/python/models/group.py >index f0240bc..ad29b8c 100644 >--- a/ucs-school-lib/python/models/group.py >+++ b/ucs-school-lib/python/models/group.py >@@ -240,6 +240,12 @@ class SchoolClass(Group, _MayHaveSchoolPrefix): > ret['name'] = self.get_relative_name() > return ret > >+ @classmethod >+ def get_class_for_udm_obj(cls, udm_obj, school): >+ if not cls.is_school_class(school, udm_obj.dn): >+ return # is a workgroup >+ return cls >+ > > class WorkGroup(SchoolClass, _MayHaveSchoolPrefix): > >diff --git a/ucs-school-lib/python/models/user.py b/ucs-school-lib/python/models/user.py >index 104b75d..24c64a8 100644 >--- a/ucs-school-lib/python/models/user.py >+++ b/ucs-school-lib/python/models/user.py >@@ -253,45 +253,35 @@ class User(UCSSchoolHelperAbstractClass): > self.password = old_password > return success > >- def do_modify(self, udm_obj, lo): >- self.create_mail_domain(lo) >- self.password = self.password or None >- mandatory_groups = self.groups_used(lo) >- for group_dn in udm_obj['groups'][:]: >- # User might have been removed from school(s), remove class >- # and workgroup memberships for those. Leave other group types >- # (e.g. global groups) untouched. >- logger.debug('Checking group %s for removal', group_dn) >- if group_dn not in mandatory_groups: >- logger.debug('Group not mandatory! Part of a school?') >- try: >- school_group = Group.from_dn(group_dn, None, lo) >- except noObject: >- logger.debug('No. Leaving it alone...') >- continue >- # Bug 41907: >- # SchoolClass.from_dn does not throw WrongModel if no class or workgroup. >- # But self_is_class() and self_is_workgroup() return correct values. >- if school_group.self_is_class(): >- classes = self.school_classes.get(school_group.school, []) >- remove = school_group.name not in classes and school_group.get_relative_name() not in classes >- elif school_group.self_is_workgroup(): >- remove = school_group.school not in self.schools >- else: >- logger.debug('Group is no school class or workgroup. Leave it untouched.') >- continue >- logger.debug('Yes, part of %s!', school_group.school) >- if remove: >- logger.debug('Removing it!') >- udm_obj['groups'].remove(group_dn) >- else: >- logger.debug('Leaving it alone: Part of own school and either non-school class or new school classes were not defined at all.') >- for group_dn in mandatory_groups: >- logger.debug('Checking group %s for adding', group_dn) >- if group_dn not in udm_obj['groups']: >- logger.debug('Group is not yet part of the user. Adding...') >- udm_obj['groups'].append(group_dn) >- return super(User, self).do_modify(udm_obj, lo) >+ def do_modify(self, udm_obj, lo): >+ self.create_mail_domain(lo) >+ self.password = self.password or None >+ mandatory_groups = self.groups_used(lo) >+ for group_dn in udm_obj['groups'][:]: >+ logger.debug('Checking group %s for removal', group_dn) >+ if group_dn not in mandatory_groups: >+ logger.debug('Group not mandatory! Part of a school?') >+ try: >+ school_class = SchoolClass.from_dn(group_dn, None, lo) >+ except noObject: >+ logger.debug('No. Leaving it alone...') >+ continue >+ logger.debug('Yes, part of %s!', school_class.school) >+ if school_class.school not in self.school_classes: >+ continue # if the key isn't set we don't change anything to the groups. to remove the groups it has to be an empty list >+ classes = self.school_classes[school_class.school] >+ remove = school_class.name not in classes and school_class.get_relative_name() not in classes >+ if remove: >+ logger.debug('Removing it!') >+ udm_obj['groups'].remove(group_dn) >+ else: >+ logger.debug('Leaving it alone: Part of own school and either non-school class or new school classes were not defined at all') >+ for group_dn in mandatory_groups: >+ logger.debug('Checking group %s for adding', group_dn) >+ if group_dn not in udm_obj['groups']: >+ logger.debug('Group is not yet part of the user. Adding...') >+ udm_obj['groups'].append(group_dn) >+ return super(User, self).do_modify(udm_obj, lo) > > def do_school_change(self, udm_obj, lo, old_school): > super(User, self).do_school_change(udm_obj, lo, old_school)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 42495
: 8029