Ignore:
Timestamp:
28 Mar 2012, 06:23:25 (13 years ago)
Author:
Henrik Bettermann
Message:

Adapt changes recently made in the base package.

Location:
main/waeup.custom/trunk/src/waeup/custom/students
Files:
5 edited

Legend:

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

    r7890 r7995  
    2424    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
    2525    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
    26     StudentClearanceDisplayFormPage)
     26    StudentClearanceDisplayFormPage,
     27    ExportPDFClearanceSlipPage)
    2728from waeup.kofa.students.viewlets import RequestCallbackActionButton
    2829from waeup.custom.students.interfaces import (
    29     IStudent, IStudentPersonal, IStudentClearance, IStudentClearanceEdit,
     30    IStudent, IStudentPersonal,
     31    IUGStudentClearance,IPGStudentClearance,
    3032    )
    3133from waeup.custom.interfaces import MessageFactory as _
     
    4850    """
    4951    grok.context(IStudent)
    50     form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    51     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     52
     53    @property
     54    def form_fields(self):
     55        cm = getattr(self.context,'current_mode', None)
     56        if cm is not None and cm.startswith('pg'):
     57            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     58        else:
     59            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     60        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     61        return form_fields
     62
     63class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
     64    """Deliver a PDF slip of the context.
     65    """
     66    grok.context(IStudent)
     67
     68    @property
     69    def form_fields(self):
     70        cm = getattr(self.context,'current_mode', None)
     71        if cm is not None and cm.startswith('pg'):
     72            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     73        else:
     74            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     75        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     76        return form_fields
    5277
    5378class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
     
    5580    """
    5681    grok.context(IStudent)
    57     form_fields = grok.AutoFields(IStudentClearance)
    58     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     82
     83    @property
     84    def form_fields(self):
     85        cm = getattr(self.context,'current_mode', None)
     86        if cm is not None and cm.startswith('pg'):
     87            form_fields = grok.AutoFields(IPGStudentClearance)
     88        else:
     89            form_fields = grok.AutoFields(IUGStudentClearance)
     90        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     91        return form_fields
    5992
    6093class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
     
    6295    """
    6396    grok.context(IStudent)
    64     form_fields = grok.AutoFields(
    65         IStudentClearanceEdit).omit('clearance_locked')
    66     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     97
     98    @property
     99    def form_fields(self):
     100        cm = getattr(self.context,'current_mode', None)
     101        if cm is not None and cm.startswith('pg'):
     102            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     103        else:
     104            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     105        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     106        return form_fields
    67107
    68108class RequestCallbackActionButton(RequestCallbackActionButton):
  • main/waeup.custom/trunk/src/waeup/custom/students/interfaces.py

    r7822 r7995  
    2020from waeup.kofa.interfaces import SimpleKofaVocabulary
    2121from waeup.kofa.students.interfaces import (
    22     IStudentBase,IStudentClearance,IStudentPersonal,IStudentNavigation,
     22    IStudentBase,IUGStudentClearance,IPGStudentClearance,
     23    IStudentPersonal,IStudentNavigation,
    2324    )
    2425from waeup.kofa.students.vocabularies import (
     
    5152        )
    5253
    53 class IStudentClearance(IStudentClearance):
    54     """Representation of student clearance data.
     54class IUGStudentClearance(IUGStudentClearance):
     55    """Representation of ug student clearance data.
    5556
    5657    """
     
    7374        )
    7475
    75 class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
     76class IPGStudentClearance(IUGStudentClearance):
     77    """Representation of pg student clearance data.
     78
     79    """
     80
     81class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,IStudentPersonal):
    7682    """Representation of a student.
    7783
    7884    """
    79 
    80 # Interfaces for students only
    81 
    82 class IStudentClearanceEdit(IStudentClearance):
    83     """Interface needed for restricted editing of student clearance data.
    84 
    85     """
    86 
    87 class IStudentPersonalEdit(IStudentPersonal):
    88     """Interface needed for restricted editing of student personal data.
    89 
    90     """
  • main/waeup.custom/trunk/src/waeup/custom/students/student.py

    r7822 r7995  
    2323from waeup.kofa.utils.helpers import attrs_to_fields
    2424from waeup.kofa.students.student import Student, StudentFactory
    25 from waeup.custom.students.interfaces import (
    26     IStudent, IStudentNavigation,
    27     IStudentPersonalEdit, IStudentClearanceEdit)
     25from waeup.custom.students.interfaces import IStudent, IStudentNavigation
    2826
    2927
     
    3230    owned by students.
    3331    """
    34     grok.implements(IStudent, IStudentNavigation,
    35         IStudentPersonalEdit, IStudentClearanceEdit)
     32    grok.implements(IStudent, IStudentNavigation)
    3633    grok.provides(IStudent)
    3734
  • main/waeup.custom/trunk/src/waeup/custom/students/tests/sample_student_data.csv

    r7894 r7995  
    1 firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,lga,nationality
    2 Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234
    3 Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234
    4 Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234
     1firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex
     2Aaren,Pieri,1,,100000,aa@aa.ng,1234,m
     3Aaren,Finau,2,,100001,aa@aa.ng,1234,m
     4Aaren,Berson,3,,100002,aa@aa.ng,1234,m
  • main/waeup.custom/trunk/src/waeup/custom/students/tests/test_browser.py

    r7934 r7995  
    7272
    7373    def test_import(self):
    74         # We added empty columns 'nationality' and 'lga' to the import file.
    75         # The original processor will fail because these fields are required
     74        # We have an empty column 'date_of_birth' in the import file.
     75        # The original processor will fail because 'date_of_birth' is required
    7676        # in the base package.
    7777        num, num_warns, fin_file, fail_file = self.processor_base.doImport(
     
    7979        self.assertEqual(num_warns,3)
    8080        assert len(self.app['students'].keys()) == 0
    81         # The customized processor does not complain since both fields are
     81        # The customized processor does not complain since 'date_of_birth' is
    8282        # not required in the custom package.
    8383        num, num_warns, fin_file, fail_file = self.processor.doImport(
    8484            self.csv_file, STUDENT_HEADER_FIELDS)
     85        #print open(fail_file).read()
    8586        self.assertEqual(num_warns,0)
    8687        assert len(self.app['students'].keys()) == 3
     
    103104        # Managers can add online payment tickets
    104105        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    105         self.browser.open(self.payments_student_path)
     106        self.browser.open(self.payments_path)
    106107        self.browser.getControl("Add online payment ticket").click()
    107108        self.browser.getControl("Create ticket").click()
     
    109110                           self.browser.contents)
    110111        IWorkflowState(self.student).setState('cleared')
    111         self.browser.open(self.payments_student_path + '/addop')
     112        self.browser.open(self.payments_path + '/addop')
    112113        self.browser.getControl("Create ticket").click()
    113114        self.assertMatches('...ticket created...',
     
    122123        ticket.p_state = 'paid'
    123124        IWorkflowState(self.student).setState('returning')
    124         self.browser.open(self.payments_student_path + '/addop')
     125        self.browser.open(self.payments_path + '/addop')
    125126        self.browser.getControl("Create ticket").click()
    126127        self.assertMatches('...This type of payment has already been made...',
     
    130131        for payment in keys:
    131132            del self.student['payments'][payment]
    132         self.browser.open(self.payments_student_path + '/addop')
     133        self.browser.open(self.payments_path + '/addop')
    133134        self.browser.getControl("Create ticket").click()
    134135        self.assertMatches('...ticket created...',
    135136                           self.browser.contents)
    136         self.browser.open(self.payments_student_path + '/addop')
     137        self.browser.open(self.payments_path + '/addop')
    137138        self.browser.getControl(name="form.p_category").value = ['gown']
    138139        self.browser.getControl("Create ticket").click()
    139         self.browser.open(self.payments_student_path + '/addop')
     140        self.browser.open(self.payments_path + '/addop')
    140141        self.browser.getControl(name="form.p_category").value = ['transfer']
    141142        self.browser.getControl("Create ticket").click()
    142         self.browser.open(self.payments_student_path + '/addop')
     143        self.browser.open(self.payments_path + '/addop')
    143144        self.browser.getControl(
    144145            name="form.p_category").value = ['bed_allocation']
    145146        self.browser.getControl("Create ticket").click()
    146         self.browser.open(self.payments_student_path + '/addop')
     147        self.browser.open(self.payments_path + '/addop')
    147148        self.browser.getControl(
    148149            name="form.p_category").value = ['hostel_maintenance']
    149150        self.browser.getControl("Create ticket").click()
    150         self.browser.open(self.payments_student_path + '/addop')
     151        self.browser.open(self.payments_path + '/addop')
    151152        self.browser.getControl(name="form.p_category").value = ['clearance']
    152153        self.browser.getControl("Create ticket").click()
    153154        self.certificate.study_mode = 'ug_pt'
    154         self.browser.open(self.payments_student_path + '/addop')
     155        self.browser.open(self.payments_path + '/addop')
    155156        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    156157        self.browser.getControl("Create ticket").click()
     
    161162        # be shown
    162163        del self.app['configuration']['2004']
    163         self.browser.open(self.payments_student_path)
     164        self.browser.open(self.payments_path)
    164165        self.browser.getControl("Add online payment ticket").click()
    165166        self.browser.getControl("Create ticket").click()
    166167        self.assertMatches('...Session configuration object is not...',
    167168                           self.browser.contents)
    168 
    169 
Note: See TracChangeset for help on using the changeset viewer.