Ignore:
Timestamp:
17 Feb 2012, 12:06:10 (13 years ago)
Author:
Henrik Bettermann
Message:

Rename attribute core_or_elective to mandatory.

The following commands in debug mode will fix existing databases:

from zope.component import getUtility
from zope.catalog.interfaces import ICatalog
from zope.intid.interfaces import IIntIds
import transaction
sm = rootfutminna?.getSiteManager()
cat = sm.getUtility(ICatalog, name='certcourses_catalog')
cat.values()[0].documentCount()
results = cat.apply({'course_code':(None,None)})
uidutil = getUtility(IIntIds, context=cat)
for r in results:

... o = uidutil.getObject(r)
... o.mandatory = o.core_or_elective
...

cat = sm.getUtility(ICatalog, name='coursetickets_catalog')
cat.values()[0].documentCount()
results = cat.apply({'code':(None,None)})
uidutil = getUtility(IIntIds, context=cat)
for r in results:

... o = uidutil.getObject(r)
... o.mandatory = o.core_or_elective
...

transaction.commit()

Location:
main/waeup.sirp/trunk/src/waeup/sirp/university
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/university/batching.py

    r7333 r7665  
    272272        parent = self.getParent(row, site)
    273273        parent.addCourseRef(row['course'],
    274                             row['level'], row['core_or_elective'])
     274                            row['level'], row['mandatory'])
    275275        return
    276276
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py

    r7349 r7665  
    5757        return "%s (%s)" % (self.title,self.code)
    5858
    59     def addCourseRef(self, course, level=100, core_or_elective=True):
     59    def addCourseRef(self, course, level=100, mandatory=True):
    6060        """Add a course referrer.
    6161        """
    6262        code = "%s_%s" % (course.code, level)
    63         self[code] = CertificateCourse(course, level, core_or_elective)
     63        self[code] = CertificateCourse(course, level, mandatory)
    6464        self[code].__parent__ = self
    6565        self[code].__name__ = code
     
    9797    grok.implements(ICertificateCourse)
    9898
    99     def __init__(self, course=None, level=100, core_or_elective=True):
     99    def __init__(self, course=None, level=100, mandatory=True):
    100100        self.course = course
    101101        self.level = level
    102         self.core_or_elective = core_or_elective
     102        self.mandatory = mandatory
    103103
    104104    def getCourseCode(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.txt

    r7321 r7665  
    9696      .. XXX: This is not a proper description
    9797
    98    .. method:: addCourseRef(course[, level=100,[ core_or_elective=True]])
     98   .. method:: addCourseRef(course[, level=100,[ mandatory=True]])
    9999
    100100      Add a referrer of a course. A course is an object implementing
     
    115115--------------------------
    116116
    117 .. class:: CertificateCourse(course[, level=100[, core_or_elective=True]])
     117.. class:: CertificateCourse(course[, level=100[, mandatory=True]])
    118118
    119119   Create a course referrer.
     
    134134      An integer telling the level to which this course applies.
    135135
    136    .. attribute:: core_or_elective
     136   .. attribute:: mandatory
    137137
    138138      A bool stating whether this course is required or optional to
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r7601 r7665  
    274274        )
    275275
    276     core_or_elective = schema.Bool(
     276    mandatory = schema.Bool(
    277277        title = u'Is mandatory course (not elective)',
    278278        required = True,
Note: See TracChangeset for help on using the changeset viewer.