Changeset 8503


Ignore:
Timestamp:
23 May 2012, 21:27:37 (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.aaue/trunk/src/waeup/aaue
Files:
3 edited

Legend:

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

    r8455 r8503  
    2828from waeup.kofa.students.vocabularies import nats_vocab
    2929from waeup.aaue.interfaces import (
    30     lgas_vocab, high_qual, high_grade, exam_types)
     30    LGASource, high_qual, high_grade, exam_types)
    3131from waeup.aaue.interfaces import MessageFactory as _
    3232from waeup.aaue.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.aaue/trunk/src/waeup/aaue/interfaces.py

    r8444 r8503  
    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.aaue/trunk/src/waeup/aaue/students/interfaces.py

    r8455 r8503  
    3030    nats_vocab, contextual_reg_num_source)
    3131from waeup.aaue.interfaces import (
    32     lgas_vocab, high_qual, high_grade, exam_types)
     32    high_qual, high_grade, exam_types, LGASource)
    3333from waeup.aaue.interfaces import MessageFactory as _
    3434from waeup.aaue.payments.interfaces import ICustomOnlinePayment
     35from waeup.aaue.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.