## ## interfaces.py from zope.interface import Attribute, invariant from zope.interface.exceptions import Invalid from zope import schema from waeup.sirp.interfaces import IWAeUPObject from waeup.sirp.schema import TextLineChoice from waeup.sirp.university.vocabularies import CourseSource from waeup.sirp.students.vocabularies import ( CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source, ) 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 = TextLineChoice( title = u'Registration Number', #default = u'', required = True, readonly = False, source = contextual_reg_num_source, ) matric_number = TextLineChoice( title = u'Matriculation Number', #default = u'', required = False, readonly = False, source = contextual_mat_num_source, ) 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 IStudentStudyLevel(IWAeUPObject): """A container for course tickets. """ level = Attribute('The level code') validation_date = Attribute('The date of validation') validated_by = Attribute('User Id of course adviser') level_session = schema.Choice( title = u'Session', source = academic_sessions_vocab, default = None, required = True, ) level_verdict = schema.Choice( title = u'Verdict', source = verdicts, default = None, required = False, ) class ICourseTicket(IWAeUPObject): """A course ticket. """ code = Attribute('code of the original course') title = Attribute('title of the original course') credits = Attribute('credits of the original course') passmark = Attribute('passmark of the original course') semester = Attribute('semester of the original course') faculty = Attribute('faculty of the original course') department = Attribute('department of the original course') automatic = Attribute('automatical creation of ticket') core_or_elective = schema.Bool( title = u'Mandatory', default = False, required = False, readonly = False, ) score = schema.Int( title = u'Score', default = 0, required = False, readonly = False, ) class ICourseTicketAdd(ICourseTicket): """An interface for adding course tickets """ course = schema.Choice( title = u'Course', source = CourseSource(), readonly = 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. """