Ignore:
Timestamp:
2 Apr 2012, 10:14:03 (12 years ago)
Author:
Henrik Bettermann
Message:

All pages now distinguish between undergraduate and postgraduate applicants.

Location:
main/waeup.custom/trunk/src/waeup/custom/applicants
Files:
3 edited

Legend:

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

    r8012 r8017  
    2424from waeup.kofa.widgets.phonewidget import PhoneWidget
    2525from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
    26     OnlinePaymentCallbackPage, ExportPDFPage, ApplicantManageFormPage)
     26    OnlinePaymentCallbackPage, ExportPDFPage,
     27    ApplicantManageFormPage, ApplicantEditFormPage)
    2728from waeup.kofa.applicants.viewlets import RequestCallbackActionButton
    28 from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit
    29 from waeup.custom.applicants.interfaces import IPGApplicant, IUGApplicant
     29from waeup.kofa.applicants.pdf import PDFApplicationSlip
     30#from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit
     31from waeup.custom.applicants.interfaces import (
     32    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit)
    3033from waeup.custom.interfaces import MessageFactory as _
    3134
     
    4346        return
    4447
    45 class ExportPDFPage(ExportPDFPage):
    46     """Deliver a PDF slip of the context.
    47     """
    48     grok.context(IApplicant)
    49     grok.name('application_slip.pdf')
    50     grok.require('waeup.viewApplication')
    51     form_fields = grok.AutoFields(IApplicant).omit(
    52         'locked', 'course_admitted')
    53     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    54     prefix = 'form'
     48class PDFApplicationSlip(PDFApplicationSlip):
    5549
     50    @property
     51    def form_fields(self):
     52        target = getattr(self.context.__parent__, 'prefix', None)
     53        if target is not None and target.startswith('pg'):
     54            form_fields = grok.AutoFields(IPGApplicant).omit(
     55                'locked', 'course_admitted')
     56        else:
     57            form_fields = grok.AutoFields(IUGApplicant).omit(
     58                'locked', 'course_admitted')
     59        form_fields[
     60            'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     61        return form_fields
    5662
    5763class ApplicantDisplayFormPage(ApplicantDisplayFormPage):
     64    """A display view for applicant data.
     65    """
    5866
    5967    @property
     
    6674            form_fields = grok.AutoFields(IUGApplicant).omit(
    6775                'locked', 'course_admitted', 'password')
    68         form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     76        form_fields[
     77            'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    6978        return form_fields
    7079
     
    7281    """A full edit view for applicant data.
    7382    """
    74     grok.context(IApplicant)
    75     grok.name('manage')
    76     grok.require('waeup.manageApplication')
    77     form_fields = grok.AutoFields(IApplicant)
    78     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    79     form_fields['student_id'].for_display = True
    80     form_fields['applicant_id'].for_display = True
    81     form_fields['phone'].custom_widget = PhoneWidget
    82     grok.template('applicanteditpage')
    83     manage_applications = True
    84     pnav = 3
    85     display_actions = [[_('Save'), _('Final Submit')],
    86         [_('Add online payment ticket'),_('Remove selected tickets')]]
     83   
     84    @property
     85    def form_fields(self):
     86        target = getattr(self.context.__parent__, 'prefix', None)
     87        if target is not None and target.startswith('pg'):
     88            form_fields = grok.AutoFields(IPGApplicant)
     89        else:
     90            form_fields = grok.AutoFields(IUGApplicant)
     91        form_fields[
     92            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     93        form_fields['phone'].custom_widget = PhoneWidget
     94        form_fields['student_id'].for_display = True
     95        form_fields['applicant_id'].for_display = True
     96        form_fields['phone'].custom_widget = PhoneWidget
     97        return form_fields
    8798
    88 
    89 class ApplicantEditFormPage(ApplicantManageFormPage):
     99class ApplicantEditFormPage(ApplicantEditFormPage):
    90100    """An applicant-centered edit view for applicant data.
    91101    """
    92     grok.context(IApplicantEdit)
    93     grok.name('edit')
    94     grok.require('waeup.handleApplication')
    95     form_fields = grok.AutoFields(IApplicantEdit).omit(
    96         'locked', 'course_admitted', 'student_id',
    97         'screening_score', 'reg_number'
    98         )
    99     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    100     form_fields['phone'].custom_widget = PhoneWidget
    101     form_fields['applicant_id'].for_display = True
    102     grok.template('applicanteditpage')
    103     manage_applications = False
     102
     103    @property
     104    def form_fields(self):
     105        target = getattr(self.context.__parent__, 'prefix', None)
     106        if target is not None and target.startswith('pg'):
     107            form_fields = grok.AutoFields(IPGApplicantEdit).omit(
     108                'locked', 'course_admitted', 'student_id',
     109                'screening_score', 'reg_number'
     110                )
     111        else:
     112            form_fields = grok.AutoFields(IUGApplicantEdit).omit(
     113                'locked', 'course_admitted', 'student_id',
     114                'screening_score', 'reg_number'
     115                )
     116        form_fields[
     117            'date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     118        form_fields['phone'].custom_widget = PhoneWidget
     119        form_fields['applicant_id'].for_display = True
     120        return form_fields
  • main/waeup.custom/trunk/src/waeup/custom/applicants/interfaces.py

    r8012 r8017  
    4444    """
    4545
    46 class IUGApplicantEdit(IApplicantProcessData):
     46class IUGApplicantEdit(IUGApplicant):
    4747    """An undergraduate applicant interface for editing.
    4848
     
    5656    """
    5757
    58 class IPGApplicantEdit(IApplicantProcessData):
     58class IPGApplicantEdit(IPGApplicant):
    5959    """A postgraduate applicant interface for editing.
    6060
  • main/waeup.custom/trunk/src/waeup/custom/applicants/tests.py

    r8012 r8017  
    105105            % self.pgapplication_number)
    106106        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     107        # The IPGApplicant interface is really used in all pages
    107108        self.browser.open(pgapplicant_path)
    108109        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    109         # The IPGApplicant interface is really used
    110110        self.assertTrue('Employer' in self.browser.contents)
    111         # If we move the applicant to the container,
    112         # the Employer field disappears
     111        self.browser.open(pgapplicant_path + '/manage')
     112        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     113        self.assertTrue('Employer' in self.browser.contents)
     114        self.browser.open(pgapplicant_path + '/edit')
     115        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     116        self.assertTrue('Employer' in self.browser.contents)
     117        self.browser.open(pgapplicant_path + '/application_slip.pdf')
     118        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     119        # If we lool at the applicant in the ug container,
     120        # the employer field doesn't appear
    113121        ugapplicant_path = ('http://localhost/app/applicants/app2011/%s'
    114122            % self.ugapplication_number)
     
    116124        self.browser.open(ugapplicant_path)
    117125        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    118 
    119126        self.assertFalse('Employer' in self.browser.contents)
     127        self.browser.open(ugapplicant_path + '/manage')
     128        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     129        self.assertFalse('Employer' in self.browser.contents)
     130        self.browser.open(ugapplicant_path + '/edit')
     131        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     132        self.assertFalse('Employer' in self.browser.contents)
     133        self.browser.open(ugapplicant_path + '/application_slip.pdf')
     134        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    120135        return
Note: See TracChangeset for help on using the changeset viewer.