Ignore:
Timestamp:
26 Oct 2015, 17:18:16 (9 years ago)
Author:
Henrik Bettermann
Message:

Extend personal data form and force student to fill the form.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
1 added
5 edited

Legend:

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

    r13059 r13351  
    1919from zope.i18n import translate
    2020from zope.component import getUtility
     21from zope.formlib.textwidgets import BytesDisplayWidget
    2122from waeup.kofa.browser.layout import UtilityView
    2223from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     
    3839    NigeriaExportPDFCourseRegistrationSlip,
    3940    NigeriaExportPDFClearanceSlip,
     41    NigeriaStudentPersonalDisplayFormPage,
     42    NigeriaStudentPersonalEditFormPage,
     43    NigeriaStudentPersonalManageFormPage,
    4044    )
    4145from waeup.aaue.students.interfaces import (
    4246    ICustomStudentOnlinePayment,
    4347    ICustomStudentStudyLevel,
    44     ICustomStudent)
     48    ICustomStudent,
     49    ICustomStudentPersonal,
     50    ICustomStudentPersonalEdit)
    4551from waeup.aaue.interfaces import MessageFactory as _
    4652
     53class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
     54    """ Page to display student personal data
     55    """
     56    form_fields = grok.AutoFields(ICustomStudentPersonal)
     57    form_fields['perm_address'].custom_widget = BytesDisplayWidget
     58    form_fields['father_address'].custom_widget = BytesDisplayWidget
     59    form_fields['mother_address'].custom_widget = BytesDisplayWidget
     60    form_fields['next_kin_address'].custom_widget = BytesDisplayWidget
     61    form_fields[
     62        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     63
     64class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
     65    """ Page to edit personal data
     66    """
     67    form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit('personal_updated')
     68
     69class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
     70    """ Page to edit personal data
     71    """
     72    form_fields = grok.AutoFields(ICustomStudentPersonal)
     73    form_fields['personal_updated'].for_display = True
     74    form_fields[
     75        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     76
    4777class CustomStartClearancePage(StartClearancePage):
    48     with_ac = False
     78    with_ac = True
     79
     80    @property
     81    def all_required_fields_filled(self):
     82        if not self.context.email:
     83            return _("Email address is missing."), 'edit_base'
     84        if not self.context.phone:
     85            return _("Phone number is missing."), 'edit_base'
     86        if not self.context.father_name:
     87            return _("Personal data form is not properly filled."), 'edit_personal'
     88        return
    4989
    5090class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py

    r10280 r13351  
    2222from zope.component import getUtility
    2323from waeup.kofa.interfaces import IKofaObject
     24from waeup.kofa.schema import PhoneNumber
    2425from kofacustom.nigeria.students.interfaces import (
    2526    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
     
    4142    """
    4243
     44    father_name = schema.TextLine(
     45        title = _(u'Father\'s Name'),
     46        required = False,
     47        readonly = False,
     48        )
     49
     50    father_address = schema.Text(
     51        title = _(u'Father\'s Permanent Address'),
     52        required = False,
     53        readonly = False,
     54        )
     55
     56    father_work = schema.TextLine(
     57        title = _(u'Father\'s Place of Work'),
     58        required = False,
     59        readonly = False,
     60        )
     61
     62    father_phone = PhoneNumber(
     63        title = _(u'Father\'s Phone'),
     64        required = False,
     65        readonly = False,
     66        )
     67
     68    mother_name = schema.TextLine(
     69        title = _(u'Mother\'s Name'),
     70        required = False,
     71        readonly = False,
     72        )
     73
     74    mother_address = schema.Text(
     75        title = _(u'Mother\'s Permanent Address'),
     76        required = False,
     77        readonly = False,
     78        )
     79
     80    mother_work = schema.TextLine(
     81        title = _(u'Mother\'s Place of Work'),
     82        required = False,
     83        readonly = False,
     84        )
     85
     86    mother_phone = PhoneNumber(
     87        title = _(u'Mother\'s Phone'),
     88        required = False,
     89        readonly = False,
     90        )
     91
     92    phone_personal = PhoneNumber(
     93        title = _(u'Student\'s Personal Phone'),
     94        description = u'',
     95        required = True,
     96        readonly = False,
     97        )
     98
     99class ICustomStudentPersonalEdit(ICustomStudentPersonal):
     100    """Interface for editing personal data by students.
     101
     102    Here we can repeat the fields from IStudentPersonal and set the
     103    `required` if necessary.
     104    """
     105
     106    perm_address = schema.Text(
     107        title = _(u'Permanent Address'),
     108        required = True,
     109        )
     110
     111    next_kin_name = schema.TextLine(
     112        title = _(u'Next of Kin Name'),
     113        required = True,
     114        readonly = False,
     115        )
     116
     117    next_kin_relation = schema.TextLine(
     118        title = _(u'Next of Kin Relationship'),
     119        required = True,
     120        readonly = False,
     121        )
     122
     123    next_kin_address = schema.Text(
     124        title = _(u'Next of Kin Address'),
     125        required = True,
     126        readonly = False,
     127        )
     128
     129    next_kin_phone = PhoneNumber(
     130        title = _(u'Next of Kin Phone'),
     131        description = u'',
     132        required = True,
     133        readonly = False,
     134        )
     135
     136    father_name = schema.TextLine(
     137        title = _(u'Father\'s Name'),
     138        required = True,
     139        readonly = False,
     140        )
     141
     142    father_address = schema.Text(
     143        title = _(u'Father\'s Permanent Address'),
     144        required = True,
     145        readonly = False,
     146        )
     147
     148    father_work = schema.TextLine(
     149        title = _(u'Father\'s Place of Work'),
     150        required = True,
     151        readonly = False,
     152        )
     153
     154    father_phone = PhoneNumber(
     155        title = _(u'Father\'s Phone'),
     156        required = True,
     157        readonly = False,
     158        )
     159
     160    mother_name = schema.TextLine(
     161        title = _(u'Mother\'s Name'),
     162        required = True,
     163        readonly = False,
     164        )
     165
     166    mother_address = schema.Text(
     167        title = _(u'Mother\'s Permanent Address'),
     168        required = True,
     169        readonly = False,
     170        )
     171
     172    mother_work = schema.TextLine(
     173        title = _(u'Mother\'s Place of Work'),
     174        required = True,
     175        readonly = False,
     176        )
     177
     178    mother_phone = PhoneNumber(
     179        title = _(u'Mother\'s Phone'),
     180        required = True,
     181        readonly = False,
     182        )
     183
     184    phone_personal = PhoneNumber(
     185        title = _(u'Student\'s Personal Phone'),
     186        description = u'',
     187        required = True,
     188        readonly = False,
     189        )
     190
    43191class ICustomUGStudentClearance(INigeriaUGStudentClearance):
    44192    """Representation of ug student clearance data.
  • main/waeup.aaue/trunk/src/waeup/aaue/students/student.py

    r10422 r13351  
    2525from waeup.kofa.students.interfaces import IStudentNavigation
    2626from kofacustom.nigeria.students.student import NigeriaStudent
    27 from waeup.aaue.students.interfaces import ICustomStudent
     27from waeup.aaue.students.interfaces import (
     28    ICustomStudent, ICustomStudentPersonalEdit)
    2829
    2930
     
    3233    owned by students.
    3334    """
    34     grok.implements(ICustomStudent, IStudentNavigation)
     35    grok.implements(ICustomStudent, IStudentNavigation,
     36                    ICustomStudentPersonalEdit)
    3537    grok.provides(ICustomStudent)
    3638
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r13059 r13351  
    2121import pytz
    2222import grok
     23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2324from datetime import datetime, timedelta, date
    2425from mechanize import LinkNotFoundError
     
    3334from waeup.kofa.browser.tests.test_pdf import samples_dir
    3435from waeup.aaue.testing import FunctionalLayer
     36
     37SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    3538
    3639
     
    493496        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    494497        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     498
     499    def test_student_clearance(self):
     500        # Student cant login if their password is not set
     501        IWorkflowInfo(self.student).fireTransition('admit')
     502        self.browser.open(self.login_path)
     503        self.browser.getControl(name="form.login").value = self.student_id
     504        self.browser.getControl(name="form.password").value = 'spwd'
     505        self.browser.getControl("Login").click()
     506        self.assertMatches(
     507            '...You logged in...', self.browser.contents)
     508        # Admitted student can upload a passport picture
     509        self.browser.open(self.student_path + '/change_portrait')
     510        ctrl = self.browser.getControl(name='passportuploadedit')
     511        file_obj = open(SAMPLE_IMAGE, 'rb')
     512        file_ctrl = ctrl.mech_control
     513        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
     514        self.browser.getControl(
     515            name='upload_passportuploadedit').click()
     516        self.assertTrue(
     517            'src="http://localhost/app/students/E1000000/passport.jpg"'
     518            in self.browser.contents)
     519        # Student is redirected to the personal data form because
     520        # personal data form is not properly filled.
     521        self.browser.open(self.student_path + '/start_clearance')
     522        self.assertMatches('...Personal data form is not properly filled...',
     523                           self.browser.contents)
     524        self.assertEqual(self.browser.url, self.student_path + '/edit_personal')
     525        self.student.father_name = u'Rudolf'
     526        self.browser.open(self.student_path + '/start_clearance')
     527        self.assertMatches('...<h1 class="kofa-content-label">Start clearance</h1>...',
     528                   self.browser.contents)
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r13112 r13351  
    4747        result = open(self.outfile, 'rb').read()
    4848        self.assertMatches(
    49             'adm_code,alr_date,alr_fname,alr_no,alr_results,'
    50             'clr_code,date_of_birth,def_adm,disabled,email,emp2_end,'
    51             'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,'
    52             'emp_reason,emp_start,employer,employer2,firstname,former_matric,'
    53             'fst_sit_date,fst_sit_fname,fst_sit_no,fst_sit_results,'
    54             'fst_sit_type,hq2_degree,hq2_disc,hq2_matric_no,hq2_school,'
    55             'hq2_session,hq2_type,hq_degree,hq_disc,hq_fname,hq_matric_no,'
    56             'hq_school,hq_session,hq_type,is_staff,lastname,lga,'
    57             'marit_stat,matric_number,middlename,nationality,'
    58             'next_kin_address,next_kin_name,next_kin_phone,next_kin_relation,'
    59             'nysc_lga,nysc_location,nysc_year,officer_comment,'
    60             'perm_address,personal_updated,phone,physical_clearance_date,reg_number,'
    61             'religion,scd_sit_date,scd_sit_fname,scd_sit_no,'
    62             'scd_sit_results,scd_sit_type,sex,student_id,'
    63             'suspended,suspended_comment,password,state,history,certcode,is_postgrad,'
    64             'current_level,current_session\r\nmy adm code,,,,'
    65             '"[(\'printing_craft_practice\', \'A1\')]",my clr code,1981-02-04#,,,'
    66             'anna@sample.com,,,,,,,,,,,Anna,,,,,"[(\'printing_craft_practice\', \'A1\')]"'
    67             ',,,,,,,,,,,,,,,,Tester,,,234,M.,NG,,,,,,,,,'
    68             '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,,123,,,,,'
    69             '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,created,'
    70             '[u\'2012-11-06 13:16:41 WAT - Record created by system\'],'
     49            'adm_code,alr_date,alr_fname,alr_no,alr_results,clr_code,'
     50            'date_of_birth,def_adm,disabled,email,emp2_end,emp2_position,'
     51            'emp2_reason,emp2_start,emp_end,emp_position,emp_reason,'
     52            'emp_start,employer,employer2,father_address,father_name,'
     53            'father_phone,father_work,firstname,former_matric,fst_sit_date,'
     54            'fst_sit_fname,fst_sit_no,fst_sit_results,fst_sit_type,hq2_degree,'
     55            'hq2_disc,hq2_matric_no,hq2_school,hq2_session,hq2_type,'
     56            'hq_degree,hq_disc,hq_fname,hq_matric_no,hq_school,hq_session,'
     57            'hq_type,is_staff,lastname,lga,marit_stat,matric_number,'
     58            'middlename,mother_address,mother_name,mother_phone,'
     59            'mother_work,nationality,next_kin_address,next_kin_name,'
     60            'next_kin_phone,next_kin_relation,nysc_lga,nysc_location,'
     61            'nysc_year,officer_comment,perm_address,personal_updated,'
     62            'phone,phone_personal,physical_clearance_date,reg_number,'
     63            'religion,scd_sit_date,scd_sit_fname,scd_sit_no,scd_sit_results,'
     64            'scd_sit_type,sex,student_id,suspended,suspended_comment,password,'
     65            'state,history,certcode,is_postgrad,current_level,current_session'
     66            '\r\n'
     67            'my adm code,,,,"[(\'printing_craft_practice\', \'A1\')]",'
     68            'my clr code,1981-02-04#,,,anna@sample.com,,,,,,,,,,,,,,,Anna,,,,,'
     69            '"[(\'printing_craft_practice\', \'A1\')]",,,,,,,,,,,,,,,,Tester,,,'
     70            '234,M.,,,,,NG,,,,,,,,,"Studentroad 21\nLagos 123456\n",,'
     71            '+234-123-12345#,,,123,,,,,'
     72            '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,'
     73            'created,[u\'2015-10-26 17:45:56 WAT - Record created by system\'],'
    7174            'CERT1,0,200,2012\r\n',
    7275            result
Note: See TracChangeset for help on using the changeset viewer.