Ignore:
Timestamp:
28 Jun 2016, 11:25:21 (8 years ago)
Author:
Henrik Bettermann
Message:

Enable screening data. Add ExportScreeningInvitationLetter? view.

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

Legend:

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

    r13977 r13996  
    2020import grok
    2121import os
    22 from zope.component import getUtility
     22from zope.component import getUtility, getAdapter
     23from zope.i18n import translate
    2324from waeup.kofa.interfaces import (
    24     IExtFileStore, IFileStoreNameChooser)
     25    IExtFileStore, IFileStoreNameChooser, IKofaUtils)
    2526from zope.formlib.textwidgets import BytesDisplayWidget
    2627from waeup.kofa.utils.helpers import string_from_bytes, file_size
    27 from waeup.kofa.applicants.browser import ApplicantCheckStatusPage
     28from waeup.kofa.applicants.browser import (
     29    ApplicantCheckStatusPage, ApplicantBaseDisplayFormPage)
    2830from waeup.kofa.applicants.viewlets import PDFActionButton
     31from waeup.kofa.browser.layout import UtilityView
     32from waeup.kofa.students.interfaces import IStudentsUtils
     33from waeup.kofa.interfaces import IPDF
     34from waeup.kofa.applicants.interfaces import IApplicant
    2935from waeup.aaue.interfaces import MessageFactory as _
    3036from kofacustom.nigeria.applicants.browser import (
     
    4046    ICustomUGApplicant,
    4147    ICustomUGApplicantEdit,
    42     ITranscriptApplicant
     48    ITranscriptApplicant,
     49    ICustomApplicant
    4350    )
    4451
     
    8895    'course1',
    8996    'master_sheet_number',
     97    'screening_venue',
     98    'screening_score',
     99    'screening_date'
    90100    )
    91101
     
    333343    """
    334344    grok.template('applicantcheckstatus')
     345
     346
     347class ExportScreeningInvitationLetter(UtilityView, grok.View):
     348    """Deliver a slip with only screening data.
     349    This form page is available only in AAUE.
     350    """
     351    grok.context(IApplicant)
     352    grok.name('screening_invitation.pdf')
     353    grok.require('waeup.viewApplication')
     354    prefix = 'form'
     355
     356    label = u'Screening Invitation Letter'
     357
     358    form_fields = []
     359
     360    @property
     361    def note(self):
     362        if self.context.screening_date:
     363            return """
     364<br /><br /><br /><br /><font size='12'>
     365Dear %s,
     366<br /><br /><br />
     367You are invited for your screening exercise on:
     368<br /><br />
     369<strong>%s</strong>.
     370<br /><br />
     371Please bring along this letter of invitation to the %s
     372<br /><br />
     373on your screening date.
     374<br /><br /><br />
     375Signed,
     376<br /><br />
     377xyz<br />
     378</font>
     379
     380""" % (self.context.display_fullname,
     381       self.context.screening_date,
     382       self.context.screening_venue)
     383        return
     384
     385    @property
     386    def title(self):
     387        return None
     388
     389    def update(self):
     390        if not self.context.screening_date:
     391            self.flash(_('Forbidden'), type="warning")
     392            self.redirect(self.url(self.context))
     393
     394    def render(self):
     395        applicantview = ApplicantBaseDisplayFormPage(self.context, self.request)
     396        students_utils = getUtility(IStudentsUtils)
     397        return students_utils.renderPDF(self,'screening_data.pdf',
     398            self.context, applicantview, note=self.note)
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/interfaces.py

    r13977 r13996  
    418418        )
    419419
    420     #screening_venue = schema.TextLine(
    421     #    title = _(u'Screening Venue'),
    422     #    required = False,
    423     #    )
    424     #screening_date = schema.TextLine(
    425     #    title = _(u'Screening Date'),
    426     #    required = False,
    427     #    )
    428     #screening_score = schema.Int(
    429     #    title = _(u'Screening Score (%)'),
    430     #    required = False,
    431     #    )
     420    screening_venue = schema.TextLine(
     421        title = _(u'Screening Venue'),
     422        required = False,
     423        )
     424    screening_date = schema.TextLine(
     425        title = _(u'Screening Date'),
     426        required = False,
     427        )
     428    screening_score = schema.Int(
     429        title = _(u'Screening Score (%)'),
     430        required = False,
     431        )
    432432    #aggregate = schema.Int(
    433433    #    title = _(u'Aggregate Score (%)'),
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py

    r13977 r13996  
    1919import datetime
    2020import pytz
     21import os
    2122from zope.event import notify
    2223from zope.component import createObject, getUtility
    2324from waeup.kofa.configuration import SessionConfiguration
    2425from waeup.kofa.applicants.container import ApplicantsContainer
     26from waeup.kofa.browser.tests.test_pdf import samples_dir
    2527from waeup.aaue.testing import FunctionalLayer
    2628from waeup.kofa.applicants.tests.test_browser import (
     
    6870        self.assertEqual(self.browser.headers['Content-Type'],
    6971                 'application/pdf')
     72        return
     73
     74    def test_screening_slip_download(self):
     75        self.login()
     76        self.applicant.screening_date = u'29th August 2016'
     77        self.applicant.screening_venue = u'Main Auditorium'
     78        self.applicant.lastname = u'Cox'
     79        self.applicant.firstname = u'Jo'
     80        self.applicant.email = 'xx@yy.zz'
     81        self.browser.open(self.view_path + '/screening_invitation.pdf')
     82        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     83        self.assertEqual(
     84            self.browser.headers['Content-Type'], 'application/pdf')
     85        path = os.path.join(samples_dir(), 'screening_invitation.pdf')
     86        open(path, 'wb').write(self.browser.contents)
     87        print "Sample PDF screening_invitation.pdf written to %s" % path
    7088        return
    7189
Note: See TracChangeset for help on using the changeset viewer.