Ignore:
Timestamp:
28 Apr 2012, 05:10:27 (13 years ago)
Author:
Henrik Bettermann
Message:

Add school fee attributes to certificate and update existing objects with a new CertificatesPlugin?.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8268 r8299  
    10091009        self.assertTrue('Student is in the wrong state'
    10101010            in self.browser.contents)
    1011         # The CA can go to his certificate throug the my_roles page
     1011        # The CA can go to his certificate through the my_roles page
    10121012        self.browser.open('http://localhost/app/users/mrsadvise/my_roles')
    10131013        self.browser.getLink(
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py

    r7819 r8299  
    2121from zope.event import notify
    2222from zope.catalog.interfaces import ICatalog
     23from zope.intid.interfaces import IIntIds
     24from zope.schema import getFields
    2325from zope.component import getUtility
    2426from zope.component.interfaces import IFactory, ComponentLookupError
    2527from zope.interface import implementedBy
     28from waeup.kofa.interfaces import IKofaPluggable
    2629from waeup.kofa.university.interfaces import (
    2730    ICertificate, ICertificateAdd, ICertificateCourse)
     
    4548    def __init__(self, code=u'NA', title=u'Unnamed Certificate',
    4649                 study_mode=None, start_level=None,
    47                  end_level=None, application_category=None):
     50                 end_level=None, application_category=None,
     51                 school_fee_1=None, school_fee_2=None):
    4852        super(Certificate, self).__init__()
    4953        self.code = code
     
    5357        self.end_level = end_level
    5458        self.application_category = application_category
     59        self.school_fee_1 = school_fee_1
     60        self.school_fee_2 = school_fee_2
    5561
    5662    def longtitle(self):
     
    147153        student.loggerInfo('ObjectRemovedEvent', 'removed: certificate')
    148154    return
     155
     156class CertificatesPlugin(grok.GlobalUtility):
     157    """A plugin that updates certificates.
     158    """
     159
     160    grok.implements(IKofaPluggable)
     161    grok.name('certificates')
     162
     163    def setup(self, site, name, logger):
     164        return
     165
     166    def update(self, site, name, logger):
     167        cat = getUtility(ICatalog, name='certificates_catalog')
     168        results = cat.apply({'code':(None,None)})
     169        uidutil = getUtility(IIntIds, context=cat)
     170        items = getFields(ICertificate).items()
     171        for r in results:
     172            o = uidutil.getObject(r)
     173            for i in items:
     174                if getattr(o,i[0],None) is None:
     175                    setattr(o,i[0],i[1].missing_value)
     176                    logger.info(
     177                        'CertificatesPlugin: %s attribute %s added.' % (
     178                        o.code,i[0]))
     179        return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r7819 r8299  
    198198    title = schema.TextLine(
    199199        title = _(u'Title'),
    200         default = _(u'Unnamed'),
     200        default = _(u'Unnamed Certificate'),
    201201        required = True,
    202202        )
     
    230230        )
    231231
     232    school_fee_1 = schema.Float(
     233        title = _(u'Initial School Fee'),
     234        required = False,
     235        )
     236
     237    school_fee_2 = schema.Float(
     238        title = _(u'Returning School Fee'),
     239        required = False,
     240        )
     241
    232242    def longtitle():
    233243        """
Note: See TracChangeset for help on using the changeset viewer.