Ignore:
Timestamp:
6 Nov 2012, 20:46:03 (12 years ago)
Author:
Henrik Bettermann
Message:

Adjust to previous revision and add more tests.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/browser.py

    r9562 r9564  
    3939from kofacustom.nigeria.students.interfaces import (
    4040    INigeriaStudentBase, INigeriaStudent, INigeriaStudentPersonal,
     41    INigeriaStudentPersonalEdit,
    4142    INigeriaUGStudentClearance,INigeriaPGStudentClearance,
    4243    INigeriaStudentOnlinePayment
     
    8384    """ Page to edit personal data
    8485    """
    85     form_fields = grok.AutoFields(INigeriaStudentPersonal).omit('personal_updated')
     86    form_fields = grok.AutoFields(INigeriaStudentPersonalEdit).omit('personal_updated')
    8687
    8788class NigeriaStudentPersonalManageFormPage(StudentPersonalManageFormPage):
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/interfaces.py

    r9552 r9564  
    5858    'reg_number'].order
    5959
     60
     61class INigeriaUGStudentClearance(IUGStudentClearance):
     62    """Representation of ug student clearance data.
     63
     64    """
     65    officer_comment = schema.Text(
     66        title = _(u"Officer's Comment"),
     67        required = False,
     68        )
     69
     70    clearance_locked = schema.Bool(
     71        title = _(u'Clearance form locked'),
     72        default = False,
     73        required = False,
     74        )
     75
     76    clr_code = schema.TextLine(
     77        title = _(u'CLR Activation Code'),
     78        required = False,
     79        readonly = False,
     80        )
     81
     82    date_of_birth = FormattedDate(
     83        title = _(u'Date of Birth'),
     84        required = False,
     85        show_year = True,
     86        )
     87
     88    nationality = schema.Choice(
     89        source = nats_vocab,
     90        title = _(u'Nationality'),
     91        required = True,
     92        )
     93
     94    lga = schema.Choice(
     95        source = LGASource(),
     96        title = _(u'State/LGA (Nigerians only)'),
     97        required = False,
     98        )
     99
     100    def_adm = schema.Bool(
     101        title = _(u'Deferent of Admission'),
     102        required = False,
     103        readonly = False,
     104        )
     105
     106    fst_sit_fname = schema.TextLine(
     107        title = _(u'Full Name'),
     108        required = False,
     109        readonly = False,
     110        )
     111    fst_sit_no = schema.TextLine(
     112        title = _(u'Exam Number'),
     113        required = False,
     114        readonly = False,
     115        )
     116
     117    fst_sit_date = FormattedDate(
     118        title = _(u'Exam Date'),
     119        required = False,
     120        readonly = False,
     121        show_year = True,
     122        )
     123
     124    fst_sit_type = schema.Choice(
     125        title = _(u'Exam Type'),
     126        required = False,
     127        readonly = False,
     128        vocabulary = exam_types,
     129        )
     130
     131    fst_sit_results = schema.List(
     132        title = _(u'Exam Results'),
     133        value_type = ResultEntryField(),
     134        required = False,
     135        readonly = False,
     136        default = [],
     137        )
     138
     139    scd_sit_fname = schema.TextLine(
     140        title = _(u'Full Name'),
     141        required = False,
     142        readonly = False,
     143        )
     144    scd_sit_no = schema.TextLine(
     145        title = _(u'Exam Number'),
     146        required = False,
     147        readonly = False,
     148        )
     149
     150    scd_sit_date = FormattedDate(
     151        title = _(u'Exam Date'),
     152        required = False,
     153        readonly = False,
     154        show_year = True,
     155        )
     156
     157    scd_sit_type = schema.Choice(
     158        title = _(u'Exam Type'),
     159        required = False,
     160        readonly = False,
     161        vocabulary = exam_types,
     162        )
     163
     164    scd_sit_results = schema.List(
     165        title = _(u'Exam Results'),
     166        value_type = ResultEntryField(),
     167        required = False,
     168        readonly = False,
     169        default = [],
     170        )
     171
     172    alr_fname = schema.TextLine(
     173        title = _(u'Full Name'),
     174        required = False,
     175        readonly = False,
     176        )
     177    alr_no = schema.TextLine(
     178        title = _(u'Exam Number'),
     179        required = False,
     180        readonly = False,
     181        )
     182
     183    alr_date = FormattedDate(
     184        title = _(u'Exam Date'),
     185        required = False,
     186        readonly = False,
     187        show_year = True,
     188        )
     189
     190    alr_results = schema.List(
     191        title = _(u'Exam Results'),
     192        value_type = ResultEntryField(),
     193        required = False,
     194        readonly = False,
     195        default = [],
     196        )
     197
     198    hq_type = schema.Choice(
     199        title = _(u'Qualification Obtained'),
     200        required = False,
     201        readonly = False,
     202        vocabulary = high_qual,
     203        )
     204
     205    hq_fname = schema.TextLine(
     206        title = _(u'Full Name'),
     207        required = False,
     208        readonly = False,
     209        )
     210
     211    hq_matric_no = schema.TextLine(
     212        title = _(u'Former Matric Number'),
     213        required = False,
     214        readonly = False,
     215        )
     216
     217    hq_degree = schema.Choice(
     218        title = _(u'Class of Degree'),
     219        required = False,
     220        readonly = False,
     221        vocabulary = high_grade,
     222        )
     223
     224    hq_school = schema.TextLine(
     225        title = _(u'Institution Attended'),
     226        required = False,
     227        readonly = False,
     228        )
     229
     230    hq_session = schema.TextLine(
     231        title = _(u'Years Attended'),
     232        required = False,
     233        readonly = False,
     234        )
     235
     236    hq_disc = schema.TextLine(
     237        title = _(u'Discipline'),
     238        required = False,
     239        readonly = False,
     240        )
     241
     242
     243class INigeriaPGStudentClearance(INigeriaUGStudentClearance):
     244    """Representation of pg student clearance data.
     245
     246    """
     247
     248    hq2_type = schema.Choice(
     249        title = _(u'Qualification Obtained'),
     250        required = False,
     251        readonly = False,
     252        vocabulary = high_qual,
     253        )
     254
     255    hq2_matric_no = schema.TextLine(
     256        title = _(u'Former Matric Number'),
     257        required = False,
     258        readonly = False,
     259        )
     260
     261    hq2_degree = schema.Choice(
     262        title = _(u'Class of Degree'),
     263        required = False,
     264        readonly = False,
     265        vocabulary = high_grade,
     266        )
     267
     268    hq2_school = schema.TextLine(
     269        title = _(u'Institution Attended'),
     270        required = False,
     271        readonly = False,
     272        )
     273
     274    hq2_session = schema.TextLine(
     275        title = _(u'Years Attended'),
     276        required = False,
     277        readonly = False,
     278        )
     279
     280    hq2_disc = schema.TextLine(
     281        title = _(u'Discipline'),
     282        required = False,
     283        readonly = False,
     284        )
     285
     286    nysc_year = schema.Int(
     287        title = _(u'Nysc Year'),
     288        required = False,
     289        readonly = False,
     290        )
     291
     292    nysc_location = schema.TextLine(
     293        title = _(u'Nysc Location'),
     294        required = False,
     295        )
     296
     297    nysc_lga = schema.Choice(
     298        source = LGASource(),
     299        title = _(u'Nysc LGA'),
     300        required = False,
     301        )
     302
     303    employer = schema.TextLine(
     304        title = _(u'Employer'),
     305        required = False,
     306        readonly = False,
     307        )
     308
     309    emp_position = schema.TextLine(
     310        title = _(u'Employer Position'),
     311        required = False,
     312        readonly = False,
     313        )
     314
     315    emp_start = FormattedDate(
     316        title = _(u'Start Date'),
     317        required = False,
     318        readonly = False,
     319        show_year = True,
     320        )
     321
     322    emp_end = FormattedDate(
     323        title = _(u'End Date'),
     324        required = False,
     325        readonly = False,
     326        show_year = True,
     327        )
     328
     329    emp_reason = schema.TextLine(
     330        title = _(u'Reason for Leaving'),
     331        required = False,
     332        readonly = False,
     333        )
     334
     335    employer2 = schema.TextLine(
     336        title = _(u'2nd Employer'),
     337        required = False,
     338        readonly = False,
     339        )
     340
     341    emp2_position = schema.TextLine(
     342        title = _(u'2nd Employer Position'),
     343        required = False,
     344        readonly = False,
     345        )
     346
     347    emp2_start = FormattedDate(
     348        title = _(u'Start Date'),
     349        required = False,
     350        readonly = False,
     351        show_year = True,
     352        )
     353    emp2_end = FormattedDate(
     354        title = _(u'End Date'),
     355        required = False,
     356        readonly = False,
     357        show_year = True,
     358        )
     359
     360    emp2_reason = schema.TextLine(
     361        title = _(u'Reason for Leaving'),
     362        required = False,
     363        readonly = False,
     364        )
     365
     366    former_matric = schema.TextLine(
     367        title = _(u'If yes, matric number'),
     368        required = False,
     369        readonly = False,
     370        )
     371
    60372class INigeriaStudentPersonal(IStudentPersonal):
    61373    """Student personal data.
     
    64376
    65377    is_foreigner = Attribute('True if student is non-Nigerian')
     378
     379    next_kin_name = schema.TextLine(
     380        title = _(u'Next of Kin Name'),
     381        required = False,
     382        readonly = False,
     383        )
     384
     385    next_kin_relation = schema.TextLine(
     386        title = _(u'Next of Kin Relationship'),
     387        required = False,
     388        readonly = False,
     389        )
     390
     391    next_kin_address = schema.Text(
     392        title = _(u'Next of Kin Address'),
     393        required = False,
     394        readonly = False,
     395        description = _(u'Please provide email address and/or phone number.'),
     396        )
    66397
    67398    marit_stat = schema.Choice(
     
    85416        )
    86417
    87     next_kin_name = schema.TextLine(
    88         title = _(u'Next of Kin Name'),
    89         required = False,
    90         readonly = False,
    91         )
    92 
    93     next_kin_relation = schema.TextLine(
    94         title = _(u'Next of Kin Relationship'),
    95         required = False,
    96         readonly = False,
    97         )
    98 
    99     next_kin_address = schema.Text(
    100         title = _(u'Next of Kin Address'),
    101         required = False,
    102         readonly = False,
    103         description = _(u'Please provide email address and/or phone number.'),
    104         )
    105 
    106418    disabled = schema.Bool(
    107419        title = u'Disabled',
     
    110422        )
    111423
    112 class INigeriaUGStudentClearance(IUGStudentClearance):
    113     """Representation of ug student clearance data.
    114 
    115     """
    116     officer_comment = schema.Text(
    117         title = _(u"Officer's Comment"),
    118         required = False,
    119         )
    120 
    121     clearance_locked = schema.Bool(
    122         title = _(u'Clearance form locked'),
    123         default = False,
    124         required = False,
    125         )
    126 
    127     clr_code = schema.TextLine(
    128         title = _(u'CLR Activation Code'),
    129         required = False,
    130         readonly = False,
    131         )
    132 
    133     date_of_birth = FormattedDate(
    134         title = _(u'Date of Birth'),
    135         required = False,
    136         show_year = True,
    137         )
    138 
    139     nationality = schema.Choice(
    140         source = nats_vocab,
    141         title = _(u'Nationality'),
    142         required = True,
    143         )
    144 
    145     lga = schema.Choice(
    146         source = LGASource(),
    147         title = _(u'State/LGA (Nigerians only)'),
    148         required = False,
    149         )
    150 
    151     def_adm = schema.Bool(
    152         title = _(u'Deferent of Admission'),
    153         required = False,
    154         readonly = False,
    155         )
    156 
    157     fst_sit_fname = schema.TextLine(
    158         title = _(u'Full Name'),
    159         required = False,
    160         readonly = False,
    161         )
    162     fst_sit_no = schema.TextLine(
    163         title = _(u'Exam Number'),
    164         required = False,
    165         readonly = False,
    166         )
    167 
    168     fst_sit_date = FormattedDate(
    169         title = _(u'Exam Date'),
    170         required = False,
    171         readonly = False,
    172         show_year = True,
    173         )
    174 
    175     fst_sit_type = schema.Choice(
    176         title = _(u'Exam Type'),
    177         required = False,
    178         readonly = False,
    179         vocabulary = exam_types,
    180         )
    181 
    182     fst_sit_results = schema.List(
    183         title = _(u'Exam Results'),
    184         value_type = ResultEntryField(),
    185         required = False,
    186         readonly = False,
    187         default = [],
    188         )
    189 
    190     scd_sit_fname = schema.TextLine(
    191         title = _(u'Full Name'),
    192         required = False,
    193         readonly = False,
    194         )
    195     scd_sit_no = schema.TextLine(
    196         title = _(u'Exam Number'),
    197         required = False,
    198         readonly = False,
    199         )
    200 
    201     scd_sit_date = FormattedDate(
    202         title = _(u'Exam Date'),
    203         required = False,
    204         readonly = False,
    205         show_year = True,
    206         )
    207 
    208     scd_sit_type = schema.Choice(
    209         title = _(u'Exam Type'),
    210         required = False,
    211         readonly = False,
    212         vocabulary = exam_types,
    213         )
    214 
    215     scd_sit_results = schema.List(
    216         title = _(u'Exam Results'),
    217         value_type = ResultEntryField(),
    218         required = False,
    219         readonly = False,
    220         default = [],
    221         )
    222 
    223     alr_fname = schema.TextLine(
    224         title = _(u'Full Name'),
    225         required = False,
    226         readonly = False,
    227         )
    228     alr_no = schema.TextLine(
    229         title = _(u'Exam Number'),
    230         required = False,
    231         readonly = False,
    232         )
    233 
    234     alr_date = FormattedDate(
    235         title = _(u'Exam Date'),
    236         required = False,
    237         readonly = False,
    238         show_year = True,
    239         )
    240 
    241     alr_results = schema.List(
    242         title = _(u'Exam Results'),
    243         value_type = ResultEntryField(),
    244         required = False,
    245         readonly = False,
    246         default = [],
    247         )
    248 
    249     hq_type = schema.Choice(
    250         title = _(u'Qualification Obtained'),
    251         required = False,
    252         readonly = False,
    253         vocabulary = high_qual,
    254         )
    255 
    256     hq_fname = schema.TextLine(
    257         title = _(u'Full Name'),
    258         required = False,
    259         readonly = False,
    260         )
    261 
    262     hq_matric_no = schema.TextLine(
    263         title = _(u'Former Matric Number'),
    264         required = False,
    265         readonly = False,
    266         )
    267 
    268     hq_degree = schema.Choice(
    269         title = _(u'Class of Degree'),
    270         required = False,
    271         readonly = False,
    272         vocabulary = high_grade,
    273         )
    274 
    275     hq_school = schema.TextLine(
    276         title = _(u'Institution Attended'),
    277         required = False,
    278         readonly = False,
    279         )
    280 
    281     hq_session = schema.TextLine(
    282         title = _(u'Years Attended'),
    283         required = False,
    284         readonly = False,
    285         )
    286 
    287     hq_disc = schema.TextLine(
    288         title = _(u'Discipline'),
    289         required = False,
    290         readonly = False,
    291         )
    292 
    293 
    294 class INigeriaPGStudentClearance(INigeriaUGStudentClearance):
    295     """Representation of pg student clearance data.
    296 
    297     """
    298 
    299     hq2_type = schema.Choice(
    300         title = _(u'Qualification Obtained'),
    301         required = False,
    302         readonly = False,
    303         vocabulary = high_qual,
    304         )
    305 
    306     hq2_matric_no = schema.TextLine(
    307         title = _(u'Former Matric Number'),
    308         required = False,
    309         readonly = False,
    310         )
    311 
    312     hq2_degree = schema.Choice(
    313         title = _(u'Class of Degree'),
    314         required = False,
    315         readonly = False,
    316         vocabulary = high_grade,
    317         )
    318 
    319     hq2_school = schema.TextLine(
    320         title = _(u'Institution Attended'),
    321         required = False,
    322         readonly = False,
    323         )
    324 
    325     hq2_session = schema.TextLine(
    326         title = _(u'Years Attended'),
    327         required = False,
    328         readonly = False,
    329         )
    330 
    331     hq2_disc = schema.TextLine(
    332         title = _(u'Discipline'),
    333         required = False,
    334         readonly = False,
    335         )
    336 
    337     nysc_year = schema.Int(
    338         title = _(u'Nysc Year'),
    339         required = False,
    340         readonly = False,
    341         )
    342 
    343     nysc_location = schema.TextLine(
    344         title = _(u'Nysc Location'),
    345         required = False,
    346         )
    347 
    348     nysc_lga = schema.Choice(
    349         source = LGASource(),
    350         title = _(u'Nysc LGA'),
    351         required = False,
    352         )
    353 
    354     employer = schema.TextLine(
    355         title = _(u'Employer'),
    356         required = False,
    357         readonly = False,
    358         )
    359 
    360     emp_position = schema.TextLine(
    361         title = _(u'Employer Position'),
    362         required = False,
    363         readonly = False,
    364         )
    365 
    366     emp_start = FormattedDate(
    367         title = _(u'Start Date'),
    368         required = False,
    369         readonly = False,
    370         show_year = True,
    371         )
    372 
    373     emp_end = FormattedDate(
    374         title = _(u'End Date'),
    375         required = False,
    376         readonly = False,
    377         show_year = True,
    378         )
    379 
    380     emp_reason = schema.TextLine(
    381         title = _(u'Reason for Leaving'),
    382         required = False,
    383         readonly = False,
    384         )
    385 
    386     employer2 = schema.TextLine(
    387         title = _(u'2nd Employer'),
    388         required = False,
    389         readonly = False,
    390         )
    391 
    392     emp2_position = schema.TextLine(
    393         title = _(u'2nd Employer Position'),
    394         required = False,
    395         readonly = False,
    396         )
    397 
    398     emp2_start = FormattedDate(
    399         title = _(u'Start Date'),
    400         required = False,
    401         readonly = False,
    402         show_year = True,
    403         )
    404     emp2_end = FormattedDate(
    405         title = _(u'End Date'),
    406         required = False,
    407         readonly = False,
    408         show_year = True,
    409         )
    410 
    411     emp2_reason = schema.TextLine(
    412         title = _(u'Reason for Leaving'),
    413         required = False,
    414         readonly = False,
    415         )
    416 
    417     former_matric = schema.TextLine(
    418         title = _(u'If yes, matric number'),
    419         required = False,
    420         readonly = False,
    421         )
    422 
    423424
    424425class INigeriaStudent(INigeriaStudentBase,INigeriaUGStudentClearance,
     
    428429    """
    429430
     431class INigeriaStudentPersonalEdit(INigeriaStudentPersonal):
     432    """Interface for editing personal data by students.
     433
     434    Here we can repeat the fields from IStudentPersonal and set the
     435    `required` if necessary.
     436    """
     437
     438    perm_address = schema.Text(
     439        title = _(u'Permanent Address'),
     440        required = True,
     441        )
     442
     443    next_kin_name = schema.TextLine(
     444        title = _(u'Next of Kin Name'),
     445        required = True,
     446        readonly = False,
     447        )
     448
     449    next_kin_relation = schema.TextLine(
     450        title = _(u'Next of Kin Relationship'),
     451        required = True,
     452        readonly = False,
     453        )
     454
     455    next_kin_address = schema.Text(
     456        title = _(u'Next of Kin Address'),
     457        required = True,
     458        readonly = False,
     459        description = _(u'Please provide email address and/or phone number.'),
     460        )
     461
     462INigeriaStudentPersonalEdit['next_kin_name'].order = INigeriaStudentPersonal[
     463    'next_kin_name'].order
     464INigeriaStudentPersonalEdit['next_kin_relation'].order = INigeriaStudentPersonal[
     465    'next_kin_relation'].order
     466INigeriaStudentPersonalEdit['next_kin_address'].order = INigeriaStudentPersonal[
     467    'next_kin_address'].order
     468INigeriaStudentPersonalEdit['perm_address'].order = INigeriaStudentPersonal[
     469    'perm_address'].order
     470
    430471class INigeriaStudentStudyCourse(IStudentStudyCourse):
    431472    """A container for student study levels.
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/student.py

    r8968 r9564  
    2323from waeup.kofa.utils.helpers import attrs_to_fields
    2424from waeup.kofa.students.student import Student, StudentFactory
    25 from kofacustom.nigeria.students.interfaces import INigeriaStudent, IStudentNavigation
     25from kofacustom.nigeria.students.interfaces import (
     26    INigeriaStudent, IStudentNavigation, INigeriaStudentPersonalEdit)
    2627
    2728
     
    3031    owned by students.
    3132    """
    32     grok.implements(INigeriaStudent, IStudentNavigation)
     33    grok.implements(
     34        INigeriaStudent, INigeriaStudentPersonalEdit, IStudentNavigation)
    3335    grok.provides(INigeriaStudent)
    3436
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py

    r9562 r9564  
    186186        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    187187        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     188        # Managers can edit personal data. No fields are required.
     189        self.browser.open(self.manage_personal_path)
     190        self.browser.getControl("Save").click()
     191        self.assertMatches('...Form has been saved...',
     192                           self.browser.contents)
    188193
    189194    def test_student_access(self):
     
    226231        self.browser.getControl("Save and request clearance").click()
    227232        self.assertMatches('...Clearance has been requested...',
     233                           self.browser.contents)
     234
     235        # Students can edit personal data. Some fields are required.
     236        self.browser.open(self.personal_path)
     237        self.assertTrue('Updated' in self.browser.contents)
     238        self.browser.getLink("Edit").click()
     239        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     240        self.assertEqual(self.browser.url, self.edit_personal_path)
     241        self.browser.getControl("Save").click()
     242        self.assertMatches('...Required input is missing...',
     243                           self.browser.contents)
     244        self.browser.getControl(name="form.perm_address").value = 'My address!'
     245        self.browser.getControl("Save").click()
     246        self.assertMatches('...Required input is missing...',
     247                           self.browser.contents)
     248        # Ok, let's give up and fill the rest.
     249        self.browser.getControl(name="form.next_kin_name").value = 'My Mutti'
     250        self.browser.getControl(name="form.next_kin_relation").value = 'mother'
     251        self.browser.getControl(name="form.next_kin_address").value = 'sweet home'
     252        self.browser.getControl("Save").click()
     253        self.assertMatches('...Form has been saved...',
    228254                           self.browser.contents)
    229255
Note: See TracChangeset for help on using the changeset viewer.