Ignore:
Timestamp:
14 Dec 2011, 22:34:02 (13 years ago)
Author:
Henrik Bettermann
Message:

Rollback of r7341 as discussed on the phone. But now we get other problems (see email). A regression test will follow.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/__init__.py

    r7341 r7347  
    1010    ApplicantsRoot, get_applicant_data, application_exists,
    1111    )
     12from waeup.sirp.applicants.dynamicroles import (
     13    ApplicantPrincipalRoleManager,)
    1214
    1315__all__ = [
     
    1618    'ApplicantImageNameChooser',
    1719    'ApplicantImageStoreHandler',
     20    'ApplicantPrincipalRoleManager',
    1821    'ApplicantsContainer',
    1922    'ApplicantsRoot',
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py

    r7344 r7347  
    9393            return False, 'Registration Number exists.'
    9494        # Has the course_admitted field been properly filled?
    95         code = self.course_admitted.get('code')
    96         if code:
    97             catalog = getUtility(ICatalog, name='certificates_catalog')
    98             cert = [i for i in catalog.searchResults(code=(code,code))][0]
    99         else:
     95        if self.course_admitted is None:
    10096            return False, 'No course admitted provided.'
    10197        # Add student object
     
    117113        student.phone = self.phone
    118114        # Save the certificate
    119         student['studycourse'].certificate = cert
     115        student['studycourse'].certificate = self.course_admitted
    120116        # Create StudentApplication object ...
    121117        application = createObject(u'waeup.StudentApplication')
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r7341 r7347  
    438438    grok.template('applicantdisplaypage')
    439439    form_fields = grok.AutoFields(IApplicant).omit(
    440         'locked',
    441         'password')
     440        'locked', 'course_admitted', 'password')
    442441    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    443442    label = 'Applicant'
     
    469468            container_title, self.context.application_number)
    470469
    471     def getDepartmentAdmitted(self):
    472         course_admitted = getattr(self.context,'course_admitted',None)
    473         if course_admitted:
    474             return course_admitted['dep']
    475 
    476     def getFacultyAdmitted(self):
    477         course_admitted = getattr(self.context,'course_admitted',None)
    478         if course_admitted:
    479             return course_admitted['fac']
     470    def getCourseAdmitted(self):
     471        """Return link, title and code in html format to the certificate
     472           admitted.
     473        """
     474        course_admitted = self.context.course_admitted
     475        if ICertificate.providedBy(course_admitted):
     476            url = self.url(course_admitted)
     477            title = course_admitted.title
     478            code = course_admitted.code
     479            return '<a href="%s">%s - %s</a>' %(url,code,title)
     480        return ''
    480481
    481482class ApplicantBaseDisplayFormPage(ApplicantDisplayFormPage):
     
    672673    grok.require('waeup.viewApplication')
    673674    form_fields = grok.AutoFields(IApplicant).omit(
    674         'locked',
    675         )
     675        'locked', 'course_admitted')
    676676    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    677677    prefix = 'form'
     
    683683            container_title, self.context.application_number)
    684684
    685     def getDepartmentAdmitted(self):
    686         course_admitted = getattr(self.context,'course_admitted',None)
    687         if course_admitted:
    688             return course_admitted['dep']
    689 
    690     def getFacultyAdmitted(self):
    691         course_admitted = getattr(self.context,'course_admitted',None)
    692         if course_admitted:
    693             return course_admitted['fac']
    694 
     685    def getCourseAdmitted(self):
     686        """Return title and code in html format to the certificate
     687           admitted.
     688        """
     689        course_admitted = self.context.course_admitted
     690        if ICertificate.providedBy(course_admitted):
     691            title = course_admitted.title
     692            code = course_admitted.code
     693            return '%s - %s' %(code,title)
     694        return ''
    695695
    696696    def setUpWidgets(self, ignore_request=False):
     
    755755            f_text = Paragraph(f_text, style["Normal"])
    756756            data.append([f_label,f_text])
    757         #f_label = '<font size=12>Admitted Course of Study:</font>'
    758         #f_text = '<font size=12>%s</font>' % self.getCourseAdmitted()
    759         #f_label = Paragraph(f_label, style["Normal"])
    760         #f_text = Paragraph(f_text, style["Normal"])
    761         #data.append([f_label,f_text])
    762 
    763         f_label = '<font size=12>Department:</font>'
    764         f_text = '<font size=12>%s</font>' % self.getDepartmentAdmitted()
     757        course_admitted = self.getCourseAdmitted()
     758        f_label = '<font size=12>Admitted Course of Study:</font>'
     759        f_text = '<font size=12>%s</font>' % course_admitted
    765760        f_label = Paragraph(f_label, style["Normal"])
    766761        f_text = Paragraph(f_text, style["Normal"])
    767762        data.append([f_label,f_text])
    768763
    769         f_label = '<font size=12>Faculty:</font>'
    770         f_text = '<font size=12>%s</font>' % self.getFacultyAdmitted()
    771         f_label = Paragraph(f_label, style["Normal"])
    772         f_text = Paragraph(f_text, style["Normal"])
    773         data.append([f_label,f_text])
     764        course_admitted = self.context.course_admitted
     765        if ICertificate.providedBy(course_admitted):
     766            f_label = '<font size=12>Department:</font>'
     767            f_text = '<font size=12>%s</font>' % (
     768                course_admitted.__parent__.__parent__.longtitle())
     769            f_label = Paragraph(f_label, style["Normal"])
     770            f_text = Paragraph(f_text, style["Normal"])
     771            data.append([f_label,f_text])
     772
     773            f_label = '<font size=12>Faculty:</font>'
     774            f_text = '<font size=12>%s</font>' % (
     775                course_admitted.__parent__.__parent__.__parent__.longtitle())
     776            f_label = Paragraph(f_label, style["Normal"])
     777            f_text = Paragraph(f_text, style["Normal"])
     778            data.append([f_label,f_text])
    774779
    775780        # Create table
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantdisplaypage.pt

    r7341 r7347  
    2727    <tr>
    2828      <td class="fieldname">
    29           Department:
     29          Admitted Course of Study:
    3030      </td>
    3131      <td>
    32         <span tal:replace="view/getDepartmentAdmitted" />
    33       </td>
    34     </tr>
    35     <tr>
    36       <td class="fieldname">
    37           Faculty:
    38       </td>
    39       <td>
    40         <span tal:replace="view/getFacultyAdmitted" />
     32        <span tal:replace="structure view/getCourseAdmitted" />
    4133      </td>
    4234    </tr>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7341 r7347  
    3232    ISIRPObject, year_range, validate_email, academic_sessions_vocab)
    3333from waeup.sirp.university.vocabularies import application_categories
    34 from waeup.sirp.students.vocabularies import lgas_vocab, GenderSource
     34from waeup.sirp.students.vocabularies import (
     35  lgas_vocab, CertificateSource, GenderSource,
     36  )
    3537from waeup.sirp.applicants.vocabularies import (
    3638  application_types_vocab, application_pins_vocab,
    37   AppCatCertificateTitleSource, CertificateTitleSource
     39  AppCatCertificateSource,
    3840  )
    3941from waeup.sirp.payments.interfaces import IOnlinePayment
     
    343345    course1 = schema.Choice(
    344346        title = u'1st Choice Course of Study',
    345         source = CertificateTitleSource(),
     347        source = CertificateSource(),
    346348        required = True,
    347349        )
    348350    course2 = schema.Choice(
    349351        title = u'2nd Choice Course of Study',
    350         source = CertificateTitleSource(),
     352        source = CertificateSource(),
    351353        required = False,
    352354        )
     
    363365        required = False,
    364366        )
     367    course_admitted = schema.Choice(
     368        title = u'Admitted Course of Study',
     369        source = CertificateSource(),
     370        default = None,
     371        required = False,
     372        )
    365373    notice = schema.Text(
    366374        title = u'Notice',
    367         required = False,
    368         )
    369     course_admitted = schema.Choice(
    370         title = u'Admitted Course of Study',
    371         source = CertificateTitleSource(),
    372         default = None,
    373375        required = False,
    374376        )
     
    423425    course1 = schema.Choice(
    424426        title = u'1st Choice Course of Study',
    425         source = AppCatCertificateTitleSource(),
     427        source = AppCatCertificateSource(),
    426428        required = True,
    427429        )
    428430    course2 = schema.Choice(
    429431        title = u'2nd Choice Course of Study',
    430         source = AppCatCertificateTitleSource(),
     432        source = AppCatCertificateSource(),
    431433        required = False,
    432434        )
     
    443445    course_admitted = schema.Choice(
    444446        title = u'Admitted Course of Study',
    445         source = CertificateTitleSource(),
     447        source = CertificateSource(),
    446448        default = None,
    447449        required = False,
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py

    r7341 r7347  
    2121from zope.catalog.interfaces import ICatalog
    2222from waeup.sirp.interfaces import SimpleSIRPVocabulary
    23 from zc.sourcefactory.contextual import BasicContextualSourceFactory
     23from waeup.sirp.students.vocabularies import CertificateSource
    2424
    2525#: Types of applications we support.
     
    4444    *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES])
    4545
    46 class CertificateTitleSource(BasicContextualSourceFactory):
    47     """A certificate title source delivers all certificates titles provided
    48     in the portal.
    49     """
    50     def getValues(self, context):
    51         catalog = getUtility(ICatalog, name='certificates_catalog')
    52         certs = list(catalog.searchResults(code=('', 'z*')))
    53         certs = [dict(
    54             code = i.code,
    55             title = i.title,
    56             dep = i.__parent__.__parent__.longtitle(),
    57             fac = i.__parent__.__parent__.__parent__.longtitle()
    58             ) for i in certs]
    59         return sorted(certs, key=lambda value: value['code'])
    6046
    61     def getToken(self, context, value):
    62         return value['code']
    63 
    64     def getTitle(self, context, value):
    65         return "%s - %s" % (value['code'], value['title'][:64])
    66 
    67 class AppCatCertificateTitleSource(CertificateTitleSource):
    68     """An application certificate source delivers all course titles which belong to
     47class AppCatCertificateSource(CertificateSource):
     48    """An application certificate source delivers all courses which belong to
    6949    a certain application_category.
    7050    """
     
    7252        appcat = context.__parent__.application_category
    7353        catalog = getUtility(ICatalog, name='certificates_catalog')
    74         certs = list(catalog.searchResults(code=('', 'z*'),
    75             application_category=(appcat,appcat)))
    76         certs = [dict(
    77             code = i.code,
    78             title = i.title,
    79             dep = i.__parent__.__parent__.longtitle(),
    80             fac = i.__parent__.__parent__.__parent__.longtitle()
    81             ) for i in certs]
    82         return sorted(certs, key=lambda value: value['code'])
    83 
    84 
     54        return sorted(list(
     55                catalog.searchResults(
     56                    code=('', 'z*'),
     57                    application_category=(appcat,appcat))),
     58                    key=lambda value: value.code)
Note: See TracChangeset for help on using the changeset viewer.