Ignore:
Timestamp:
27 Feb 2012, 11:52:23 (13 years ago)
Author:
Henrik Bettermann
Message:

Start internationalization of applicants package. Store description as reST dictionary like frontpage in browsers.

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

Legend:

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

    r7687 r7708  
    147147
    148148    form_fields = grok.AutoFields(
    149         IApplicantsContainerAdd).omit('code').omit('title')
     149        IApplicantsContainerAdd).omit('code').omit('title', 'description_dict')
    150150    form_fields['startdate'].custom_widget = FriendlyDateWidget('le')
    151151    form_fields['enddate'].custom_widget = FriendlyDateWidget('le')
     
    222222    pnav = 3
    223223
    224     form_fields = grok.AutoFields(IApplicantsContainer).omit('title')
     224    form_fields = grok.AutoFields(IApplicantsContainer).omit(
     225        'title', 'description_dict')
    225226    form_fields['startdate'].custom_widget = FriendlyDateDisplayWidget('le')
    226227    form_fields['enddate'].custom_widget = FriendlyDateDisplayWidget('le')
    227228    form_fields['description'].custom_widget = ReSTDisplayWidget
     229
     230    @property
     231    def introduction(self):
     232        portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE
     233        lang = self.request.cookies.get('sirp.language', portal_language)
     234        html = self.context.description_dict.get(lang,'')
     235        if html =='':
     236            html = self.context.description_dict.get(portal_language,'')
     237        if html =='':
     238            return ''
     239        else:
     240            return html
    228241
    229242    @property
     
    235248    grok.name('manage')
    236249    grok.template('applicantscontainermanagepage')
    237     form_fields = grok.AutoFields(IApplicantsContainer).omit('title')
     250    form_fields = grok.AutoFields(IApplicantsContainer).omit(
     251        'title', 'description_dict')
    238252    taboneactions = ['Save','Cancel']
    239253    tabtwoactions = ['Add applicant', 'Remove selected','Cancel']
     
    277291        return get_users_with_local_roles(self.context)
    278292
     293    def _description(self):
     294        view = ApplicantsContainerPage(
     295            self.context,self.request)
     296        view.setUpWidgets()
     297        return view.widgets['description']()
     298
    279299    @action('Save', style='primary')
    280300    def save(self, **data):
    281301        self.applyData(self.context, **data)
     302        self.context.description_dict = self._description()
    282303        self.flash('Form has been saved.')
    283304        return
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantscontainerpage.pt

    r7477 r7708  
    1 <span tal:replace="structure view/widgets/description">Description</span>
    2 
    3 <br />
     1<span tal:condition="view/introduction" tal:omit-tag="">
     2  <span tal:content="structure view/introduction">INTRODUCTION</span>
     3  <br />
     4</span>
    45
    56<table class="form-table" tal:condition="layout/isAuthenticated">
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7688 r7708  
    3232from waeup.sirp.interfaces import (
    3333    ISIRPObject, year_range, validate_email, academic_sessions_vocab)
     34from waeup.sirp.interfaces import MessageFactory as _
    3435from waeup.sirp.university.vocabularies import (
    3536    course_levels, AppCatSource)
     
    194195
    195196    code = schema.TextLine(
    196         title = u'Code',
     197        title = _(u'Code'),
    197198        default = u'-',
    198199        required = True,
     
    201202
    202203    title = schema.TextLine(
    203         title = u'Title',
     204        title = _(u'Title'),
    204205        required = True,
    205206        default = u'-',
     
    208209
    209210    prefix = schema.Choice(
    210         title = u'Application Target',
     211        title = _(u'Application Target'),
    211212        required = True,
    212213        default = None,
     
    216217
    217218    entry_level = schema.Choice(
    218         title = u'Entry Level',
     219        title = _(u'Entry Level'),
    219220        vocabulary = course_levels,
    220221        default = 100,
     
    223224
    224225    year = schema.Choice(
    225         title = u'Year of Entrance',
     226        title = _(u'Year of Entrance'),
    226227        required = True,
    227228        default = None,
     
    231232
    232233    provider = schema.Choice(
    233         title = u'Applicants Container Type',
     234        title = _(u'Applicants Container Type'),
    234235        required = True,
    235236        default = None,
     
    247248
    248249    application_category = schema.Choice(
    249         title = u'Category for the grouping of certificates',
     250        title = _(u'Category for the grouping of certificates'),
    250251        required = True,
    251252        default = None,
     
    254255
    255256    description = schema.Text(
    256         title = u'Human readable description in reST format',
     257        title = _(u'Human readable description in reST format'),
    257258        required = False,
    258259        default = u'''This text can been seen by anonymous users.
    259 Here we put information about the study courses provided, the application procedure and deadlines.'''
     260Here we put mult-lingual information about the study courses provided, the application procedure and deadlines.
     261>>de<<
     262Dieser Text kann von anonymen Benutzern gelesen werden.
     263Hier koennen mehrsprachige Informationen fuer Antragsteller hinterlegt werden.'''
     264        )
     265
     266    description_dict = schema.Dict(
     267        title = u'Content as language dictionary with values in html format',
     268        required = False,
     269        default = {},
    260270        )
    261271
    262272    startdate = schema.Date(
    263         title = u'Application Start Date',
     273        title = _(u'Application Start Date'),
    264274        required = False,
    265275        default = None,
     
    267277
    268278    enddate = schema.Date(
    269         title = u'Application Closing Date',
     279        title = _(u'Application Closing Date'),
    270280        required = False,
    271281        default = None,
     
    273283
    274284    strict_deadline = schema.Bool(
    275         title = u'Forbid additions after deadline (enddate)',
     285        title = _(u'Forbid additions after deadline (enddate)'),
    276286        required = True,
    277287        default = True,
     
    312322    """
    313323    prefix = schema.Choice(
    314         title = u'Application Target',
     324        title = _(u'Application Target'),
    315325        required = True,
    316326        default = None,
     
    320330
    321331    year = schema.Choice(
    322         title = u'Year of Entrance',
     332        title = _(u'Year of Entrance'),
    323333        required = True,
    324334        default = None,
     
    328338
    329339    provider = schema.Choice(
    330         title = u'Applicants Container Type',
     340        title = _(u'Applicants Container Type'),
    331341        required = True,
    332342        default = None,
     
    356366
    357367    applicant_id = schema.TextLine(
    358         title = u'Applicant Id',
     368        title = _(u'Applicant Id'),
    359369        required = False,
    360370        readonly = False,
    361371        )
    362372    reg_number = TextLineChoice(
    363         title = u'JAMB Registration Number',
     373        title = _(u'JAMB Registration Number'),
    364374        readonly = False,
    365375        required = True,
     
    373383    #    )
    374384    firstname = schema.TextLine(
    375         title = u'First Name',
     385        title = _(u'First Name'),
    376386        required = True,
    377387        )
    378388    middlename = schema.TextLine(
    379         title = u'Middle Name',
     389        title = _(u'Middle Name'),
    380390        required = False,
    381391        )
    382392    lastname = schema.TextLine(
    383         title = u'Last Name (Surname)',
     393        title = _(u'Last Name (Surname)'),
    384394        required = True,
    385395        )
    386396    date_of_birth = schema.Date(
    387         title = u'Date of Birth',
     397        title = _(u'Date of Birth'),
    388398        required = True,
    389399        )
    390400    lga = schema.Choice(
    391401        source = lgas_vocab,
    392         title = u'State/LGA',
     402        title = _(u'State/LGA'),
    393403        default = 'foreigner',
    394404        required = True,
    395405        )
    396406    sex = schema.Choice(
    397         title = u'Sex',
     407        title = _(u'Sex'),
    398408        source = GenderSource(),
    399409        default = u'm',
     
    401411        )
    402412    email = schema.ASCIILine(
    403         title = u'Email Address',
     413        title = _(u'Email Address'),
    404414        required = True,
    405415        constraint=validate_email,
    406416        )
    407417    phone = schema.TextLine(
    408         title = u'Phone',
     418        title = _(u'Phone'),
    409419        description = u'',
    410420        required = False,
    411421        )
    412422    course1 = schema.Choice(
    413         title = u'1st Choice Course of Study',
     423        title = _(u'1st Choice Course of Study'),
    414424        source = CertificateSource(),
    415425        required = True,
    416426        )
    417427    course2 = schema.Choice(
    418         title = u'2nd Choice Course of Study',
     428        title = _(u'2nd Choice Course of Study'),
    419429        source = CertificateSource(),
    420430        required = False,
     
    425435    #
    426436    screening_score = schema.Int(
    427         title = u'Screening Score',
     437        title = _(u'Screening Score'),
    428438        required = False,
    429439        )
    430440    screening_venue = schema.TextLine(
    431         title = u'Screening Venue',
     441        title = _(u'Screening Venue'),
    432442        required = False,
    433443        )
    434444    course_admitted = schema.Choice(
    435         title = u'Admitted Course of Study',
     445        title = _(u'Admitted Course of Study'),
    436446        source = CertificateSource(),
    437447        default = None,
     
    439449        )
    440450    notice = schema.Text(
    441         title = u'Notice',
     451        title = _(u'Notice'),
    442452        required = False,
    443453        )
     
    461471
    462472    student_id = schema.TextLine(
    463         title = u'Student Id',
     473        title = _(u'Student Id'),
    464474        required = False,
    465475        readonly = False,
    466476        )
    467477    locked = schema.Bool(
    468         title = u'Form locked',
     478        title = _(u'Form locked'),
    469479        default = False,
    470480        )
     
    491501
    492502    course1 = schema.Choice(
    493         title = u'1st Choice Course of Study',
     503        title = _(u'1st Choice Course of Study'),
    494504        source = AppCatCertificateSource(),
    495505        required = True,
    496506        )
    497507    course2 = schema.Choice(
    498         title = u'2nd Choice Course of Study',
     508        title = _(u'2nd Choice Course of Study'),
    499509        source = AppCatCertificateSource(),
    500510        required = False,
    501511        )
    502512    screening_score = schema.Int(
    503         title = u'Screening Score',
     513        title = _(u'Screening Score'),
    504514        required = False,
    505515        readonly = True,
    506516        )
    507517    screening_venue = schema.TextLine(
    508         title = u'Screening Venue',
     518        title = _(u'Screening Venue'),
    509519        required = False,
    510520        readonly = True,
    511521        )
    512522    course_admitted = schema.Choice(
    513         title = u'Admitted Course of Study',
     523        title = _(u'Admitted Course of Study'),
    514524        source = CertificateSource(),
    515525        default = None,
     
    518528        )
    519529    notice = schema.Text(
    520         title = u'Notice',
     530        title = _(u'Notice'),
    521531        required = False,
    522532        readonly = True,
     
    545555    """
    546556    p_year = schema.Choice(
    547         title = u'Payment Session',
     557        title = _(u'Payment Session'),
    548558        source = academic_sessions_vocab,
    549559        required = False,
Note: See TracChangeset for help on using the changeset viewer.