Changeset 8008 for main/waeup.kofa


Ignore:
Timestamp:
30 Mar 2012, 10:23:32 (13 years ago)
Author:
Henrik Bettermann
Message:

Remove all ApplicantsContainerProvider? components. Experience has shown that we only need one type of ApplicantsContainers? and one type of Applicants but with different interfaces for form generation.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py

    r7933 r8008  
    8181    name = u'Applicant Processor'
    8282    iface = IApplicant
    83     location_fields = []
     83    location_fields = ['container_code']
    8484    factory_name = 'waeup.Applicant'
    85     location_fields = ['container_code']
    8685
    8786    mode = None
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r7997 r8008  
    2727from hurry.workflow.interfaces import (
    2828    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
     29from waeup.kofa.applicants.container import ApplicantsContainer
    2930from waeup.kofa.applicants.interfaces import (
    3031    IApplicant, IApplicantEdit, IApplicantsRoot,
     
    169170            return
    170171        # Add new applicants container...
    171         provider = data['provider'][1]
    172         container = provider.factory()
     172        container = ApplicantsContainer()
    173173        self.applyData(container, **data)
    174174        container.code = code
     
    363363    @action(_('Create application record'))
    364364    def addApplicant(self, **data):
    365         applicant = createObject(self.context.factory_name)
     365        applicant = createObject(u'waeup.Applicant')
    366366        self.applyData(applicant, **data)
    367367        self.context.addApplicant(applicant)
     
    921921            return
    922922        # Add applicant and create password
    923         applicant = createObject(self.context.factory_name)
     923        applicant = createObject(u'waeup.Applicant')
    924924        self.applyData(applicant, **data)
    925925        self.context.addApplicant(applicant)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py

    r7903 r8008  
    2525from waeup.kofa.interfaces import MessageFactory as _
    2626from waeup.kofa.applicants.interfaces import (
    27     IApplicantsContainer, IApplicantsContainerAdd,
    28     IApplicantsContainerProvider, IApplicant
     27    IApplicantsContainer, IApplicantsContainerAdd, IApplicant
    2928    )
    3029from waeup.kofa.utils.helpers import attrs_to_fields
     
    4544    grok.implements(IApplicantsContainer,IApplicantsContainerAdd)
    4645
    47     #: These are 'class-attributes'. Do not fiddle around with it in
    48     #: instances of this class.
    49     #:
    50     #: The title of this container as displayed in add-forms. It should
    51     #: give some idea about what kind of container this is (one or two words)
    52     container_title = _(u'Basic')
    53     #: The `container_description` gives a short explanation about for what
    54     #: purposes this container type serves (a few words only).
    55     container_description = _(u'handles basic applicants')
    56     #: `iface` is the interface of the child objects.
    57     iface = IApplicant
    58     #: The name of the child object factory. This name is used in views
    59     #: to create proper applicant objects.
    60     factory_name = 'waeup.Applicant'
    6146    #: A dictionary to hold per language translations of description string.
    6247    description_dict = {}
     
    10186        """Add an applicant.
    10287        """
    103         if not self.iface.providedBy(applicant):
     88        if not IApplicant.providedBy(applicant):
    10489            raise TypeError(
    105                 '%s containers contain only %s instances' %(
    106                 self.container_title, self.iface))
     90                'ApplicantsContainers contain only IApplicant instances')
    10791        applicant_id = generate_applicant_id(container=self)
    10892        applicant.applicant_id = applicant_id
     
    11296ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
    11397
    114 class ApplicantsContainerProvider(grok.GlobalUtility):
    115     """A utility that provides basic applicants containers.
     98# ApplicantsContainers must be importable. So we need a factory.
     99class ApplicantsContainerFactory(grok.GlobalUtility):
     100    """A factory for student online payments.
    116101    """
    117     grok.implements(IApplicantsContainerProvider)
    118     grok.name('waeup.kofa.applicants.ApplicantsContainer')
     102    grok.implements(IFactory)
     103    grok.name(u'waeup.ApplicantsContainer')
     104    title = u"Create a new container for applicants.",
     105    description = u"This factory instantiates new IApplicantsContainer instances."
    119106
    120     #: The applicants container type this provider provides:
    121     #: :class:`ApplicantsContainer`.
    122     factory = ApplicantsContainer
     107    def __call__(self, *args, **kw):
     108        return ApplicantsContainer()
    123109
    124 factory = Factory(lambda : ApplicantsContainer, 'ApplicantsContainer')
    125 grok.global_utility(factory, IFactory, name='waeup.ApplicantsContainer')
     110    def getInterfaces(self):
     111        return implementedBy(ApplicantsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py

    r7924 r8008  
    3434    #: Fieldnames considered by this exporter
    3535    fields = ('code', 'title', 'prefix', 'entry_level', 'year',
    36               'provider', 'application_category', 'description',
     36              'application_category', 'description',
    3737              'startdate', 'enddate', 'strict_deadline')
    3838
     
    4141
    4242    def mangle_value(self, value, name, context=None):
    43         if name == 'provider' and isinstance(value, tuple):
    44             value = value[0]
    4543        return super(
    4644            ApplicantsContainerExporter, self).mangle_value(
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r7984 r8008  
    189189    """
    190190
    191     container_title = Attribute(
    192         u'classattribute: title for type of container')
    193     container_description = Attribute(
    194         u'classattribute: description for type of container')
    195 
    196 
    197191    code = schema.TextLine(
    198192        title = _(u'Code'),
    199         #default = u'-',
    200193        required = True,
    201194        readonly = True,
     
    205198        title = _(u'Title'),
    206199        required = True,
    207         #default = u'-',
    208200        readonly = True,
    209201        )
     
    213205        required = True,
    214206        source = ApplicationTypeSource(),
     207        readonly = True,
     208        )
     209
     210    year = schema.Choice(
     211        title = _(u'Year of Entrance'),
     212        required = True,
     213        values = year_range(),
    215214        readonly = True,
    216215        )
     
    219218        title = _(u'Entry Level'),
    220219        vocabulary = course_levels,
    221         #default = 100,
    222         required = True,
    223         )
    224 
    225     year = schema.Choice(
    226         title = _(u'Year of Entrance'),
    227         required = True,
    228         values = year_range(),
    229         readonly = True,
    230         )
    231 
    232     provider = schema.Choice(
    233         title = _(u'Applicants Container Type'),
    234         required = True,
    235         source = ApplicantContainerProviderSource(),
    236         readonly = True,
     220        required = True,
    237221        )
    238222
     
    327311        )
    328312
    329     provider = schema.Choice(
    330         title = _(u'Applicants Container Type'),
    331         required = True,
    332         source = ApplicantContainerProviderSource(),
    333         readonly = False,
    334         )
    335 
    336313IApplicantsContainerAdd[
    337314    'prefix'].order =  IApplicantsContainer['prefix'].order
    338315IApplicantsContainerAdd[
    339316    'year'].order =  IApplicantsContainer['year'].order
    340 IApplicantsContainerAdd[
    341     'provider'].order =  IApplicantsContainer['provider'].order
    342317
    343318class IApplicantBaseData(IKofaObject):
     
    553528    'p_year'].order
    554529
    555 class IApplicantsContainerProvider(Interface):
    556     """A provider for applicants containers.
    557 
    558     Applicants container providers are meant to be looked up as
    559     utilities. This way we can find all applicant container types
    560     defined somewhere.
    561 
    562     Each applicants container provider registered as utility provides
    563     one container type and one should be able to call the `factory`
    564     attribute to create an instance of the requested container type.
    565 
    566     .. THE FOLLOWING SHOULD GO INTO SPHINX DOCS (and be tested)
    567 
    568     Samples:
    569 
    570     Given, you had an IApplicantsContainer implementation somewhere
    571     and you would like to make it findable on request, then you would
    572     normally create an appropriate provider utility like this::
    573 
    574       import grok
    575       from waeup.kofa.applicants.interfaces import IApplicantsContainerProvider
    576 
    577       class MyContainerProvider(grok.GlobalUtility):
    578           grok.implements(IApplicantsContainerProvider)
    579           grok.name('MyContainerProvider') # Must be unique
    580           factory = MyContainer # A class implementing IApplicantsContainer
    581                                 # or derivations thereof.
    582 
    583     This utility would be registered on startup and could then be used
    584     like this:
    585 
    586       >>> from zope.component import getAllUtilitiesRegisteredFor
    587       >>> from waeup.kofa.applicants.interfaces import (
    588       ...     IApplicantsContainerProvider)
    589       >>> all_providers = getAllUtilitiesRegisteredFor(
    590       ...     IApplicantsContainerProvider)
    591       >>> all_providers
    592       [<MyContainerProvider object at 0x...>]
    593 
    594     You could look up this specific provider by name:
    595 
    596       >>> from zope.component import getUtility
    597       >>> p = getUtility(IApplicantsContainerProvider, name='MyProvider')
    598       >>> p
    599       <MyContainerProvider object at 0x...>
    600 
    601     An applicants container would then be created like this:
    602 
    603       >>> provider = all_providers[0]
    604       >>> container = provider.factory()
    605       >>> container
    606       <MyContainer object at 0x...>
    607 
    608     """
    609     factory = Attribute("A class that can create instances of the "
    610                         "requested container type")
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r7933 r8008  
    151151        self.assertEqual(container.entry_level, 100)
    152152        self.assertEqual(container.year, 2012)
    153         self.assertEqual(
    154             container.provider[0],
    155             u'waeup.kofa.applicants.ApplicantsContainer')
    156153        self.assertEqual(container.application_category, 'basic')
    157154        self.assertEqual(
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r7997 r8008  
    248248        self.browser.getControl(name="form.year").value = ['2010']
    249249        self.browser.getControl(name="form.entry_level").value = ['100']
    250         self.browser.getControl(name="form.provider").value = [
    251             'waeup.kofa.applicants.ApplicantsContainer']
    252250        self.browser.getControl(
    253251            name="form.application_category").value = ['basic']
     
    264262        self.browser.getControl(name="form.year").value = ['2010']
    265263        self.browser.getControl(name="form.entry_level").value = ['100']
    266         self.browser.getControl(name="form.provider").value = [
    267             'waeup.kofa.applicants.ApplicantsContainer']
    268264        self.browser.getControl(
    269265            name="form.application_category").value = ['basic']
     
    280276        self.browser.getControl(name="form.year").value = ['2010']
    281277        self.browser.getControl(name="form.entry_level").value = ['100']
    282         self.browser.getControl(name="form.provider").value = [
    283             'waeup.kofa.applicants.ApplicantsContainer']
    284278        #self.browser.getControl(name="form.ac_prefix").value = ['APP']
    285279        self.browser.getControl(
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py

    r7984 r8008  
    1212    ApplicantsContainerExporter, ApplicantsExporter)
    1313from waeup.kofa.applicants.interfaces import (
    14     IApplicantsContainerProvider, AppCatSource, ApplicationTypeSource)
     14    AppCatSource, ApplicationTypeSource)
    1515from waeup.kofa.applicants.tests.test_batching import (
    1616    ApplicantImportExportSetup)
     
    5353        container.year = 2012
    5454        container.entry_level = 100
    55         provider = [
    56             x for x in getUtilitiesFor(IApplicantsContainerProvider)
    57             if x[0] == 'waeup.kofa.applicants.ApplicantsContainer'][0]
    58         container.provider = provider
    5955        container.application_category = list(AppCatSource()(container))[0]
    6056        container.description = u'Some Description\nwith linebreak\n'
     
    7369        self.assertEqual(
    7470            result,
    75             'code,title,prefix,entry_level,year,provider,application_category,'
     71            'code,title,prefix,entry_level,year,application_category,'
    7672            'description,startdate,enddate,strict_deadline\r\n'
    7773
    78             'dp2012,General Studies 2012/13,app,100,2012,'
    79             'waeup.kofa.applicants.ApplicantsContainer,basic,'
     74            'dp2012,General Studies 2012/13,app,100,2012,basic,'
    8075            '"Some Description\nwith linebreak\n<<de>>man spriht deutsh",'
    8176            '2012-01-01,2012-01-31,1\r\n'
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r7993 r8008  
    257257        )
    258258
    259 class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,IStudentPersonal):
     259class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,
     260    IStudentPersonal):
    260261    """Representation of a student.
    261262
Note: See TracChangeset for help on using the changeset viewer.