## ## interfaces.py from zope.interface import Interface, Attribute, invariant from zope.interface.exceptions import Invalid from zope import schema from waeup.sirp.interfaces import IWAeUPObject from waeup.sirp.university.vocabularies import study_modes from waeup.sirp.students.vocabularies import ( year_range, lgas_vocab, CertificateSource, GenderSource, academic_sessions_vocab, verdicts, StudyLevelSource, ) class IStudentsContainer(IWAeUPObject): """An students container contains university students. """ def addStudent(student): """Add an IStudent object and subcontainers. """ def archive(id=None): """Create on-dist archive of students. If id is `None`, all students are archived. If id contains a single id string, only the respective students are archived. If id contains a list of id strings all of the respective students types are saved to disk. """ def clear(id=None, archive=True): """Remove students of type given by 'id'. Optionally archive the students. If id is `None`, all students are archived. If id contains a single id string, only the respective students are archived. If id contains a list of id strings all of the respective student types are saved to disk. If `archive` is ``False`` none of the archive-handling is done and respective students are simply removed from the database. """ class IStudentNavigation(IWAeUPObject): """Interface needed for student navigation. """ def getStudent(): """Return student object. """ class IStudentPasswordSetting(IWAeUPObject): """Data needed for password setting. """ name = schema.TextLine( title = u'Full Name', default = u'Nobody', required = True, readonly = True ) password = schema.Password( title = u'New password', required = False, ) password_repeat = schema.Password( title = u'Retype new password', required = False, ) @invariant def passwords_match(obj): if obj.password == obj.password_repeat: return raise Invalid('passwords do not match') class IStudentBase(IWAeUPObject): """Representation of student base data. """ history = Attribute('Object history, a list of messages.') state = Attribute('Returns the registration state of a student') password = Attribute('Encrypted password of a student') def loggerInfo(ob_class, comment): """Adds an INFO message to the log file """ student_id = schema.TextLine( title = u'Student ID', required = True, ) name = schema.TextLine( title = u'Full Name', default = u'Nobody', required = True, ) reg_number = schema.TextLine( title = u'Registration Number', default = u'', required = True, readonly = False, ) matric_number = schema.TextLine( title = u'Matriculation Number', default = u'', required = False, readonly = False, ) adm_code = schema.TextLine( title = u'PWD Access Code', default = u'', required = False, readonly = True, ) class IStudentClearance(IWAeUPObject): """Representation of student clearance data. """ date_of_birth = schema.Date( title = u'Date of Birth', required = True, ) clearance_locked = schema.Bool( title = u'Clearance form locked', default = False, ) clr_code = schema.TextLine( title = u'CLR Access Code', default = u'', required = False, readonly = True, ) class IStudentPersonal(IWAeUPObject): """Representation of student personal data. """ perm_address = schema.Text( title = u'Permanent Address', required = False, ) class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): """Representation of a student. """ class IStudentStudyCourse(IWAeUPObject): """A container for student study levels. """ certificate = schema.Choice( title = u'Certificate', source = CertificateSource(), default = None, required = True, ) current_session = schema.Choice( title = u'Current Session', source = academic_sessions_vocab, default = None, required = True, ) current_level = schema.Choice( title = u'Current Level', source = StudyLevelSource(), default = None, required = False, ) current_verdict = schema.Choice( title = u'Current Verdict', source = verdicts, default = None, required = False, ) previous_verdict = schema.Choice( title = u'Previous Verdict', source = verdicts, default = None, required = False, ) class IStudentAccommodation(IWAeUPObject): """A container for student accommodation objects. """ class IStudentPayments(IWAeUPObject): """A container for student payment objects. """ # Interfaces for students only class IStudentClearanceEdit(IStudentClearance): """Interface needed for restricted editing of student clearance data. """ class IStudentPersonalEdit(IStudentPersonal): """Interface needed for restricted editing of student personal data. """