Changeset 7665 for main/waeup.sirp/trunk


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
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/batchprocessing.txt

    r7627 r7665  
    365365
    366366    >>> open('mycertcourses.csv', 'wb').write(
    367     ... """course,faculty_code,department_code,certificate_code,level,core_or_elective
     367    ... """course,faculty_code,department_code,certificate_code,level,mandatory
    368368    ... CRS1,FAC1,DEP1,CERT1,100,True
    369369    ... CRS2,FAC1,DEP1,CERT1,100,True
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt

    r7657 r7665  
    12251225
    12261226  >>> open('certcourses.csv', 'wb').write(
    1227   ... """code,faculty_code,department_code,certificate_code,level,core_or_elective
     1227  ... """code,faculty_code,department_code,certificate_code,level,mandatory
    12281228  ... LI1,FA,LIT,LBA,100,True
    12291229  ... LI2,FA,LIT,LBA,200,True
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatecoursepage.pt

    r7465 r7665  
    2929    <tr>
    3030      <td>Is mandatory course (not elective):</td>
    31       <td tal:content="context/core_or_elective">MANDATORY</td>
     31      <td tal:content="context/mandatory">MANDATORY</td>
    3232    </tr>
    3333  </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatemanagepage.pt

    r7484 r7665  
    8181            </td>
    8282            <td>
    83               <span tal:content="cc/core_or_elective">
     83              <span tal:content="cc/mandatory">
    8484                   MANDATORY
    8585              </span>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatepage.pt

    r7465 r7665  
    5353    </td>
    5454    <td>
    55       <span tal:content="cc/core_or_elective">
     55      <span tal:content="cc/mandatory">
    5656           MANDATORY
    5757      </span>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7663 r7665  
    681681                         ('Dept.','dcode', 1.5), ('Faculty','fcode', 1.5),
    682682                         ('Cred.', 'credits', 1.5),
    683                          ('Mand.', 'core_or_elective', 1.5),
     683                         ('Mand.', 'mandatory', 1.5),
    684684                         ('Score', 'score', 1.5),('Auto', 'automatic', 1.5)
    685685                         ],
     
    16841684        for id in child_id:
    16851685            # Students are not allowed to remove core tickets
    1686             if not self.context[id].core_or_elective:
     1686            if not self.context[id].mandatory:
    16871687                try:
    16881688                    del self.context[id]
     
    17101710    grok.require('waeup.handleStudent')
    17111711    form_fields = grok.AutoFields(ICourseTicketAdd).omit(
    1712         'grade', 'score', 'core_or_elective', 'automatic', 'carry_over')
     1712        'grade', 'score', 'mandatory', 'automatic', 'carry_over')
    17131713
    17141714    def update(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt

    r7663 r7665  
    2222        <input type="checkbox" name="val_id"
    2323                  tal:attributes="value value/__name__"
    24         tal:condition="not: value/core_or_elective" />
     24        tal:condition="not: value/mandatory" />
    2525      </td>
    2626      <td tal:content="value/semester">SEMESTER</td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelmanagepage.pt

    r7663 r7665  
    7373          <td tal:content="value/fcode">FACULTY</td>
    7474          <td tal:content="value/credits">CREDITS</td>
    75           <td tal:content="value/core_or_elective">MANDATORY</td>
     75          <td tal:content="value/mandatory">MANDATORY</td>
    7676          <td tal:content="value/score">SCORE</td>
    7777          <td tal:content="value/carry_over">CO</td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelpage.pt

    r7663 r7665  
    5353      <td tal:content="value/fcode">FACULTY</td>
    5454      <td tal:content="value/credits">CREDITS</td>
    55       <td tal:content="value/core_or_elective">MANDATORY</td>
     55      <td tal:content="value/mandatory">MANDATORY</td>
    5656      <td tal:content="value/score">SCORE</td>
    5757      <td tal:content="value/carry_over">CO</td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r7661 r7665  
    357357    dcode = Attribute('department code of the original course')
    358358
    359     core_or_elective = schema.Bool(
     359    mandatory = schema.Bool(
    360360        title = u'Mandatory',
    361361        default = False,
  • main/waeup.sirp/trunk/src/waeup/sirp/students/studycourse.py

    r7664 r7665  
    5757                ticket.code = val.getCourseCode()
    5858                ticket.automatic = True
    59                 ticket.core_or_elective = val.core_or_elective
     59                ticket.mandatory = val.mandatory
    6060                ticket.title = val.course.title
    6161                ticket.fcode = val.course.__parent__.__parent__.__parent__.code
     
    8383                        co_ticket = CourseTicket()
    8484                        for name in ['code', 'title', 'credits', 'passmark',
    85                                      'semester', 'core_or_elective',
     85                                     'semester', 'mandatory',
    8686                                     'fcode', 'dcode']:
    8787                            setattr(co_ticket, name, getattr(val, name))
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/sample_courseticket_data.csv

    r7548 r7665  
    1 reg_number,matric_number,level,code,score,core_or_elective
     1reg_number,matric_number,level,code,score,mandatory
    221,,100,COURSE1,1,True
    332,,100,COURSE1,2,False
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py

    r7649 r7665  
    523523        self.assertEqual(courseticket.__parent__.__parent__.certificate.code, u'CERT1')
    524524        self.assertEqual(courseticket.score, 1)
    525         self.assertEqual(courseticket.core_or_elective, True)
     525        self.assertEqual(courseticket.mandatory, True)
    526526        self.assertEqual(courseticket.fcode, 'NA')
    527527        self.assertEqual(courseticket.dcode, 'NA')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7664 r7665  
    12061206        self.assertRaises(
    12071207            LookupError, self.browser.getControl, name='val_id')
    1208         self.student['studycourse']['200']['COURSE1'].core_or_elective = False
     1208        self.student['studycourse']['200']['COURSE1'].mandatory = False
    12091209        self.browser.open(self.student_path + '/studycourse/200/edit')
    12101210        # Now the student can remove the ticket
  • 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.