View | Details | Raw Unified | Return to bug 43247
Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py (-6 / +8 lines)
 Lines 2430-2443   def update_groups(self): Link Here 
2430
				return
2430
				return
2431
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'updating groups')
2431
		univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'updating groups')
2432
2432
2433
		def _append_dn(from_, target, dn):
2434
			if not any(self.lo.lo.compare_dn(x, dn) for x in from_):
2435
				target.append(dn)
2436
2433
		add_to_group = []
2437
		add_to_group = []
2434
		remove_from_group = []
2438
		remove_from_group = []
2435
		for group in self.oldinfo.get('groups', []):
2439
		for group in self.oldinfo.get('groups', []):
2436
			if group not in self.info.get('groups', []):
2440
			_append_dn(self.info.get('groups', []), remove_from_group, group)
2437
				remove_from_group.append(group)
2438
		for group in self.info.get('groups', []):
2441
		for group in self.info.get('groups', []):
2439
			if group not in self.oldinfo.get('groups', []):
2442
			_append_dn(self.oldinfo.get('groups', []), add_to_group, group)
2440
				add_to_group.append(group)
2441
2443
2442
		if 'oldPrimaryGroupDn' in self.__dict__:
2444
		if 'oldPrimaryGroupDn' in self.__dict__:
2443
			if self.oldPrimaryGroupDn:
2445
			if self.oldPrimaryGroupDn:
 Lines 2455-2468   def update_groups(self): Link Here 
2455
		for group in add_to_group:
2457
		for group in add_to_group:
2456
			groupObject = univention.admin.objects.get(univention.admin.modules.get('groups/group'), self.co, self.lo, self.position, group)
2458
			groupObject = univention.admin.objects.get(univention.admin.modules.get('groups/group'), self.co, self.lo, self.position, group)
2457
			groupObject.open()
2459
			groupObject.open()
2458
			if self.dn not in groupObject['hosts']:
2460
			if not any(self.lo.lo.compare_dn(x, self.dn) for x in groupObject['hosts']):
2459
				groupObject['hosts'].append(self.dn)
2461
				groupObject['hosts'].append(self.dn)
2460
				groupObject.modify(ignore_license=1)
2462
				groupObject.modify(ignore_license=1)
2461
2463
2462
		for group in remove_from_group:
2464
		for group in remove_from_group:
2463
			groupObject = univention.admin.objects.get(univention.admin.modules.get('groups/group'), self.co, self.lo, self.position, group)
2465
			groupObject = univention.admin.objects.get(univention.admin.modules.get('groups/group'), self.co, self.lo, self.position, group)
2464
			groupObject.open()
2466
			groupObject.open()
2465
			if self.dn in groupObject['hosts']:
2467
			if not any(self.lo.lo.compare_dn(x, self.dn) for x in groupObject['hosts']):
2466
				groupObject['hosts'].remove(self.dn)
2468
				groupObject['hosts'].remove(self.dn)
2467
				groupObject.modify(ignore_license=1)
2469
				groupObject.modify(ignore_license=1)
2468
2470

Return to bug 43247