Changeset 13996 for main/waeup.aaue/trunk/src/waeup
- Timestamp:
- 28 Jun 2016, 11:25:21 (8 years ago)
- 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 20 20 import grok 21 21 import os 22 from zope.component import getUtility 22 from zope.component import getUtility, getAdapter 23 from zope.i18n import translate 23 24 from waeup.kofa.interfaces import ( 24 IExtFileStore, IFileStoreNameChooser )25 IExtFileStore, IFileStoreNameChooser, IKofaUtils) 25 26 from zope.formlib.textwidgets import BytesDisplayWidget 26 27 from waeup.kofa.utils.helpers import string_from_bytes, file_size 27 from waeup.kofa.applicants.browser import ApplicantCheckStatusPage 28 from waeup.kofa.applicants.browser import ( 29 ApplicantCheckStatusPage, ApplicantBaseDisplayFormPage) 28 30 from waeup.kofa.applicants.viewlets import PDFActionButton 31 from waeup.kofa.browser.layout import UtilityView 32 from waeup.kofa.students.interfaces import IStudentsUtils 33 from waeup.kofa.interfaces import IPDF 34 from waeup.kofa.applicants.interfaces import IApplicant 29 35 from waeup.aaue.interfaces import MessageFactory as _ 30 36 from kofacustom.nigeria.applicants.browser import ( … … 40 46 ICustomUGApplicant, 41 47 ICustomUGApplicantEdit, 42 ITranscriptApplicant 48 ITranscriptApplicant, 49 ICustomApplicant 43 50 ) 44 51 … … 88 95 'course1', 89 96 'master_sheet_number', 97 'screening_venue', 98 'screening_score', 99 'screening_date' 90 100 ) 91 101 … … 333 343 """ 334 344 grok.template('applicantcheckstatus') 345 346 347 class 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'> 365 Dear %s, 366 <br /><br /><br /> 367 You are invited for your screening exercise on: 368 <br /><br /> 369 <strong>%s</strong>. 370 <br /><br /> 371 Please bring along this letter of invitation to the %s 372 <br /><br /> 373 on your screening date. 374 <br /><br /><br /> 375 Signed, 376 <br /><br /> 377 xyz<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 418 418 ) 419 419 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 ) 432 432 #aggregate = schema.Int( 433 433 # title = _(u'Aggregate Score (%)'), -
main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py
r13977 r13996 19 19 import datetime 20 20 import pytz 21 import os 21 22 from zope.event import notify 22 23 from zope.component import createObject, getUtility 23 24 from waeup.kofa.configuration import SessionConfiguration 24 25 from waeup.kofa.applicants.container import ApplicantsContainer 26 from waeup.kofa.browser.tests.test_pdf import samples_dir 25 27 from waeup.aaue.testing import FunctionalLayer 26 28 from waeup.kofa.applicants.tests.test_browser import ( … … 68 70 self.assertEqual(self.browser.headers['Content-Type'], 69 71 '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 70 88 return 71 89
Note: See TracChangeset for help on using the changeset viewer.