Ignore:
Timestamp:
21 Mar 2017, 10:13:41 (8 years ago)
Author:
Henrik Bettermann
Message:

Add course_category attribute to certificate courses. Plugins must be updated!

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

Legend:

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

    r14511 r14638  
    8888        getUtility(IKofaPluggable, name='certificates').update(
    8989            self, 'certificates', self.logger)
     90        getUtility(IKofaPluggable, name='certcourses').update(
     91            self, 'certcourses', self.logger)
    9092        return
    9193attrs_to_fields(University)
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/certificatecoursepage.pt

    r10650 r14638  
    1616    </tr>
    1717    <tr>
    18       <td i18n:translate="">Provided by:</td>
     18      <td class="fieldname" i18n:translate="">Provided by:</td>
    1919      <td>
    2020      <span tal:content="python: context.course.__parent__.__parent__.longtitle">DEPARTMENT</span>
     
    2828    </tr>
    2929    <tr>
     30      <td i18n:translate="">Course Category:</td>
     31      <td tal:content="context/course_category">NONE</td>
     32    </tr>
     33    <tr>
    3034      <td i18n:translate="">Required course:</td>
    3135      <td tal:content="context/mandatory">REQUIRED</td>
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py

    r13721 r14638  
    9595        return "%s (%s)" % (self.title,self.code)
    9696
    97     def addCertCourse(self, course, level=100, mandatory=True):
     97    def addCertCourse(self, course, level=100,
     98                      mandatory=True, course_category=None):
    9899        """Add a certificate course.
    99100        """
    100101        code = "%s_%s" % (course.code, level)
    101         self[code] = CertificateCourse(course, level, mandatory)
     102        self[code] = CertificateCourse(course, level, mandatory, course_category)
    102103        self[code].__parent__ = self
    103104        self[code].__name__ = code
     
    156157    grok.implements(ICertificateCourse)
    157158
    158     def __init__(self, course=None, level=100, mandatory=True):
     159    def __init__(self, course=None, level=100,
     160                 mandatory=True, course_category=None):
    159161        self.course = course
    160162        self.level = level
    161163        self.mandatory = mandatory
     164        self.course_category = course_category
    162165
    163166    def getCourseCode(self):
     
    249252                    pass
    250253        return
     254
     255class CertificateCoursesPlugin(grok.GlobalUtility):
     256    """A plugin that updates certificate courses.
     257    """
     258
     259    grok.implements(IKofaPluggable)
     260    grok.name('certcourses')
     261
     262    deprecated_attributes = []
     263
     264    def setup(self, site, name, logger):
     265        return
     266
     267    def update(self, site, name, logger):
     268        cat = getUtility(ICatalog, name='certcourses_catalog')
     269        results = cat.apply({'course_code':(None,None)})
     270        uidutil = getUtility(IIntIds, context=cat)
     271        items = getFields(ICertificateCourse).items()
     272        for r in results:
     273            o = uidutil.getObject(r)
     274            # Add new attributes
     275            for i in items:
     276                if not hasattr(o,i[0]):
     277                    setattr(o,i[0],i[1].missing_value)
     278            # Remove deprecated attributes
     279            for i in self.deprecated_attributes:
     280                try:
     281                    delattr(o,i)
     282                except AttributeError:
     283                    pass
     284        return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r14511 r14638  
    3131    SemesterSource,
    3232    DegreeSource,
     33    CourseCategorySource
    3334    )
    3435
     
    329330        )
    330331
     332    course_category = schema.Choice(
     333        title = _(u'Course Category'),
     334        source = CourseCategorySource(),
     335        required = False,
     336        )
     337
    331338    mandatory = schema.Bool(
    332339        title = _(u'Registration required'),
  • main/waeup.kofa/trunk/src/waeup/kofa/university/vocabularies.py

    r13617 r14638  
    9494        return "%s - %s" % (value.code, value.title[:64])
    9595
     96class CourseCategorySource(ContextualDictSourceFactoryBase):
     97    """A course category source provides additional information on
     98    the course.
     99    """
     100    #: name of dict to deliver from kofa utils.
     101    DICT_NAME = 'COURSE_CATEGORY_DICT'
    96102
    97103
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r14473 r14638  
    158158        }
    159159
     160    COURSE_CATEGORY_DICT = {
     161        }
     162
    160163    SPECIAL_HANDLING_DICT = {
    161164        'regular': 'Regular Hostel',
Note: See TracChangeset for help on using the changeset viewer.