Changeset 7714 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 28 Feb 2012, 10:34:16 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7710 r7714 25 25 from zope.component import getUtility, createObject, getAdapter 26 26 from zope.formlib.form import setUpEditWidgets 27 from zope.i18n import translate 27 28 from hurry.workflow.interfaces import ( 28 29 IWorkflowInfo, IWorkflowState, InvalidTransitionError) … … 297 298 return view.widgets['description']() 298 299 299 @action( 'Save', style='primary')300 @action(_('Save'), style='primary') 300 301 def save(self, **data): 301 302 self.applyData(self.context, **data) … … 356 357 'firstname', 'middlename', 'lastname', 357 358 'email', 'phone') 358 label = 'Add applicant'359 label = _('Add applicant') 359 360 pnav = 3 360 361 361 @action( 'Create application record')362 @action(_('Create application record')) 362 363 def addApplicant(self, **data): 363 364 applicant = createObject(u'waeup.Applicant') 364 365 self.applyData(applicant, **data) 365 366 self.context.addApplicant(applicant) 366 self.flash( 'Applicant record created.')367 self.flash(_('Applicant record created.')) 367 368 self.redirect( 368 369 self.url(self.context[applicant.application_number], 'index')) … … 377 378 'locked', 'course_admitted', 'password') 378 379 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 379 label = 'Applicant'380 label = _('Applicant') 380 381 pnav = 3 381 382 … … 392 393 def hasPassword(self): 393 394 if self.context.password: 394 return 'set'395 return 'unset'395 return _('set') 396 return _('unset') 396 397 397 398 @property 398 399 def label(self): 399 400 container_title = self.context.__parent__.title 400 return '%s Application Record %s' % (401 container_title, self.context.application_number)401 return _('${a} Application Record ${b}', mapping = { 402 'a':container_title, 'b':self.context.application_number}) 402 403 403 404 def getCourseAdmitted(self): … … 449 450 academic_session = grok.getSite()['configuration'][session] 450 451 except KeyError: 451 self.flash( 'Session configuration object is not available.')452 self.flash(_('Session configuration object is not available.')) 452 453 return 453 454 timestamp = "%d" % int(time()*1000) … … 456 457 if ticket.p_state == 'paid': 457 458 self.flash( 458 'This type of payment has already been made.')459 _('This type of payment has already been made.')) 459 460 self.redirect(self.url(self.context)) 460 461 return … … 469 470 payment.surcharge_3 = academic_session.surcharge_3 470 471 self.context[payment.p_id] = payment 471 self.flash( 'Payment ticket created.')472 self.flash(_('Payment ticket created.')) 472 473 return 473 474 … … 496 497 @property 497 498 def label(self): 498 return '%s: Online Payment Ticket %s' % (499 self.context.__parent__.display_fullname,self.context.p_id)499 return _('${a}: Online Payment Ticket ${b}', mapping = { 500 'a':self.context.__parent__.display_fullname, 'b':self.context.p_id}) 500 501 501 502 class OnlinePaymentCallbackPage(UtilityView, grok.View): … … 524 525 self.context.__parent__.loggerInfo( 525 526 ob_class, 'valid callback: %s' % self.context.p_id) 526 self.flash( 'Valid callback received.')527 self.flash(_('Valid callback received.')) 527 528 return 528 529 … … 541 542 form_fields['payment_date'].custom_widget = FriendlyDateDisplayWidget('le') 542 543 prefix = 'form' 543 title = 'Payment Data' 544 545 @property 546 def title(self): 547 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 548 return translate(_('Payment Data'), 'waeup.sirp', 549 target_language=portal_language) 544 550 545 551 @property 546 552 def label(self): 547 return 'Online Payment Receipt %s' % self.context.p_id 553 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 554 return translate(_('Online Payment Receipt'), 555 'waeup.sirp', target_language=portal_language) \ 556 + ' %s' % self.context.p_id 548 557 549 558 def render(self): 550 559 if self.context.p_state != 'paid': 551 self.flash( 'Ticket not yet paid.')560 self.flash(_('Ticket not yet paid.')) 552 561 self.redirect(self.url(self.context)) 553 562 return … … 569 578 prefix = 'form' 570 579 571 @property 572 def label(self): 573 container_title = self.context.__parent__.title 574 return '%s Application Record %s' % ( 575 container_title, self.context.application_number) 576 577 def getCourseAdmitted(self): 578 """Return title and code in html format to the certificate 579 admitted. 580 """ 581 course_admitted = self.context.course_admitted 582 #if ICertificate.providedBy(course_admitted): 583 if getattr(course_admitted, '__parent__',None): 584 title = course_admitted.title 585 code = course_admitted.code 586 return '%s - %s' %(code,title) 587 return '' 588 589 def setUpWidgets(self, ignore_request=False): 590 self.adapters = {} 591 self.widgets = setUpEditWidgets( 592 self.form_fields, self.prefix, self.context, self.request, 593 adapters=self.adapters, for_display=True, 594 ignore_request=ignore_request 595 ) 580 #@property 581 #def label(self): 582 # portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 583 # container_title = self.context.__parent__.title 584 # label = translate('Application Record', 585 # 'waeup.sirp', target_language=portal_language) 586 # return container_title + label + self.context.application_number 587 588 #def getCourseAdmitted(self): 589 # """Return title and code in html format to the certificate 590 # admitted. 591 # """ 592 # course_admitted = self.context.course_admitted 593 # #if ICertificate.providedBy(course_admitted): 594 # if getattr(course_admitted, '__parent__',None): 595 # title = course_admitted.title 596 # code = course_admitted.code 597 # return '%s - %s' %(code,title) 598 # return '' 599 600 #def setUpWidgets(self, ignore_request=False): 601 # self.adapters = {} 602 # self.widgets = setUpEditWidgets( 603 # self.form_fields, self.prefix, self.context, self.request, 604 # adapters=self.adapters, for_display=True, 605 # ignore_request=ignore_request 606 # ) 596 607 597 608 def render(self): … … 612 623 size = file_size(upload) 613 624 if size > MAX_UPLOAD_SIZE: 614 view.flash( 'Uploaded image is too big!')625 view.flash(_('Uploaded image is too big!')) 615 626 return False 616 627 dummy, ext = os.path.splitext(upload.filename) 617 628 ext.lower() 618 629 if ext != '.jpg': 619 view.flash( 'jpg file extension expected.')630 view.flash(_('jpg file extension expected.')) 620 631 return False 621 632 upload.seek(0) # file pointer moved when determining size … … 639 650 manage_applications = True 640 651 pnav = 3 641 display_actions = [[ 'Save', 'Final Submit'],642 ['Add online payment ticket','Remove selected tickets']]652 display_actions = [[_('Save'), _('Final Submit')], 653 [_('Add online payment ticket'),_('Remove selected tickets')]] 643 654 644 655 def update(self): … … 659 670 def label(self): 660 671 container_title = self.context.__parent__.title 661 return '%s Application Form %s' % (662 container_title, self.context.application_number)672 return _('${a} Application Form ${b}', mapping = { 673 'a':container_title, 'b':self.context.application_number}) 663 674 664 675 def getTransitions(self): … … 673 684 dict(name=x, title=y) for x, y in allowed_transitions] 674 685 675 @action( 'Save', style='primary')686 @action(_('Save'), style='primary') 676 687 def save(self, **data): 677 688 form = self.request.form … … 702 713 if trans_id: 703 714 self.wf_info.fireTransition(trans_id) 704 self.flash( 'Form has been saved.')715 self.flash(_('Form has been saved.')) 705 716 ob_class = self.__implemented__.__name__.replace('waeup.sirp.','') 706 717 if fields_string: … … 717 728 child_id = form['val_id'] 718 729 else: 719 self.flash( 'No payment selected.')730 self.flash(_('No payment selected.')) 720 731 self.redirect(self.url(self.context)) 721 732 return … … 730 741 deleted.append(id) 731 742 except: 732 self.flash( 'Could not delete%s: %s: %s' % (743 self.flash(_('Could not delete:') + ' %s: %s: %s' % ( 733 744 id, sys.exc_info()[0], sys.exc_info()[1])) 734 745 if len(deleted): 735 self.flash( 'Successfully removed:%s' % ', '.join(deleted))746 self.flash(_('Successfully removed:') + ' %s' % ', '.join(deleted)) 736 747 ob_class = self.__implemented__.__name__.replace('waeup.sirp.','') 737 748 self.context.loggerInfo( … … 742 753 # can be created. If no validation is requested, use 743 754 # 'validator=NullValidator' in the action directive 744 @action( 'Add online payment ticket')755 @action(_('Add online payment ticket')) 745 756 def addPaymentTicket(self, **data): 746 757 self.redirect(self.url(self.context, '@@addafp')) 747 758 return 748 759 749 @jsaction( 'Remove selected tickets')760 @jsaction(_('Remove selected tickets')) 750 761 def removePaymentTickets(self, **data): 751 762 self.delPaymentTickets(**data) … … 775 786 actions = [[],[]] 776 787 elif state == STARTED: 777 actions = [[ 'Save'],778 ['Add online payment ticket','Remove selected tickets']]788 actions = [[_('Save')], 789 [_('Add online payment ticket'),_('Remove selected tickets')]] 779 790 elif state == PAID: 780 actions = [[ 'Save', 'Final Submit'],781 ['Remove selected tickets']]791 actions = [[_('Save'), _('Final Submit')], 792 [_('Remove selected tickets')]] 782 793 else: 783 794 actions = [[],[]] … … 789 800 790 801 def emit_lock_message(self): 791 self.flash( 'The requested form is locked (read-only).')802 self.flash(_('The requested form is locked (read-only).')) 792 803 self.redirect(self.url(self.context)) 793 804 return … … 803 814 store = getUtility(IExtFileStore) 804 815 if not store.getFileByContext(self.context, attr=u'passport.jpg'): 805 return 'No passport picture uploaded.'816 return _('No passport picture uploaded.') 806 817 if not self.request.form.get('confirm_passport', False): 807 return 'Passport picture confirmation box not ticked.'818 return _('Passport picture confirmation box not ticked.') 808 819 return False 809 820 … … 811 822 # can be created. If no validation is requested, use 812 823 # 'validator=NullValidator' in the action directive 813 @action( 'Add online payment ticket')824 @action(_('Add online payment ticket')) 814 825 def addPaymentTicket(self, **data): 815 826 self.redirect(self.url(self.context, '@@addafp')) 816 827 return 817 828 818 @jsaction( 'Remove selected tickets')829 @jsaction(_('Remove selected tickets')) 819 830 def removePaymentTickets(self, **data): 820 831 self.delPaymentTickets(**data) … … 822 833 return 823 834 824 @action( 'Save')835 @action(_('Save')) 825 836 def save(self, **data): 826 837 if self.passport_changed is False: # False is not None! … … 830 841 return 831 842 832 @action( 'Final Submit')843 @action(_('Final Submit')) 833 844 def finalsubmit(self, **data): 834 845 if self.passport_changed is False: # False is not None! … … 842 853 # might have forgotten to lock the form after changing the state 843 854 if state != PAID: 844 self.flash( 'This form cannot be submitted. Wrong state!')855 self.flash(_('This form cannot be submitted. Wrong state!')) 845 856 return 846 857 IWorkflowInfo(self.context).fireTransition('submit') 847 858 self.context.application_date = datetime.now() 848 859 self.context.locked = True 849 self.flash( 'Form has been submitted.')860 self.flash(_('Form has been submitted.')) 850 861 self.redirect(self.url(self.context)) 851 862 return … … 882 893 @property 883 894 def label(self): 884 return "Register for %s Application" % self.context.title 895 return _('Register for ${a} Application', 896 mapping = {'a':self.context.title}) 885 897 886 898 def update(self): 887 899 # Check if application has started ... 888 900 if not self.context.startdate or self.context.startdate > date.today(): 889 self.flash( 'Application has not yet started.')901 self.flash(_('Application has not yet started.')) 890 902 self.redirect(self.url(self.context)) 891 903 return 892 904 # ... or ended 893 905 if not self.context.enddate or self.context.enddate < date.today(): 894 self.flash( 'Application has ended.')906 self.flash(_('Application has ended.')) 895 907 self.redirect(self.url(self.context)) 896 908 return … … 901 913 return 902 914 903 @action( 'Get login credentials', style='primary')915 @action(_('Get login credentials'), style='primary') 904 916 def register(self, **data): 905 917 if not self.captcha_result.is_valid: … … 916 928 # Send email with credentials 917 929 login_url = self.url(grok.getSite(), 'login') 918 msg = 'You have successfully been registered for the'930 msg = _('You have successfully been registered for the') 919 931 if sirp_utils.sendCredentials(IUserAccount(applicant), 920 932 password, login_url, msg): … … 923 935 return 924 936 else: 925 self.flash( 'Email could not been sent. Please retry later.')937 self.flash(_('Email could not been sent. Please retry later.')) 926 938 return 927 939 … … 932 944 grok.require('waeup.Public') 933 945 grok.template('applicantregemailsent') 934 label = 'Your registration was successful'946 label = _('Your registration was successful.') 935 947 936 948 def update(self, email=None): -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantdisplaypage.pt
r7710 r7714 41 41 </tbody> 42 42 </table> 43 <h3 i18n:translate="">43 <h3 i18n:domain="waeup.sirp" i18n:translate=""> 44 44 Acceptance Fee Payment Tickets 45 45 </h3> 46 <table >46 <table i18n:domain="waeup.sirp"> 47 47 <thead> 48 48 <tr> -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/pdf.py
r7438 r7714 21 21 import grok 22 22 from datetime import datetime 23 from zope.component import getUtility 24 from zope.i18n import translate 23 25 from reportlab.pdfgen import canvas 24 26 from reportlab.lib.units import cm … … 32 34 from waeup.sirp.applicants.interfaces import IApplicant 33 35 from waeup.sirp.browser import DEFAULT_PASSPORT_IMAGE_PATH 34 from waeup.sirp.interfaces import IExtFileStore, IPDF 36 from waeup.sirp.interfaces import IExtFileStore, IPDF, ISIRPUtils 37 from waeup.sirp.interfaces import MessageFactory as _ 35 38 36 39 SLIP_STYLE = TableStyle( … … 51 54 def title(self): 52 55 container_title = self.context.__parent__.title 53 return '%s Application Record %s' % ( 54 container_title, self.context.application_number) 56 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 57 ar_translation = translate(_('Application Record'), 58 'waeup.sirp', target_language=portal_language) 59 return '%s - %s %s' % (container_title, 60 ar_translation, self.context.application_number) 55 61 56 62 def _setUpWidgets(self): … … 101 107 if dept is None: 102 108 return data 103 f_label = '<font size=12>Department:</font>' 109 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 110 dp_translation = translate(_('Department:'), 111 'waeup.sirp', target_language=portal_language) 112 f_label = '<font size=12>%s</font>' % dp_translation 104 113 f_text = '<font size=12>%s</font>' % dept.longtitle() 105 114 f_label = Paragraph(f_label, style["Normal"]) … … 110 119 if faculty is None: 111 120 return data 112 f_label = '<font size=12>Faculty:</font>' 121 fc_translation = translate(_('Faculty:'), 122 'waeup.sirp', target_language=portal_language) 123 f_label = '<font size=12>%s</font>' % fc_translation 113 124 f_text = '<font size=12>%s</font>' % faculty.longtitle() 114 125 f_label = Paragraph(f_label, style["Normal"]) … … 133 144 if view is not None: 134 145 pdf.setAuthor('%s (%s)' % (view.request.principal.title, 135 146 view.request.principal.id)) 136 147 pdf.setCreator('SIRP') 137 148 width, height = A4 … … 160 171 # Render widget fields 161 172 widgets = self._setUpWidgets() 173 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 162 174 for widget in widgets: # self.widgets: 163 f_label = '<font size=12>%s</font>:' % widget.label.strip() 175 f_label = '<font size=12>%s</font>:' % translate( 176 widget.label.strip(), 'waeup.sirp', 177 target_language=portal_language) 164 178 f_label = Paragraph(f_label, style["Normal"]) 165 179 f_text = '<font size=12>%s</font>' % widget() 166 180 f_text = Paragraph(f_text, style["Normal"]) 167 181 data.append([f_label,f_text]) 168 f_label = '<font size=12>Admitted Course of Study:</font>' 182 adm_translation = translate(_('Admitted Course of Study:'), 183 'waeup.sirp', target_language=portal_language) 184 f_label = '<font size=12>%s</font>' % adm_translation 169 185 f_text = '<font size=12>%s</font>' % ( 170 186 self._getCourseAdmittedLink(view),) … … 182 198 # Add some comments 183 199 if self.context.state == 'created': 184 comment1 = (200 comment1 = _( 185 201 '<font size=10>Proceed to the login page of the portal' + 186 202 ' and enter your new credentials:' + 187 ' user name= %s, password = %s.</font>' %188 (self.context.student_id, self.context.application_number)203 ' user name= ${a}, password = ${b}.</font>', mapping = { 204 'a':self.context.student_id, 'b':self.context.application_number} 189 205 ) 190 comment2 = (206 comment2 = _( 191 207 '<font size=10>Change your password when you have ' + 192 208 ' logged in.</font>' -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/viewlets.py
r7694 r7714 71 71 grok.require('waeup.viewMyApplicationDataTab') 72 72 pnav = 3 73 tab_title = u'My Data'73 tab_title = _(u'My Data') 74 74 75 75 @property … … 86 86 grok.view(ApplicantsRootPage) 87 87 grok.require('waeup.manageApplication') 88 text = 'Manage application section'88 text = _('Manage application section') 89 89 90 90 class ApplicantsContainerManageActionButton(ManageActionButton): … … 93 93 grok.view(ApplicantsContainerPage) 94 94 grok.require('waeup.manageApplication') 95 text = 'Manage applicants container'95 text = _('Manage applicants container') 96 96 97 97 class ApplicantRegisterActionButton(ManageActionButton): … … 101 101 grok.require('waeup.Anonymous') 102 102 icon = 'actionicon_login.png' 103 text = 'Register for application'103 text = _('Register for application') 104 104 target = 'register' 105 105 … … 109 109 grok.require('waeup.viewApplication') 110 110 icon = 'actionicon_view.png' 111 text = 'View application record'111 text = _('View application record') 112 112 target = 'index' 113 113 … … 117 117 grok.view(ApplicantDisplayFormPage) 118 118 grok.require('waeup.manageApplication') 119 text = 'Manage application record'119 text = _('Manage application record') 120 120 target = 'manage' 121 121 … … 125 125 grok.view(ApplicantDisplayFormPage) 126 126 grok.require('waeup.handleApplication') 127 text = 'Edit application record'127 text = _('Edit application record') 128 128 target ='edit' 129 129 … … 141 141 grok.require('waeup.viewApplication') 142 142 icon = 'actionicon_pdf.png' 143 text = 'Download application slip'143 text = _('Download application slip') 144 144 target = 'application_slip.pdf' 145 145 … … 149 149 grok.require('waeup.manageApplication') 150 150 icon = 'actionicon_entrance.png' 151 text = 'Create student record'151 text = _('Create student record') 152 152 target ='createstudent' 153 153 … … 166 166 grok.require('waeup.viewApplication') 167 167 icon = 'actionicon_pdf.png' 168 text = 'Download payment receipt'168 text = _('Download payment receipt') 169 169 target = 'payment_receipt.pdf' 170 170 … … 181 181 grok.require('waeup.payApplicant') 182 182 icon = 'actionicon_call.png' 183 text = 'Request callback'183 text = _('Request callback') 184 184 target = 'callback' 185 185
Note: See TracChangeset for help on using the changeset viewer.