Changeset 7993 for main/waeup.kofa/trunk


Ignore:
Timestamp:
27 Mar 2012, 20:59:30 (13 years ago)
Author:
Henrik Bettermann
Message:

Use different clearance form field interfaces for undergraduate and postgraduate students.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r7878 r7993  
    4949from waeup.kofa.widgets.phonewidget import PhoneWidget
    5050from waeup.kofa.students.interfaces import (
    51     IStudentsContainer, IStudent, IStudentClearance,
     51    IStudentsContainer, IStudent,
     52    IUGStudentClearance,IPGStudentClearance,
    5253    IStudentPersonal, IStudentBase, IStudentStudyCourse,
    5354    IStudentAccommodation, IStudentStudyLevel,
     
    393394    grok.name('view_clearance')
    394395    grok.require('waeup.viewStudent')
    395     form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    396     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    397     pnav = 4
     396    pnav = 4
     397
     398    @property
     399    def form_fields(self):
     400        cm = getattr(self.context,'current_mode', None)
     401        if cm is not None and cm.startswith('pg'):
     402            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     403        else:
     404            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     405        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     406        return form_fields
    398407
    399408    @property
     
    408417    grok.name('clearance.pdf')
    409418    grok.require('waeup.viewStudent')
    410     form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    411     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    412419    prefix = 'form'
     420
     421    @property
     422    def form_fields(self):
     423        cm = getattr(self.context,'current_mode', None)
     424        if cm is not None and cm.startswith('pg'):
     425            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     426        else:
     427            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     428        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     429        return form_fields
    413430
    414431    @property
     
    440457    grok.require('waeup.manageStudent')
    441458    grok.template('clearanceeditpage')
    442     form_fields = grok.AutoFields(IStudentClearance)
    443459    label = _('Manage clearance data')
    444460    pnav = 4
    445     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     461
     462    @property
     463    def form_fields(self):
     464        cm = getattr(self.context,'current_mode', None)
     465        if cm is not None and cm.startswith('pg'):
     466            form_fields = grok.AutoFields(IPGStudentClearance)
     467        else:
     468            form_fields = grok.AutoFields(IUGStudentClearance)
     469        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     470        return form_fields
    446471
    447472    def update(self):
     
    15611586    grok.name('cedit')
    15621587    grok.require('waeup.handleStudent')
    1563     form_fields = grok.AutoFields(
    1564         IStudentClearance).omit('clearance_locked')
    15651588    label = _('Edit clearance data')
    1566     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     1589
     1590    @property
     1591    def form_fields(self):
     1592        cm = getattr(self.context,'current_mode', None)
     1593        if cm is not None and cm.startswith('pg'):
     1594            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     1595        else:
     1596            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     1597        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     1598        return form_fields
    15671599
    15681600    def update(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r7983 r7993  
    211211        )
    212212
    213 class IStudentClearance(IKofaObject):
    214     """Representation of student clearance data.
     213class IUGStudentClearance(IKofaObject):
     214    """Representation of undergraduate student clearance data.
    215215
    216216    """
     
    238238        )
    239239
     240class IPGStudentClearance(IUGStudentClearance):
     241    """Representation of postgraduate student clearance data.
     242
     243    """
     244    employer = schema.TextLine(
     245        title = _(u'Employer'),
     246        required = False,
     247        readonly = False,
     248        )
     249
    240250class IStudentPersonal(IKofaObject):
    241251    """Representation of student personal data.
     
    247257        )
    248258
    249 class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
     259class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,IStudentPersonal):
    250260    """Representation of a student.
    251261
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r7983 r7993  
    109109        self.student_path = self.container_path + '/' + self.student_id
    110110        self.manage_student_path = self.student_path + '/manage_base'
    111         self.clearance_student_path = self.student_path + '/view_clearance'
    112         self.personal_student_path = self.student_path + '/view_personal'
    113         self.edit_clearance_student_path = self.student_path + '/edit_clearance'
    114         self.edit_personal_student_path = self.student_path + '/edit_personal'
    115         self.studycourse_student_path = self.student_path + '/studycourse'
    116         self.payments_student_path = self.student_path + '/payments'
    117         self.acco_student_path = self.student_path + '/accommodation'
    118         self.history_student_path = self.student_path + '/history'
     111        self.clearance_path = self.student_path + '/view_clearance'
     112        self.personal_path = self.student_path + '/view_personal'
     113        self.edit_clearance_path = self.student_path + '/cedit'
     114        self.manage_clearance_path = self.student_path + '/edit_clearance'
     115        self.edit_personal_path = self.student_path + '/edit_personal'
     116        self.studycourse_path = self.student_path + '/studycourse'
     117        self.payments_path = self.student_path + '/payments'
     118        self.acco_path = self.student_path + '/accommodation'
     119        self.history_path = self.student_path + '/history'
    119120
    120121        # Create 5 access codes with prefix'PWD'
     
    399400        self.browser.getLink("Clearance Data").click()
    400401        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    401         self.assertEqual(self.browser.url, self.clearance_student_path)
     402        self.assertEqual(self.browser.url, self.clearance_path)
    402403        self.browser.getLink("Manage").click()
    403404        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    404         self.assertEqual(self.browser.url, self.edit_clearance_student_path)
     405        self.assertEqual(self.browser.url, self.manage_clearance_path)
    405406        self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'
    406407        self.browser.getControl("Save").click()
     
    411412        self.browser.getLink("Personal Data").click()
    412413        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    413         self.assertEqual(self.browser.url, self.personal_student_path)
     414        self.assertEqual(self.browser.url, self.personal_path)
    414415        self.browser.getLink("Edit").click()
    415416        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    416         self.assertEqual(self.browser.url, self.edit_personal_student_path)
     417        self.assertEqual(self.browser.url, self.edit_personal_path)
    417418        self.browser.getControl("Save").click()
    418419        self.assertMatches('...Form has been saved...',
     
    423424        self.browser.getLink("Payments").click()
    424425        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    425         self.assertEqual(self.browser.url, self.payments_student_path)
     426        self.assertEqual(self.browser.url, self.payments_path)
    426427        self.browser.open(self.student_path)
    427428        self.browser.getLink("Accommodation").click()
    428429        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    429         self.assertEqual(self.browser.url, self.acco_student_path)
     430        self.assertEqual(self.browser.url, self.acco_path)
    430431        self.browser.open(self.student_path)
    431432        self.browser.getLink("History").click()
    432433        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    433         self.assertEqual(self.browser.url, self.history_student_path)
     434        self.assertEqual(self.browser.url, self.history_path)
    434435        self.assertMatches('...Student admitted by Manager...',
    435436                           self.browser.contents)
     
    477478        # The image is stored even if form has errors
    478479        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    479         self.browser.open(self.edit_clearance_student_path)
     480        self.browser.open(self.manage_clearance_path)
    480481        # No birth certificate has been uploaded yet
    481482        # Browsing the link shows a placerholder image
     
    486487        # Create a pseudo image file and select it to be uploaded in form
    487488        # as birth certificate
    488         self.browser.open(self.edit_clearance_student_path)
     489        self.browser.open(self.manage_clearance_path)
    489490        pseudo_image = StringIO('I pretend to be a graphics file')
    490491        ctrl = self.browser.getControl(name='birthcertificateupload')
     
    514515        self.assertEqual(len(self.browser.contents), 31)
    515516        # Reuploading a file which is bigger than 150k will raise an error
    516         self.browser.open(self.edit_clearance_student_path)
     517        self.browser.open(self.manage_clearance_path)
    517518        photo_content = 'A' * 1024 * 151  # A string of 21 KB size
    518519        pseudo_image = StringIO(photo_content)
     
    551552            'birth_certificate deleted' in self.browser.contents)
    552553        # Managers can add and delete second file
    553         self.browser.open(self.edit_clearance_student_path)
     554        self.browser.open(self.manage_clearance_path)
    554555        pseudo_image = StringIO('I pretend to be a graphics file')
    555556        ctrl = self.browser.getControl(name='birthcertificateupload')
     
    609610        self.browser.getLink("Study Course").click()
    610611        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    611         self.assertEqual(self.browser.url, self.studycourse_student_path)
     612        self.assertEqual(self.browser.url, self.studycourse_path)
    612613        self.assertTrue('Undergraduate Full-Time' in self.browser.contents)
    613614        self.browser.getLink("Manage").click()
     
    840841            self.browser.contents)
    841842        # CO can view the student ...
    842         self.browser.open(self.clearance_student_path)
    843         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    844         self.assertEqual(self.browser.url, self.clearance_student_path)
     843        self.browser.open(self.clearance_path)
     844        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     845        self.assertEqual(self.browser.url, self.clearance_path)
    845846        # ... but not other students
    846847        other_student = Student()
     
    853854            Unauthorized, self.browser.open, other_student_path)
    854855        # Only in state clearance requested the CO does see the 'Clear' button
    855         self.browser.open(self.clearance_student_path)
     856        self.browser.open(self.clearance_path)
    856857        self.assertFalse('Clear student' in self.browser.contents)
    857858        IWorkflowInfo(self.student).fireTransition('request_clearance')
    858         self.browser.open(self.clearance_student_path)
     859        self.browser.open(self.clearance_path)
    859860        self.assertTrue('Clear student' in self.browser.contents)
    860861        self.browser.getLink("Clear student").click()
     
    869870        self.assertTrue('clearance started' in self.browser.contents)
    870871        IWorkflowInfo(self.student).fireTransition('request_clearance')
    871         self.browser.open(self.clearance_student_path)
     872        self.browser.open(self.clearance_path)
    872873        self.browser.getLink("Reject clearance").click()
    873874        self.assertTrue('Clearance request has been rejected'
     
    941942        self.student['studycourse'].addStudentStudyLevel(
    942943            cert,studylevel)
    943         L110_student_path = self.studycourse_student_path + '/110'
     944        L110_student_path = self.studycourse_path + '/110'
    944945        # Only in state courses registered and only if the current level
    945946        # corresponds with the name of the study level object
     
    958959        self.student['studycourse'].addStudentStudyLevel(
    959960            cert,studylevel2)
    960         L200_student_path = self.studycourse_student_path + '/200'
     961        L200_student_path = self.studycourse_path + '/200'
    961962        self.browser.open(L200_student_path)
    962963        self.assertFalse('Validate' in self.browser.contents)
     
    12201221        # if certain requirements are met
    12211222        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1222         self.browser.open(self.payments_student_path)
     1223        self.browser.open(self.payments_path)
    12231224        self.browser.getControl("Add online payment ticket").click()
    12241225        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    12401241        # The same payment (with same p_item, p_session and p_category)
    12411242        # can be initialized a second time if the former ticket is not yet paid.
    1242         self.browser.open(self.payments_student_path)
     1243        self.browser.open(self.payments_path)
    12431244        self.browser.getControl("Add online payment ticket").click()
    12441245        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    12611262        # Now the first ticket is paid and no more ticket of same type
    12621263        # (with same p_item, p_session and p_category) can be added
    1263         self.browser.open(self.payments_student_path)
     1264        self.browser.open(self.payments_path)
    12641265        self.browser.getControl("Add online payment ticket").click()
    12651266        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    12761277
    12771278        # Managers can remove online school fee payment tickets
    1278         self.browser.open(self.payments_student_path)
     1279        self.browser.open(self.payments_path)
    12791280        self.browser.getControl("Remove selected").click()
    12801281        self.assertMatches('...No payment selected...', self.browser.contents)
     
    12861287
    12871288        # Managers can add online clearance payment tickets
    1288         self.browser.open(self.payments_student_path + '/addop')
     1289        self.browser.open(self.payments_path + '/addop')
    12891290        self.browser.getControl(name="form.p_category").value = ['clearance']
    12901291        self.browser.getControl("Create ticket").click()
     
    13201321
    13211322        # Students can add online clearance payment tickets
    1322         self.browser.open(self.payments_student_path + '/addop')
     1323        self.browser.open(self.payments_path + '/addop')
    13231324        self.browser.getControl(name="form.p_category").value = ['clearance']
    13241325        self.browser.getControl("Create ticket").click()
     
    13751376
    13761377        # Students can add online school fee payment tickets
    1377         self.browser.open(self.payments_student_path)
     1378        self.browser.open(self.payments_path)
    13781379        self.browser.getControl("Add online payment ticket").click()
    13791380        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    13951396        # Students can remove only online payment tickets which have
    13961397        # not received a valid callback
    1397         self.browser.open(self.payments_student_path)
     1398        self.browser.open(self.payments_path)
    13981399        self.assertRaises(
    13991400            LookupError, self.browser.getControl, name='val_id')
    1400         self.browser.open(self.payments_student_path + '/addop')
     1401        self.browser.open(self.payments_path + '/addop')
    14011402        self.browser.getControl(name="form.p_category").value = ['gown']
    14021403        self.browser.getControl("Create ticket").click()
    1403         self.browser.open(self.payments_student_path)
     1404        self.browser.open(self.payments_path)
    14041405        ctrl = self.browser.getControl(name='val_id')
    14051406        value = ctrl.options[0]
     
    14111412        IWorkflowInfo(self.student).fireTransition('request_clearance')
    14121413        IWorkflowInfo(self.student).fireTransition('clear')
    1413         self.browser.open(self.studycourse_student_path)
     1414        self.browser.open(self.studycourse_path)
    14141415        self.browser.getLink('Start course registration').click()
    14151416        pin = self.app['accesscodes']['SFE-0'].keys()[0]
     
    14281429        # callback view (see test_manage_payments)
    14291430        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1430         self.browser.open(self.payments_student_path)
     1431        self.browser.open(self.payments_path)
    14311432        self.browser.getControl("Add online payment ticket").click()
    14321433        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
     
    14521453        sfeseries, sfenumber = parts
    14531454        # Managers can use HOS code and book a bed space with it
    1454         self.browser.open(self.acco_student_path)
     1455        self.browser.open(self.acco_path)
    14551456        self.browser.getLink("Book accommodation").click()
    14561457        self.assertMatches('...You are in the wrong...',
     
    14811482            self.browser.contents)
    14821483        # The bed ticket displays the data correctly
    1483         self.browser.open(self.acco_student_path + '/2004')
     1484        self.browser.open(self.acco_path + '/2004')
    14841485        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
    14851486                           self.browser.contents)
     
    15291530        self.assertMatches(old_owner, self.student_id)
    15301531        bed2.owner = self.student_id
    1531         self.browser.open(self.acco_student_path + '/2004')
     1532        self.browser.open(self.acco_path + '/2004')
    15321533        self.assertMatches(
    15331534            "...booking cancelled...", self.browser.contents)
     
    15451546            "... Hall 1, Block A, Room 101, Bed B...", self.browser.contents)
    15461547          # Managers can delete bed tickets
    1547         self.browser.open(self.acco_student_path)
     1548        self.browser.open(self.acco_path)
    15481549        ctrl = self.browser.getControl(name='val_id')
    15491550        value = ctrl.options[0]
     
    15821583
    15831584        # Students can use HOS code and book a bed space with it
    1584         self.browser.open(self.acco_student_path)
     1585        self.browser.open(self.acco_path)
    15851586        self.browser.getLink("Book accommodation").click()
    15861587        self.assertMatches('...You are in the wrong...',
     
    16171618
    16181619        # The bed ticket displays the data correctly
    1619         self.browser.open(self.acco_student_path + '/2004')
     1620        self.browser.open(self.acco_path + '/2004')
    16201621        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
    16211622                           self.browser.contents)
     
    16311632        # Students can't relocate themselves
    16321633        self.assertFalse('Relocate' in self.browser.contents)
    1633         relocate_path = self.acco_student_path + '/2004/relocate'
     1634        relocate_path = self.acco_path + '/2004/relocate'
    16341635        self.assertRaises(
    16351636            Unauthorized, self.browser.open, relocate_path)
    16361637
    16371638        # Students can't the Remove button and check boxes
    1638         self.browser.open(self.acco_student_path)
     1639        self.browser.open(self.acco_path)
    16391640        self.assertFalse('Remove' in self.browser.contents)
    16401641        self.assertFalse('val_id' in self.browser.contents)
     
    16641665        results = cat.searchResults(student_id=(None, None))
    16651666        self.assertEqual(len(results),1)
     1667
     1668    def test_change_current_mode(self):
     1669        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1670        self.browser.open(self.clearance_path)
     1671        self.assertFalse('Employer' in self.browser.contents)
     1672        self.browser.open(self.manage_clearance_path)
     1673        self.assertFalse('Employer' in self.browser.contents)
     1674        self.student.clearance_locked = False
     1675        self.browser.open(self.edit_clearance_path)
     1676        self.assertFalse('Employer' in self.browser.contents)
     1677        # Now we change the study mode of the certificate and a different
     1678        # interface is used by clearance views
     1679        self.certificate.study_mode = 'pg_ft'
     1680        self.browser.open(self.clearance_path)
     1681        self.assertTrue('Employer' in self.browser.contents)
     1682        self.browser.open(self.manage_clearance_path)
     1683        self.assertTrue('Employer' in self.browser.contents)
     1684        self.browser.open(self.edit_clearance_path)
     1685        self.assertTrue('Employer' in self.browser.contents)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r7973 r7993  
    6666        self.assertEqual(
    6767            result,
    68             'adm_code,clearance_locked,clr_code,date_of_birth,email,'
     68            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
    6969            'firstname,lastname,matric_number,middlename,nationality,'
    7070            'perm_address,phone,reg_number,sex,student_id\r\n'
    7171
    72             'my adm code,0,my clr code,1981-02-04#,anna@sample.com,Anna,'
     72            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,Anna,'
    7373            'Tester,M123456,M.,nigeria,"Studentroad 21\nLagos 123456\n",'
    7474            '+234-123-12345,123456,f,A111111\r\n'
     
    8585        self.assertEqual(
    8686            result,
    87             'adm_code,clearance_locked,clr_code,date_of_birth,email,'
     87            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
    8888            'firstname,lastname,matric_number,middlename,nationality,'
    8989            'perm_address,phone,reg_number,sex,student_id\r\n'
    9090
    91             'my adm code,0,my clr code,1981-02-04#,anna@sample.com,Anna,'
     91            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,Anna,'
    9292            'Tester,M123456,M.,nigeria,"Studentroad 21\nLagos 123456\n",'
    9393            '+234-123-12345,123456,f,A111111\r\n'
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r7927 r7993  
    380380
    381381    VERDICTS_DICT = {
    382         '0': 'not yet',
     382        '0': _('(not yet)'),
    383383        'A': 'Successful student',
    384384        'B': 'Student with carryover courses',
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r7888 r7993  
    4141    AccommodationManageFormPage, BedTicketDisplayFormPage,)
    4242from waeup.kofa.students.interfaces import (
    43     IStudentsContainer, IStudent, IStudentClearance,
     43    IStudentsContainer, IStudent,
    4444    IStudentStudyCourse, IStudentAccommodation, IStudentStudyLevel,
    4545    ICourseTicket, IStudentOnlinePayment, IBedTicket,
     
    600600    """
    601601    grok.baseclass()
    602     grok.context(IStudentClearance)
     602    grok.context(IStudent)
    603603    grok.viewletmanager(FileManager)
    604604    grok.view(StudentClearanceDisplayFormPage)
     
    623623    """
    624624    grok.baseclass()
    625     grok.context(IStudentClearance)
     625    grok.context(IStudent)
    626626    grok.viewletmanager(FileManager)
    627627    grok.view(StudentClearanceManageFormPage)
     
    744744    grok.baseclass()
    745745    grok.name('none.jpg')
    746     grok.context(IStudentClearance)
     746    grok.context(IStudent)
    747747    grok.require('waeup.viewStudent')
    748748    download_name = u'none.jpg'
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r7969 r7993  
    122122        'ug_ft': 'Undergraduate Full-Time',
    123123        'ug_pt': 'Undergraduate Part-Time',
     124        'pg_ft': 'Postgraduate Full-Time',
     125        'pg_pt': 'Postgraduate Part-Time',
    124126        }
    125127
Note: See TracChangeset for help on using the changeset viewer.