Changeset 6087


Ignore:
Timestamp:
14 May 2011, 14:19:59 (13 years ago)
Author:
Henrik Bettermann
Message:

Adding some attributes to ApplicantsContainer?. Generate title and code of containers automatically.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
8 edited

Legend:

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

    r6085 r6087  
    4040    # The default frontpage.
    4141    frontpage= """
    42 This is the default frontpage of the portal which is written
    43 in in the `reStructuredText <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
     42This is the default frontpage of the portal written
     43in `reStructuredText (reST) <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
    4444markup language.
    4545
    46 Some reST examples for getting started:
     46Some more reST examples for getting started:
    4747
    48481. Heading
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6084 r6087  
    5252    IApplicant, IApplicantPrincipal, IApplicantPDEEditData,
    5353    IApplicantsRoot, IApplicantsContainer, IApplicantsContainerProvider,
    54     IApplicantsContainerAdd
     54    IApplicantsContainerAdd, application_types_vocab
    5555    )
    5656
     
    150150    @grok.action('Add applicants container')
    151151    def addApplicantsContainer(self, **data):
    152         if data['code'] in self.context.keys():
    153             self.status = Invalid('The name chosen already exists '
     152        year1 = unicode(data['year'])
     153        year2 = unicode(data['year']+1)
     154        code = unicode(data['prefix']) + year1
     155        title = unicode(application_types_vocab.getTerm(data['prefix']).title) + u' ' + year1 + u'/' + year2       
     156        if code in self.context.keys():
     157            self.status = Invalid('The code chosen already exists '
    154158                                  'in the database')
    155159            return
     
    158162        container = provider.factory()
    159163        self.applyData(container, **data)
    160         self.context[data['code']] = container
    161         self.flash('Added "%s".' % data['code'])
     164        container.code = code
     165        container.title = title
     166        #import pdb; pdb.set_trace()
     167        self.context[code] = container
     168        self.flash('Added "%s".' % code)
    162169        self.redirect(self.url(self.context, u'@@manage')+'#tab-1')
    163170        return
     
    210217    @property
    211218    def title(self):
    212         return "Applicants Container: %s" % getattr(
    213             self.context, '__name__', 'unnamed')
     219        return "Applicants Container: %s" % self.context.title
    214220
    215221    @property
    216222    def label(self):
    217         return self.title
    218 
     223        return self.context.title
    219224
    220225class ManageApplicantsContainerActionButton(ManageActionButton):
     
    235240    @property
    236241    def title(self):
    237         return "Manage applicants container: %s" % getattr(
    238             self.context, '__name__', 'unnamed')
     242        return "Applicants Container: %s" % self.context.title
    239243
    240244    @property
    241245    def label(self):
    242         return self.title
     246        return 'Manage applicants container'
    243247
    244248    pnav = 3
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantscontainerpage.pt

    r6069 r6087  
    1 <h2 tal:content="context/title">Title</h2>
     1<h2 tal:content="view/label">Title</h2>
    22
    33<span tal:replace="structure view/widgets/description">Title</span>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantsrootpage.pt

    r6079 r6087  
    66  <thead>
    77    <tr>
    8       <th>Code</th><th>Title</th>
     8      <th>Year</th><th>Code</th><th>Title</th>
    99    </tr>
    1010  </thead>
     
    1212    <tr tal:repeat="entry context/values"
    1313        class="gradeB">
     14      <td tal:content="entry/year">Year
     15      </td>     
    1416      <td>
    1517        <a href=""
    1618           tal:attributes="href python:view.url(entry)"
    17            tal:content="entry/__name__"
    18            >Name</a>
     19           tal:content="entry/__name__">Code</a>
    1920      </td>
    20       <td tal:content="entry/title">
    21         Title
     21      <td tal:content="entry/title">Title
    2222      </td>
    2323    </tr>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/form_manage_applicants_container.pt

    r6014 r6087  
    3131        <tbody>
    3232          <tal:block repeat="widget view/widgets">
     33            <tal:condition condition="python:widget.name not in ['form.title']">
    3334            <tr>
    3435              <td class="label" tal:define="hint widget/hint">
     
    5556              </td>
    5657            </tr>
     58            </tal:condition>
    5759          </tal:block>
    5860        </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r6076 r6087  
    55## $Id$
    66##
    7 ## Copyright (C) 2011 Uli Fouquet
     7## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
    88## This program is free software; you can redistribute it and/or modify
    99## it under the terms of the GNU General Public License as published by
     
    3434from waeup.sirp.image.image import WAeUPImageFile
    3535from waeup.sirp.interfaces import IWAeUPObject, SimpleWAeUPVocabulary
     36from waeup.sirp.university.vocabularies import FutureYearsSource
    3637
    3738
     
    4950    )
    5051
    51 #: Categories of applications we support.
    52 #: Yet not complete nor correct.
    53 APPLICATION_CATEGORIES = (
    54     ('Direct Entry Screening Exam (PDE)', 'pde'),
    55     ('Post-UME', 'pume'),
    56     ('Post-UDE', 'pude'),
    57     ('PCE', 'pce'),
     52#: Types of applications we support.
     53APPLICATION_TYPES = (
     54    ('Pre-NCE Programme', 'prence'),
     55    ('Post UME Screening Test', 'pume'),
     56    ('Post UDE Screening', 'pude'),
     57    ('Part Time Degree in Education', 'sandwich'),
     58    ('Part-Time Degree Programmes', 'pt'),
     59    ('Diploma Programmes', 'dp'),
     60    ('PCE Screening', 'pce'),
     61    ('Certificate Programmes', 'ct'),
    5862    ('Common Entry Screening Test (CEST)', 'cest'),
    5963    )
    6064
    6165#: A :class:`waeup.sirp.interfaces.SimpleWAeUPVocabulary` of supported
    62 #: application categories.
    63 application_categories_vocab = SimpleWAeUPVocabulary(*APPLICATION_CATEGORIES)
     66#: application or screening types.
     67application_types_vocab = SimpleWAeUPVocabulary(*APPLICATION_TYPES)
    6468
    6569class GenderSource(BasicSourceFactory):
     
    152156    code = schema.TextLine(
    153157        title = u'Code',
    154         description = u'Abbreviated code of applicants container',
    155         default = u'NA',
    156         required = True,
    157         readonly = True,
    158         )
     158        default = u'-',
     159        required = True,
     160        readonly = True,
     161        )
     162       
     163    title = schema.TextLine(
     164        title = u'Title',
     165        required = True,
     166        default = u'-',
     167        readonly = True,
     168        )       
     169       
     170    prefix = schema.Choice(
     171        title = u'Application target',
     172        required = True,
     173        default = None,
     174        source = application_types_vocab,
     175        readonly = True,
     176        )
     177
     178    year = schema.Choice(
     179        title = u'Year of entrance',
     180        required = True,
     181        default = None,
     182        source = FutureYearsSource(),
     183        readonly = True,
     184        )               
    159185
    160186    provider = schema.Choice(
     
    163189        default = None,
    164190        source = ApplicantContainerProviderSource(),
    165         )
    166 
    167     title = schema.TextLine(
    168         title = u'Title of the type of applicants stored here',
    169         required = True,
    170         default = u'Untitled',
     191        readonly = True,
    171192        )
    172193
     
    228249    """An applicants container contains university applicants.
    229250    """
    230     code = schema.TextLine(
    231         title = u'Code',
    232         description = u'Abbreviated code of applicants container',
    233         default = u'NA',
    234         required = True,
     251    prefix = schema.Choice(
     252        title = u'Application target',
     253        required = True,
     254        default = None,
     255        source = application_types_vocab,
    235256        readonly = False,
    236257        )
    237258
    238 IApplicantsContainerAdd['code'].order =  IApplicantsContainer['code'].order
     259    year = schema.Choice(
     260        title = u'Year of entrance',
     261        required = True,
     262        default = None,
     263        source = FutureYearsSource(),
     264        readonly = False,
     265        )               
     266
     267    provider = schema.Choice(
     268        title = u'Applicants container type',
     269        required = True,
     270        default = None,
     271        source = ApplicantContainerProviderSource(),
     272        readonly = False,
     273        )
     274
     275IApplicantsContainerAdd['prefix'].order =  IApplicantsContainer['prefix'].order
     276IApplicantsContainerAdd['year'].order =  IApplicantsContainer['year'].order
     277IApplicantsContainerAdd['provider'].order =  IApplicantsContainer['provider'].order
    239278
    240279class IApplicantBaseData(IWAeUPObject):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_interfaces.py

    r5755 r6087  
    3131from waeup.sirp.applicants import interfaces
    3232from waeup.sirp.applicants.interfaces import (
    33     APPLICATION_CATEGORIES, application_categories_vocab, GenderSource,
     33    APPLICATION_TYPES, application_types_vocab, GenderSource,
    3434    )
    3535
     
    3737
    3838    def setUp(self):
    39         self.vocab = application_categories_vocab
     39        self.vocab = application_types_vocab
    4040        return
    4141   
  • main/waeup.sirp/trunk/src/waeup/sirp/university/vocabularies.py

    r5988 r6087  
    1010    from zope.app.catalog.interfaces import ICatalog
    1111from zope.component import getUtility
     12import datetime
    1213
    1314inst_types = SimpleWAeUPVocabulary(
     
    7475        return "%s - %s" % (value.code, value.title[:64])
    7576       
     77       
     78       
     79class FutureYearsSource(BasicSourceFactory):
     80    """
     81    """
     82    def getValues(self):
     83        cy = datetime.datetime.now().year
     84        return [x for x in range(cy-2,cy+5)]
     85
     86    def getToken(self, value):
     87        return str(value)
     88
     89    def getTitle(self, value):
     90      return str(value)     
     91       
    7692                                                             
Note: See TracChangeset for help on using the changeset viewer.