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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.