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.

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

Legend:

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

    r6744 r6915  
    3636from waeup.sirp.image import createWAeUPImageFile
    3737from waeup.sirp.image.schema import ImageFile
    38 from waeup.sirp.interfaces import IWAeUPObject
     38from waeup.sirp.interfaces import IWAeUPObject, year_range
    3939from waeup.sirp.university.vocabularies import application_categories
    4040from waeup.sirp.students.vocabularies import (
    41   year_range, lgas_vocab, CertificateSource, GenderSource,
     41  lgas_vocab, CertificateSource, GenderSource,
    4242  )
    4343from waeup.sirp.applicants.vocabularies import (
  • 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):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6896 r6915  
    44from zope.interface.exceptions import Invalid
    55from zope import schema
    6 from waeup.sirp.interfaces import IWAeUPObject
     6from waeup.sirp.interfaces import IWAeUPObject, academic_sessions_vocab
    77from waeup.sirp.schema import TextLineChoice
    88from waeup.sirp.university.vocabularies import CourseSource, study_modes
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6898 r6915  
    33
    44from random import SystemRandom as r
    5 from waeup.sirp.students.vocabularies import academic_sessions_vocab
     5from waeup.sirp.interfaces import academic_sessions_vocab
    66
    77def generate_student_id(students,letter):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py

    r6804 r6915  
    11"""Vocabularies and sources for the student section.
    22"""
    3 from datetime import datetime
    43from zope.component import getUtility, queryUtility
    54from zope.catalog.interfaces import ICatalog
     
    98from zc.sourcefactory.basic import BasicSourceFactory
    109from zc.sourcefactory.contextual import BasicContextualSourceFactory
    11 from waeup.sirp.interfaces import SimpleWAeUPVocabulary
     10from waeup.sirp.interfaces import SimpleWAeUPVocabulary, academic_sessions_vocab
    1211from waeup.sirp.students.lgas import LGAS
    1312from waeup.sirp.university.vocabularies import course_levels
    14 
    15 
    16 
    17 def year_range():
    18     curr_year = datetime.now().year
    19     return range(curr_year - 2, curr_year + 5)
    20 
    21 def academic_sessions():
    22     curr_year = datetime.now().year
    23     year_range = range(curr_year - 10, curr_year + 2)
    24     return [('%s/%s' % (year,year+1), year) for year in year_range]
    25 
    26 academic_sessions_vocab = SimpleWAeUPVocabulary(*academic_sessions())
    2713
    2814lgas_vocab = SimpleWAeUPVocabulary(
Note: See TracChangeset for help on using the changeset viewer.