Ignore:
Timestamp:
28 Feb 2012, 10:34:16 (13 years ago)
Author:
Henrik Bettermann
Message:

Continue internat. of applicants package including pdf exports.

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  
    2525from zope.component import getUtility, createObject, getAdapter
    2626from zope.formlib.form import setUpEditWidgets
     27from zope.i18n import translate
    2728from hurry.workflow.interfaces import (
    2829    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
     
    297298        return view.widgets['description']()
    298299
    299     @action('Save', style='primary')
     300    @action(_('Save'), style='primary')
    300301    def save(self, **data):
    301302        self.applyData(self.context, **data)
     
    356357        'firstname', 'middlename', 'lastname',
    357358        'email', 'phone')
    358     label = 'Add applicant'
     359    label = _('Add applicant')
    359360    pnav = 3
    360361
    361     @action('Create application record')
     362    @action(_('Create application record'))
    362363    def addApplicant(self, **data):
    363364        applicant = createObject(u'waeup.Applicant')
    364365        self.applyData(applicant, **data)
    365366        self.context.addApplicant(applicant)
    366         self.flash('Applicant record created.')
     367        self.flash(_('Applicant record created.'))
    367368        self.redirect(
    368369            self.url(self.context[applicant.application_number], 'index'))
     
    377378        'locked', 'course_admitted', 'password')
    378379    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    379     label = 'Applicant'
     380    label = _('Applicant')
    380381    pnav = 3
    381382
     
    392393    def hasPassword(self):
    393394        if self.context.password:
    394             return 'set'
    395         return 'unset'
     395            return _('set')
     396        return _('unset')
    396397
    397398    @property
    398399    def label(self):
    399400        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})
    402403
    403404    def getCourseAdmitted(self):
     
    449450            academic_session = grok.getSite()['configuration'][session]
    450451        except KeyError:
    451             self.flash('Session configuration object is not available.')
     452            self.flash(_('Session configuration object is not available.'))
    452453            return
    453454        timestamp = "%d" % int(time()*1000)
     
    456457            if ticket.p_state == 'paid':
    457458                  self.flash(
    458                       'This type of payment has already been made.')
     459                      _('This type of payment has already been made.'))
    459460                  self.redirect(self.url(self.context))
    460461                  return
     
    469470        payment.surcharge_3 = academic_session.surcharge_3
    470471        self.context[payment.p_id] = payment
    471         self.flash('Payment ticket created.')
     472        self.flash(_('Payment ticket created.'))
    472473        return
    473474
     
    496497    @property
    497498    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})
    500501
    501502class OnlinePaymentCallbackPage(UtilityView, grok.View):
     
    524525        self.context.__parent__.loggerInfo(
    525526            ob_class, 'valid callback: %s' % self.context.p_id)
    526         self.flash('Valid callback received.')
     527        self.flash(_('Valid callback received.'))
    527528        return
    528529
     
    541542    form_fields['payment_date'].custom_widget = FriendlyDateDisplayWidget('le')
    542543    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)
    544550
    545551    @property
    546552    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
    548557
    549558    def render(self):
    550559        if self.context.p_state != 'paid':
    551             self.flash('Ticket not yet paid.')
     560            self.flash(_('Ticket not yet paid.'))
    552561            self.redirect(self.url(self.context))
    553562            return
     
    569578    prefix = 'form'
    570579
    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    #        )
    596607
    597608    def render(self):
     
    612623    size = file_size(upload)
    613624    if size > MAX_UPLOAD_SIZE:
    614         view.flash('Uploaded image is too big!')
     625        view.flash(_('Uploaded image is too big!'))
    615626        return False
    616627    dummy, ext = os.path.splitext(upload.filename)
    617628    ext.lower()
    618629    if ext != '.jpg':
    619         view.flash('jpg file extension expected.')
     630        view.flash(_('jpg file extension expected.'))
    620631        return False
    621632    upload.seek(0) # file pointer moved when determining size
     
    639650    manage_applications = True
    640651    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')]]
    643654
    644655    def update(self):
     
    659670    def label(self):
    660671        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})
    663674
    664675    def getTransitions(self):
     
    673684            dict(name=x, title=y) for x, y in allowed_transitions]
    674685
    675     @action('Save', style='primary')
     686    @action(_('Save'), style='primary')
    676687    def save(self, **data):
    677688        form = self.request.form
     
    702713        if trans_id:
    703714            self.wf_info.fireTransition(trans_id)
    704         self.flash('Form has been saved.')
     715        self.flash(_('Form has been saved.'))
    705716        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    706717        if fields_string:
     
    717728            child_id = form['val_id']
    718729        else:
    719             self.flash('No payment selected.')
     730            self.flash(_('No payment selected.'))
    720731            self.redirect(self.url(self.context))
    721732            return
     
    730741                    deleted.append(id)
    731742                except:
    732                     self.flash('Could not delete %s: %s: %s' % (
     743                    self.flash(_('Could not delete:') + ' %s: %s: %s' % (
    733744                            id, sys.exc_info()[0], sys.exc_info()[1]))
    734745        if len(deleted):
    735             self.flash('Successfully removed: %s' % ', '.join(deleted))
     746            self.flash(_('Successfully removed:') + ' %s' % ', '.join(deleted))
    736747            ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    737748            self.context.loggerInfo(
     
    742753    # can be created. If no validation is requested, use
    743754    # 'validator=NullValidator' in the action directive
    744     @action('Add online payment ticket')
     755    @action(_('Add online payment ticket'))
    745756    def addPaymentTicket(self, **data):
    746757        self.redirect(self.url(self.context, '@@addafp'))
    747758        return
    748759
    749     @jsaction('Remove selected tickets')
     760    @jsaction(_('Remove selected tickets'))
    750761    def removePaymentTickets(self, **data):
    751762        self.delPaymentTickets(**data)
     
    775786            actions = [[],[]]
    776787        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')]]
    779790        elif state == PAID:
    780             actions = [['Save', 'Final Submit'],
    781                        ['Remove selected tickets']]
     791            actions = [[_('Save'), _('Final Submit')],
     792                [_('Remove selected tickets')]]
    782793        else:
    783794            actions = [[],[]]
     
    789800
    790801    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).'))
    792803        self.redirect(self.url(self.context))
    793804        return
     
    803814        store = getUtility(IExtFileStore)
    804815        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
    805             return 'No passport picture uploaded.'
     816            return _('No passport picture uploaded.')
    806817        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.')
    808819        return False
    809820
     
    811822    # can be created. If no validation is requested, use
    812823    # 'validator=NullValidator' in the action directive
    813     @action('Add online payment ticket')
     824    @action(_('Add online payment ticket'))
    814825    def addPaymentTicket(self, **data):
    815826        self.redirect(self.url(self.context, '@@addafp'))
    816827        return
    817828
    818     @jsaction('Remove selected tickets')
     829    @jsaction(_('Remove selected tickets'))
    819830    def removePaymentTickets(self, **data):
    820831        self.delPaymentTickets(**data)
     
    822833        return
    823834
    824     @action('Save')
     835    @action(_('Save'))
    825836    def save(self, **data):
    826837        if self.passport_changed is False:  # False is not None!
     
    830841        return
    831842
    832     @action('Final Submit')
     843    @action(_('Final Submit'))
    833844    def finalsubmit(self, **data):
    834845        if self.passport_changed is False:  # False is not None!
     
    842853        # might have forgotten to lock the form after changing the state
    843854        if state != PAID:
    844             self.flash('This form cannot be submitted. Wrong state!')
     855            self.flash(_('This form cannot be submitted. Wrong state!'))
    845856            return
    846857        IWorkflowInfo(self.context).fireTransition('submit')
    847858        self.context.application_date = datetime.now()
    848859        self.context.locked = True
    849         self.flash('Form has been submitted.')
     860        self.flash(_('Form has been submitted.'))
    850861        self.redirect(self.url(self.context))
    851862        return
     
    882893    @property
    883894    def label(self):
    884         return "Register for %s Application" % self.context.title
     895        return _('Register for ${a} Application',
     896            mapping = {'a':self.context.title})
    885897
    886898    def update(self):
    887899        # Check if application has started ...
    888900        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.'))
    890902            self.redirect(self.url(self.context))
    891903            return
    892904        # ... or ended
    893905        if not self.context.enddate or self.context.enddate < date.today():
    894             self.flash('Application has ended.')
     906            self.flash(_('Application has ended.'))
    895907            self.redirect(self.url(self.context))
    896908            return
     
    901913        return
    902914
    903     @action('Get login credentials', style='primary')
     915    @action(_('Get login credentials'), style='primary')
    904916    def register(self, **data):
    905917        if not self.captcha_result.is_valid:
     
    916928        # Send email with credentials
    917929        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')
    919931        if sirp_utils.sendCredentials(IUserAccount(applicant),
    920932            password, login_url, msg):
     
    923935            return
    924936        else:
    925             self.flash('Email could not been sent. Please retry later.')
     937            self.flash(_('Email could not been sent. Please retry later.'))
    926938        return
    927939
     
    932944    grok.require('waeup.Public')
    933945    grok.template('applicantregemailsent')
    934     label = 'Your registration was successful'
     946    label = _('Your registration was successful.')
    935947
    936948    def update(self, email=None):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantdisplaypage.pt

    r7710 r7714  
    4141  </tbody>
    4242</table>
    43 <h3 i18n:translate="">
     43<h3  i18n:domain="waeup.sirp" i18n:translate="">
    4444    Acceptance Fee Payment Tickets
    4545</h3>
    46 <table>
     46<table i18n:domain="waeup.sirp">
    4747  <thead>
    4848    <tr>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/pdf.py

    r7438 r7714  
    2121import grok
    2222from datetime import datetime
     23from zope.component import getUtility
     24from zope.i18n import translate
    2325from reportlab.pdfgen import canvas
    2426from reportlab.lib.units import cm
     
    3234from waeup.sirp.applicants.interfaces import IApplicant
    3335from waeup.sirp.browser import DEFAULT_PASSPORT_IMAGE_PATH
    34 from waeup.sirp.interfaces import IExtFileStore, IPDF
     36from waeup.sirp.interfaces import IExtFileStore, IPDF, ISIRPUtils
     37from waeup.sirp.interfaces import MessageFactory as _
    3538
    3639SLIP_STYLE = TableStyle(
     
    5154    def title(self):
    5255        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)
    5561
    5662    def _setUpWidgets(self):
     
    101107        if dept is None:
    102108            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
    104113        f_text = '<font size=12>%s</font>' % dept.longtitle()
    105114        f_label = Paragraph(f_label, style["Normal"])
     
    110119        if faculty is None:
    111120            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
    113124        f_text = '<font size=12>%s</font>' % faculty.longtitle()
    114125        f_label = Paragraph(f_label, style["Normal"])
     
    133144        if view is not None:
    134145            pdf.setAuthor('%s (%s)' % (view.request.principal.title,
    135                                       view.request.principal.id))
     146                view.request.principal.id))
    136147        pdf.setCreator('SIRP')
    137148        width, height = A4
     
    160171        # Render widget fields
    161172        widgets = self._setUpWidgets()
     173        portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE
    162174        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)
    164178            f_label = Paragraph(f_label, style["Normal"])
    165179            f_text = '<font size=12>%s</font>' % widget()
    166180            f_text = Paragraph(f_text, style["Normal"])
    167181            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
    169185        f_text = '<font size=12>%s</font>' % (
    170186            self._getCourseAdmittedLink(view),)
     
    182198        # Add some comments
    183199        if self.context.state == 'created':
    184             comment1 = (
     200            comment1 = _(
    185201                '<font size=10>Proceed to the login page of the portal' +
    186202                ' 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}
    189205                )
    190             comment2 = (
     206            comment2 = _(
    191207                '<font size=10>Change your password when you have ' +
    192208                ' logged in.</font>'
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/viewlets.py

    r7694 r7714  
    7171    grok.require('waeup.viewMyApplicationDataTab')
    7272    pnav = 3
    73     tab_title = u'My Data'
     73    tab_title = _(u'My Data')
    7474
    7575    @property
     
    8686    grok.view(ApplicantsRootPage)
    8787    grok.require('waeup.manageApplication')
    88     text = 'Manage application section'
     88    text = _('Manage application section')
    8989
    9090class ApplicantsContainerManageActionButton(ManageActionButton):
     
    9393    grok.view(ApplicantsContainerPage)
    9494    grok.require('waeup.manageApplication')
    95     text = 'Manage applicants container'
     95    text = _('Manage applicants container')
    9696
    9797class ApplicantRegisterActionButton(ManageActionButton):
     
    101101    grok.require('waeup.Anonymous')
    102102    icon = 'actionicon_login.png'
    103     text = 'Register for application'
     103    text = _('Register for application')
    104104    target = 'register'
    105105
     
    109109    grok.require('waeup.viewApplication')
    110110    icon = 'actionicon_view.png'
    111     text = 'View application record'
     111    text = _('View application record')
    112112    target = 'index'
    113113
     
    117117    grok.view(ApplicantDisplayFormPage)
    118118    grok.require('waeup.manageApplication')
    119     text = 'Manage application record'
     119    text = _('Manage application record')
    120120    target = 'manage'
    121121
     
    125125    grok.view(ApplicantDisplayFormPage)
    126126    grok.require('waeup.handleApplication')
    127     text = 'Edit application record'
     127    text = _('Edit application record')
    128128    target ='edit'
    129129
     
    141141    grok.require('waeup.viewApplication')
    142142    icon = 'actionicon_pdf.png'
    143     text = 'Download application slip'
     143    text = _('Download application slip')
    144144    target = 'application_slip.pdf'
    145145
     
    149149    grok.require('waeup.manageApplication')
    150150    icon = 'actionicon_entrance.png'
    151     text = 'Create student record'
     151    text = _('Create student record')
    152152    target ='createstudent'
    153153
     
    166166    grok.require('waeup.viewApplication')
    167167    icon = 'actionicon_pdf.png'
    168     text = 'Download payment receipt'
     168    text = _('Download payment receipt')
    169169    target = 'payment_receipt.pdf'
    170170
     
    181181    grok.require('waeup.payApplicant')
    182182    icon = 'actionicon_call.png'
    183     text = 'Request callback'
     183    text = _('Request callback')
    184184    target = 'callback'
    185185
Note: See TracChangeset for help on using the changeset viewer.