|
105 |
room_obj = group_module.object(None, ldap_user_read, None, request.options[0]) |
105 |
room_obj = group_module.object(None, ldap_user_read, None, request.options[0]) |
106 |
room_obj.open() |
106 |
room_obj.open() |
107 |
|
107 |
|
|
|
108 |
# get the school name |
109 |
schoolDN = room_obj.dn[room_obj.dn.find('ou='):] |
110 |
school = ldap_user_read.explodeDn(schoolDN, 1)[0] |
111 |
|
112 |
# prepare the resulting structure |
108 |
result = {} |
113 |
result = {} |
109 |
result['$dn$'] = room_obj.dn |
114 |
result['$dn$'] = room_obj.dn |
110 |
result[ 'school' ] = room_obj.dn[ room_obj.dn.find( '=' ) + 1 : room_obj.dn.find( '-' ) ] |
115 |
result['school'] = school |
111 |
result['name'] = room_obj['name'].replace( '%s-' % result[ 'school' ], '', 1 ) |
116 |
result['name'] = room_obj['name'].replace( '%s-' % school, '', 1 ) |
112 |
result['description'] = room_obj['description'] |
117 |
result['description'] = room_obj['description'] |
113 |
result['computers'] = room_obj['hosts'] |
118 |
result['computers'] = room_obj['hosts'] |
114 |
|
119 |
|
|
158 |
if not group_obj: |
163 |
if not group_obj: |
159 |
raise UMC_OptionTypeError('unknown group object') |
164 |
raise UMC_OptionTypeError('unknown group object') |
160 |
|
165 |
|
|
|
166 |
# apply changes |
161 |
group_obj.open() |
167 |
group_obj.open() |
162 |
group_obj[ 'name' ] = '%(school)s-%(name)s' % group_props |
168 |
if group_obj['name'].startswith('%s-' % group_props['school']): |
|
|
169 |
# room had previously a school prefix |
170 |
group_obj['name'] = '%(school)s-%(name)s' % group_props |
171 |
else: |
172 |
# room did not have a school prefix |
173 |
group_obj['name'] = '%(name)s' % group_props |
163 |
group_obj['description'] = group_props['description'] |
174 |
group_obj['description'] = group_props['description'] |
164 |
group_obj['hosts'] = group_props['computers'] |
175 |
group_obj['hosts'] = group_props['computers'] |
165 |
group_obj.modify() |
176 |
group_obj.modify() |