Changeset 9170 for main/waeup.kofa/trunk/src/waeup/kofa/university
- Timestamp:
- 11 Sep 2012, 09:13:41 (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
r9002 r9170 21 21 from zope.catalog.interfaces import ICatalog 22 22 from zope.interface import implementedBy 23 from zope.schema import getFields 24 from zope.intid.interfaces import IIntIds 23 25 from zope.component import getUtility 24 26 from zope.component.interfaces import IFactory, ComponentLookupError 27 from waeup.kofa.interfaces import IKofaPluggable 25 28 from waeup.kofa.university.interfaces import ICourse, ICourseAdd 26 29 … … 37 40 credits=0, 38 41 passmark=40, 39 semester=1, **kw): 42 semester=1, 43 former_course=False, 44 **kw): 40 45 super(Course, self).__init__(**kw) 41 46 self.title = title … … 44 49 self.passmark = passmark 45 50 self.semester = semester 51 self.former_course = former_course 46 52 47 53 def longtitle(self): … … 83 89 cert._p_changed = True 84 90 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 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
r9035 r9170 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 170 179 def longtitle(): 171 180 """
Note: See TracChangeset for help on using the changeset viewer.