Changeset 9217 for main/waeup.kofa/trunk/src/waeup/kofa/university
- Timestamp:
- 21 Sep 2012, 11:21:05 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/university
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/course.py
r9170 r9217 21 21 from zope.catalog.interfaces import ICatalog 22 22 from zope.interface import implementedBy 23 from zope.schema import getFields24 from zope.intid.interfaces import IIntIds25 23 from zope.component import getUtility 26 24 from zope.component.interfaces import IFactory, ComponentLookupError 27 from waeup.kofa.interfaces import IKofaPluggable28 25 from waeup.kofa.university.interfaces import ICourse, ICourseAdd 29 26 … … 40 37 credits=0, 41 38 passmark=40, 42 semester=1, 43 former_course=False, 44 **kw): 39 semester=1, **kw): 45 40 super(Course, self).__init__(**kw) 46 41 self.title = title … … 49 44 self.passmark = passmark 50 45 self.semester = semester 51 self.former_course = former_course52 46 53 47 def longtitle(self): … … 89 83 cert._p_changed = True 90 84 return 91 92 class 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 return103 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 attributes112 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 attributes119 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 pass127 return -
main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py
r9170 r9217 168 168 ) 169 169 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 179 170 def longtitle(): 180 171 """
Note: See TracChangeset for help on using the changeset viewer.