Changeset 8502


Ignore:
Timestamp:
23 May 2012, 21:26:44 (12 years ago)
Author:
Henrik Bettermann
Message:

Use LGA source instead of vocabulary to catch LookupErrors? when LGA tuple has been changed.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
3 edited

Legend:

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

    r8454 r8502  
    2828from waeup.kofa.students.vocabularies import nats_vocab
    2929from waeup.uniben.interfaces import (
    30     lgas_vocab, high_qual, high_grade, exam_types)
     30    LGASource, high_qual, high_grade, exam_types)
    3131from waeup.uniben.interfaces import MessageFactory as _
    3232from waeup.uniben.payments.interfaces import ICustomOnlinePayment
     
    4343        )
    4444    lga = schema.Choice(
    45         source = lgas_vocab,
     45        source = LGASource(),
    4646        title = _(u'State/LGA (Nigerians only)'),
    4747        required = False,
     
    6666        )
    6767    lga = schema.Choice(
    68         source = lgas_vocab,
     68        source = LGASource(),
    6969        title = _(u'State/LGA (Nigerians only)'),
    7070        required = False,
     
    138138        )
    139139    nysc_lga = schema.Choice(
    140         source = lgas_vocab,
     140        source = LGASource(),
    141141        title = _(u'Nysc Location'),
    142142        required = False,
  • main/waeup.uniben/trunk/src/waeup/uniben/interfaces.py

    r8441 r8502  
    1919import zope.i18nmessageid
    2020from zope import schema
     21from zc.sourcefactory.basic import BasicSourceFactory
    2122from waeup.kofa.interfaces import (SimpleKofaVocabulary,
    2223    ISessionConfiguration, academic_sessions_vocab)
     
    6970    )
    7071
     72#lgas_vocab = SimpleKofaVocabulary(
     73#    *sorted([(x[1],x[0]) for x in LGAS]))
    7174
    72 lgas_vocab = SimpleKofaVocabulary(
    73     *sorted([(x[1],x[0]) for x in LGAS]))
     75class LGASource(BasicSourceFactory):
     76    """A source for school subjects used in exam documentation.
     77    """
     78    lga_dict = dict(LGAS)
     79
     80    def getValues(self):
     81        return sorted(self.lga_dict.keys())
     82
     83    def getToken(self, value):
     84        return str(value)
     85
     86    def getTitle(self, value):
     87        return self.lga_dict.get(value,
     88            _('Invalid key: ${a}', mapping = {'a':value}))
    7489
    7590# It's recommended to replicate all fields from the base package here.
  • main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py

    r8454 r8502  
    3030    nats_vocab, contextual_reg_num_source)
    3131from waeup.uniben.interfaces import (
    32     lgas_vocab, high_qual, high_grade, exam_types)
     32    high_qual, high_grade, exam_types, LGASource)
    3333from waeup.uniben.interfaces import MessageFactory as _
    3434from waeup.uniben.payments.interfaces import ICustomOnlinePayment
     35from waeup.uniben.utils.lgas import LGAS
     36
    3537
    3638class ICustomStudentBase(IStudentBase):
     
    7779
    7880    lga = schema.Choice(
    79         source = lgas_vocab,
     81        source = LGASource(),
    8082        title = _(u'State/LGA (Nigerians only)'),
    8183        required = False,
     
    269271
    270272    nysc_lga = schema.Choice(
    271         source = lgas_vocab,
     273        source = LGASource(),
    272274        title = _(u'Nysc Location'),
    273275        required = False,
Note: See TracChangeset for help on using the changeset viewer.