Bug 38439 - SchoolClass model does not pass validate parameter
SchoolClass model does not pass validate parameter
Status: REOPENED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 5.0
Other Linux
: P5 normal with 2 votes (vote)
: UCS@school 4.0.x
Assigned To: UCS@school maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-05 11:27 CEST by Florian Best
Modified: 2023-06-23 14:19 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
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 2015-05-05 11:27:44 CEST
ucs-school-lib/python/models/group.py

169 »   def modify_without_hooks(self, lo, validate=True, move_if_necessary=None):
170 »   »   share = self.ShareClass.from_school_group(self)
…
181 »   »   if success:
182 »   »   »   if share.exists(lo):
183 »   »   »   »   success = share.modify(lo)
184 »   »   »   else:
185 »   »   »   »   success = self.create_share(lo)
186 »   »   return success

The function creates/modifies a share when creating/modifying a school class. I guess it is required to also pass the 'validate' parameter.

Otherwise if validate=False the following traceback could occur:
Die Ausf\u00fchrung des Kommandos schoolwizards/classes/put schoolwizards/classes ist fehlgeschlagen:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/__init__.py", line 176, in _decorated
    return function(self, request, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 205, in wrapper_func
    return func( *args, **kwargs )
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolwizards/__init__.py", line 121, in _decorated
    ret = func(self, request, *a, **kw)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolwizards/__init__.py", line 218, in _modify_obj
    obj.modify(ldap_user_write, validate=False)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 421, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 183, in modify_without_hooks
    success = share.modify(lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 421, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 435, in modify_without_hooks
    raise ValidationError(self.errors.copy())
ValidationError: {'school_group': ['"Schulklasse" ist erforderlich. Bitte erg\xc3\xa4nzen Sie diese Information.']}
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2015-06-18 10:31:19 CEST
I think, that there is a "typo" when creating the "share" instance. The constructor of self.ShareClass() is called with kwarg "school_class=self" but "school_class" is nowhere used as attribute name for any of the object classes. I think "school_group" is the correct name for the kwarg.

def modify_without_hooks(self, lo, validate=True, move_if_necessary=None):
	share = self.ShareClass.from_school_group(self)
	if self.old_dn:
		old_name = self.get_name_from_dn(self.old_dn)
		if old_name != self.name:
			# recreate the share.
			# if the name changed
			# from_school_group will have initialized
			# share.old_dn incorrectly
	→→→→→→→		share = self.ShareClass(name=old_name, school=self.school, school_class=self)  ←←←←←←←←←←←←←←←←←←←←←←←
			share.name = self.name
	success = super(SchoolClass, self).modify_without_hooks(lo, validate, move_if_necessary)
	if success:
		if share.exists(lo):
			success = share.modify(lo)
		else:
			success = self.create_share(lo)
	return success
Comment 2 Florian Best univentionstaff 2015-06-18 12:31:27 CEST
(In reply to Sönke Schwardt-Krummrich from comment #1)
> I think, that there is a "typo" when creating the "share" instance. The
> constructor of self.ShareClass() is called with kwarg "school_class=self"
> but "school_class" is nowhere used as attribute name for any of the object
> classes. I think "school_group" is the correct name for the kwarg.
Oh, yes. I think I remember that I changed it. There might be an alias?
Comment 3 Florian Best univentionstaff 2016-03-01 09:03:31 CET
(In reply to Sönke Schwardt-Krummrich from comment #1)
I fixed the traceback in Bug #40537. Nevertheless the parameter is still passed wrong.
Comment 4 Florian Best univentionstaff 2016-07-21 15:19:46 CEST
21.07.16 15:14:07.986  MODULE      ( PROCESS ) : Going to create CSVStudent luisa.stieg
21.07.16 15:14:07.986  MODULE      ( INFO    ) : Getting CSVStudent UDM object by filter: username=luisa.stieg
21.07.16 15:14:07.987  MODULE      ( PROCESS ) : Creating CSVStudent(name='luisa.stieg', school='AlteSchule', dn='uid=luisa.stieg,cn=schueler,cn=users,ou=AlteSchule,dc=school,dc=local')
21.07.16 15:14:07.987  ADMIN       ( INFO    ) : reset options to default by _define_options
21.07.16 15:14:07.987  ADMIN       ( INFO    ) : modules/__init__.py _define_options: reset to default options
21.07.16 15:14:07.993  MODULE      ( INFO    ) : No password given. Generating random one
21.07.16 15:14:08.013  MODULE      ( INFO    ) : Getting SchoolClass UDM object: No DN! 
21.07.16 15:14:08.014  MODULE      ( PROCESS ) : Creating SchoolClass(name='AlteSchule-', school='AlteSchule', dn='cn=AlteSchule-,cn=klassen,cn=schueler,cn=groups,ou=AlteSchule,dc=school,dc=local')
21.07.16 15:14:08.014  MODULE      ( WARN    ) : Something went wrong. Traceback (most recent call last): 
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolcsvimport/util.py", line 234, in commit 
    self.create(lo, validate=False)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 417, in create 
    success = self.create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 443, in create_without_hooks
    self.do_create(udm_obj, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 229, in do_create
    udm_obj['groups'] = self.groups_used(lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 451, in groups_used
    self.get_or_create_group_udm_object(group_dn, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 465, in get_or_create_group_udm_object
    group.create(lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 417, in create 
    success = self.create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 200, in create_without_hooks
    success = super(SchoolClass, self).create_without_hooks(lo, validate)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 430, in create_without_hooks
    raise ValidationError(self.errors.copy())
ValidationError: {'name': ['Value may not contain other than numbers, letters and dots!']}
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2019-02-05 21:20:23 CET
This issue has been filled against UCS@school 4.0. The maintenance with bug 
and security fixes for UCS@school 4.0 has ended on May 31, 2016.

Customers still on UCS 4.0 are encouraged to update to UCS 4.3 (or later). 
Please contact your partner or Univention for any questions.

If this issue still occurs in newer UCS versions, please use "Clone this bug"
or simply reopen the issue. In this case please provide detailed information on
how this issue is affecting you.
Comment 6 Jan-Luca Kiok univentionstaff 2023-06-23 13:15:26 CEST
This issue has been filed against UCS 4.4.

UCS 4.4 is out of maintenance and UCS components may have vastly changed in later releases. Thus, this issue is now being closed.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or reopen this issue. In this case please provide detailed information on how this issue is affecting you.