Ignore:
Timestamp:
21 Sep 2012, 16:10:59 (12 years ago)
Author:
Henrik Bettermann
Message:

Changes made in r9170 were missing after merging azync stuff with trunk, don't know why.

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

Legend:

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

    r9217 r9220  
    6363        self.state = context.state
    6464        self.translated_state = context.translated_state
    65         try:
    66             current_level = course_levels.getTerm(
    67                 context['studycourse'].current_level).title
    68         except LookupError:
    69             current_level = None
    70         self.current_level = current_level
     65        self.current_level = context['studycourse'].current_level
    7166        try:
    7267            current_session = academic_sessions_vocab.getTerm(
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r9217 r9220  
    2121from zope.catalog.interfaces import ICatalog
    2222from zope.interface import implementedBy
     23from zope.schema import getFields
     24from zope.intid.interfaces import IIntIds
    2325from zope.component import getUtility
    2426from zope.component.interfaces import IFactory, ComponentLookupError
     27from waeup.kofa.interfaces import IKofaPluggable
    2528from waeup.kofa.university.interfaces import ICourse, ICourseAdd
    2629
     
    3740                 credits=0,
    3841                 passmark=40,
    39                  semester=1, **kw):
     42                 semester=1,
     43                 former_course=False,
     44                 **kw):
    4045        super(Course, self).__init__(**kw)
    4146        self.title = title
     
    4449        self.passmark = passmark
    4550        self.semester = semester
     51        self.former_course = former_course
    4652
    4753    def longtitle(self):
     
    8389        cert._p_changed = True
    8490    return
     91
     92class CoursesPlugin(grok.GlobalUtility):
     93    """A plugin that updates courses.
     94    """
     95
     96    grok.implements(IKofaPluggable)
     97    grok.name('courses')
     98
     99    deprecated_attributes = []
     100
     101    def setup(self, site, name, logger):
     102        return
     103
     104    def update(self, site, name, logger):
     105        cat = getUtility(ICatalog, name='courses_catalog')
     106        results = cat.apply({'code':(None,None)})
     107        uidutil = getUtility(IIntIds, context=cat)
     108        items = getFields(ICourse).items()
     109        for r in results:
     110            o = uidutil.getObject(r)
     111            # Add new attributes
     112            for i in items:
     113                if not hasattr(o,i[0]):
     114                    setattr(o,i[0],i[1].missing_value)
     115                    logger.info(
     116                        'CoursesPlugin: %s attribute %s added.' % (
     117                        o.code,i[0]))
     118            # Remove deprecated attributes
     119            for i in self.deprecated_attributes:
     120                try:
     121                    delattr(o,i)
     122                    logger.info(
     123                        'CoursesPlugin: %s attribute %s deleted.' % (
     124                        o.code,i))
     125                except AttributeError:
     126                    pass
     127        return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r9217 r9220  
    168168        )
    169169
     170    former_course = schema.Bool(
     171        title = _(u'Former Course'),
     172        description = _(
     173            u'If this attribute is being set all certificate courses '
     174            'referring to this course will be automatically deleted.'),
     175        required = False,
     176        default = False,
     177        )
     178
    170179    def longtitle():
    171180        """
Note: See TracChangeset for help on using the changeset viewer.