Ignore:
Timestamp:
20 Oct 2011, 17:14:37 (13 years ago)
Author:
Henrik Bettermann
Message:

Move year_range and academic_sessions_vocab to waeup.sirp.interfaces.

File:
1 edited

Legend:

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

    r6907 r6915  
    22## interfaces.py
    33import os
     4from datetime import datetime
    45from hurry.workflow.interfaces import IWorkflow, IWorkflowInfo
    56from zc.sourcefactory.basic import BasicSourceFactory
     
    1314        os.path.dirname(__file__), 'frontpage.rst'), 'rb').read()
    1415
     16def SimpleWAeUPVocabulary(*terms):
     17    """A well-buildt vocabulary provides terms with a value, token and
     18       title for each term
     19    """
     20    return SimpleVocabulary([
     21            SimpleTerm(value, value, title) for title, value in terms])
     22
     23def year_range():
     24    curr_year = datetime.now().year
     25    return range(curr_year - 2, curr_year + 5)
     26
     27def academic_sessions():
     28    curr_year = datetime.now().year
     29    year_range = range(curr_year - 10, curr_year + 2)
     30    return [('%s/%s' % (year,year+1), year) for year in year_range]
     31
     32academic_sessions_vocab = SimpleWAeUPVocabulary(*academic_sessions())
     33
    1534class FatalCSVError(Exception):
    1635    """Some row could not be processed.
     
    3251    def __str__(self):
    3352        return '%r' % self.msg
    34 
    35 def SimpleWAeUPVocabulary(*terms):
    36     """A well-buildt vocabulary provides terms with a value, token and
    37        title for each term
    38     """
    39     return SimpleVocabulary([
    40             SimpleTerm(value, value, title) for title, value in terms])
    4153
    4254class RoleSource(BasicSourceFactory):
     
    216228
    217229class ISessionConfiguration(IWAeUPObject):
    218     """A container for session configuration objects.
    219     """
     230    """A session configuration object.
     231    """
     232
     233    academic_session = schema.Choice(
     234        title = u'Academic Session',
     235        source = academic_sessions_vocab,
     236        default = None,
     237        required = True,
     238        readonly = True,
     239        )
     240
     241    fee_1 = schema.Int(
     242        title = u'School Fee',
     243        default = 0,
     244        )
    220245
    221246class IDataCenter(IWAeUPObject):
Note: See TracChangeset for help on using the changeset viewer.