Changeset 5977 for main/waeup.sirp


Ignore:
Timestamp:
26 Apr 2011, 10:35:52 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement a vocabulary module in university and move some vocabularies to it.

Rebuild the certificatepage page template.

Rename Course Reference to Course Referrer. It's very difficult to find a proper name for these 'certificatecourse' objects. But we have to clearly distinguish courses and referrers of courses as they are not the same.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r5951 r5977  
    11841184            if a['level'] > b['level']:
    11851185                return 1
     1186            if a['semester'] < b['semester']:
     1187                return -1
     1188            if a['semester'] > b['semester']:
     1189                return 1               
    11861190            if a['mandatory'] != b['mandatory']:
    11871191                if a['mandatory'] == False and b['mandatory'] == True:
     
    11961200        entries = []
    11971201        levels = dict()
    1198         for key, course in self.context.items():
    1199             certcourse = self.context[key]
     1202        for key, certcourse in self.context.items():
    12001203            course = certcourse.course
    12011204            level = certcourse.level
    12021205            mandatory = certcourse.core_or_elective
    12031206            title = course.title
    1204             code = course.code
    1205             course_url = self.url(self.context[key])
     1207            courseref_url = self.url(self.context[key])
     1208            course_url = self.url(course)
    12061209            semester = course.semester
    12071210
    12081211            new_entry = dict(
    1209                 level=level, mandatory=mandatory, url=course_url,
    1210                 title=title, code=code, semester=semester)
     1212                level=level, mandatory=mandatory, url=courseref_url,
     1213                title=title, semester=semester, course=course, code=key,
     1214                course_url=course_url)
    12111215            if str(level) not in levels.keys():
    12121216                levels[str(level)] = dict()
     
    12781282    @property
    12791283    def title(self):
    1280         return 'Course Reference: %s' % (self.context.course.code)
     1284        return 'Course Referrer: %s' % (self.context.__name__)
    12811285
    12821286class CertificateCourseFormPage(WAeUPEditFormPage):
     
    12911295    @property
    12921296    def title(self):
    1293         return 'Edit course reference'
     1297        return 'Edit course referrer'
    12941298   
    12951299    @grok.action('Save and return')
     
    13211325    form_fields = grok.AutoFields(ICertificateCourseAdd)
    13221326    pnav = 1
    1323     title = 'Add course reference'
    1324 
    1325     @grok.action('Add course reference')
     1327    title = 'Add course referrer'
     1328
     1329    @grok.action('Add course referrer')
    13261330    def addCertcourse(self, **data):
    13271331        try:
    13281332            self.context.addCourseRef(**data)
    13291333        except KeyError:
    1330             self.status = Invalid('The chosen course reference is already part of'
     1334            self.status = Invalid('The chosen course referrer is already part of'
    13311335                                  'this certificate')
    13321336            return
    13331337        except DuplicationError:
    1334             self.status = Invalid('The chosen course reference is already part of'
     1338            self.status = Invalid('The chosen course referrer is already part of'
    13351339                                  'this certificate')
    13361340            return
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatecoursepage.pt

    r5950 r5977  
    1 <h2 tal:content="context/course/code">TITLE</h2>
     1<h2 tal:content="context/__name__">TITLE</h2>
    22
    33<table class="listing">
     
    66  <tbody>
    77    <tr class="odd">
    8       <td>Reference Code:</td>
     8      <td>Code:</td>
    99      <td tal:content="context/__name__">CODE</td>
    1010    </tr> 
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatepage.pt

    r5946 r5977  
    11<h2 tal:content="context/title">TITLE</h2>
    22
    3 <table class="listing">
     3<table class="zebra">
    44  <thead>
    55  </thead>
    66  <tbody>
    7     <tr class="odd">
     7    <tr>
    88      <td>Code:</td>
    99      <td tal:content="context/__name__">CODE</td>
    1010    </tr>   
    11     <tr class="even">
     11    <tr>
    1212      <td>Title:</td>
    1313      <td tal:content="context/title">THE TITLE</td>
    1414    </tr>
    15     <tr class="odd">
     15    <tr>
    1616      <td>Start Level:</td>
    1717      <td tal:content="context/start_level">START_LEVEL</td>
    1818    </tr>
    19     <tr class="even">
     19    <tr>
    2020      <td>End Level:</td>
    2121      <td tal:content="context/end_level">END_LEVEL</td>
    2222    </tr>
    23     <tr class="odd">
     23    <tr>
    2424      <td>Study Mode:</td>
    2525      <td tal:content="context/study_mode">STUDY_MODE</td>
    2626    </tr>
    27     <tr class="even">
     27    <tr>
    2828      <td>Application Category:</td>
    2929      <td tal:content="context/application_category">APPLICATION_CATEGORY</td>
     
    3232</table>
    3333
    34 <h3>Courses</h3>
     34<h3><span tal:content="context/__name__">Code</span> Course Referrers</h3>
    3535
     36    <table class="zebra">
     37      <thead>
     38        <tr>
     39          <th>Course Referrer</th>
     40          <th>Course</th>
     41          <th>Title</th>
     42          <th>Level</th>
     43          <th>Semester</th>
     44          <th>Mandatory</th>
     45          <th>&nbsp;</th>
     46        </tr>     
     47      </thead>   
     48      <tbody>
     49      <span tal:omit-tag="" tal:repeat="level python: sorted(view.getCourseList().items())">
     50      <span tal:omit-tag="" tal:repeat="semester python: sorted(level[1].items())">
     51      <tr tal:repeat="courseref python:semester[1]">
     52        <td> <a href="" tal:attributes="href courseref/url" tal:content="courseref/code">courseref code</a></td>
     53        <td> <a href="" tal:attributes="href courseref/course_url" tal:content="courseref/course/code">course code</a></td>
     54        <td tal:content="courseref/title">title</td>
     55        <td tal:content="python:level[0]">level</td>
     56        <td tal:content="python:semester[0]">semester</td>
     57        <td tal:content="courseref/mandatory">mandatory</td>
     58        <td>
     59            <form method="POST">
     60              <input type="hidden" name="code"
     61                 value="" tal:attributes="value courseref/course/code" />
     62              <input type="hidden" name="level"
     63                 value="" tal:attributes="value python:level[0]" />
     64              <input type="submit" name="delcourse" value="delete" />
     65             </form>       
     66        </td>
     67      </tr>
     68      </span>
     69      </span>
     70      </tbody>
     71    </table>
    3672
    37 <div tal:repeat="level python: sorted(view.getCourseList().items())">
    38   <b>
    39     Level <span tal:replace="python: level[0]">100</span>
    40   </b>
    41 
    42   <div tal:repeat="semester python: sorted(level[1].items())">
    43     <div tal:condition="python: semester[0] == '0'">
    44       &nbsp;&nbsp;Untimed courses
    45     </div>
    46     <div tal:condition="python: semester[0] == '1'">
    47       &nbsp;&nbsp;First semester
    48     </div>
    49     <div tal:condition="python: semester[0] == '2'">
    50       &nbsp;&nbsp;Second semester
    51     </div>
    52     <div tal:condition="python: semester[0] == '3'">
    53       &nbsp;&nbsp;Combined
    54     </div>
    55    
    56     <div tal:repeat="course python:semester[1]">
    57       &nbsp;&nbsp;&nbsp;&nbsp;
    58         <form method="POST">
    59           <input type="hidden" name="code"
    60                  value="" tal:attributes="value course/code" />
    61           <input type="hidden" name="level"
    62                  value="" tal:attributes="value python:level[0]" />
    63           <input type="submit" name="delcourse" value="delete" />
    64 
    65       <a href=""
    66          tal:attributes="href course/url"
    67          ><span tal:content="course/code">code</span>
    68       </a>
    69       <span tal:content="course/title">title</span>
    70       <span tal:condition="course/mandatory">
    71         [mandatory]
    72       </span>
    73       <span tal:condition="not: course/mandatory">
    74         [optional]
    75       </span>
    76         </form>
    77     </div>
    78   </div>
    79 
    80 </div>
    81 
    82 
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r5950 r5977  
    344344    grok.context(ICertificateCourse)
    345345    grok.view(CertificateCoursePage)
    346     text = 'Edit course reference'
     346    text = 'Edit course referrer'
    347347
    348348#
     
    384384    grok.view(CertificatePage)
    385385    grok.order(4)
    386     text = 'Add course reference'
     386    text = 'Add course referrer'
    387387    target = 'addcertificatecourse'
    388388
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py

    r5953 r5977  
    5858   
    5959    def addCourseRef(self, course, level=100, core_or_elective=True):
    60         """Add a course reference.
     60        """Add a course referrer.
    6161        """
    6262        code = "%s_%s" % (course.code, level)
     
    6767
    6868    def delCourseRef(self, code, level=None):
    69         """Delete a course reference denoted by its code.
     69        """Delete a course referrer denoted by its code.
    7070        """
    7171        for key in self.keys():
     
    122122@grok.subscribe(ICourse, grok.IObjectRemovedEvent)
    123123def removedCourseHandler(course, event):
    124     """If a course is deleted, we make sure that also references in a
     124    """If a course is deleted, we make sure that also referrers in a
    125125       certificatecontainer are removed.
    126126    """
    127127    code = course.code
    128128
    129     # Find all certcourses that reference the given course...
     129    # Find all certificatecourses that refer to given course...
    130130    try:
    131131        cat = getUtility(ICatalog, name='certcourses_catalog')
     
    136136    results = cat.searchResults(course_code=(code, code))
    137137    for certcourse in results:
    138         # Remove that reference...
     138        # Remove that referrer...
    139139        cert = certcourse.__parent__
    140140        cert.delCourseRef(code)
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r5951 r5977  
    11"""Interfaces of academics specific objects.
    22"""
    3 from zc.sourcefactory.basic import BasicSourceFactory
    43from zope import schema
    5 try:
    6     from zope.catalog.interfaces import ICatalog
    7 except ImportError:
    8     # BBB
    9     from zope.app.catalog.interfaces import ICatalog
    10 from zope.component import getUtility
    114from zope.interface import Attribute
    12 from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer,
    13                                    SimpleWAeUPVocabulary)
    14 
    15 class CourseSource(BasicSourceFactory):
    16     """A course source delivers all courses inside the portal by looking
    17        up a catalog.
    18     """
    19     def getValues(self):
    20         catalog = getUtility(ICatalog, name='courses_catalog')
    21         return list(catalog.searchResults(code=('', 'z*')))
    22 
    23     def getToken(self, value):
    24         return value.code
    25        
    26     def getTitle(self, value):
    27         return "%s - %s" % (value.code, value.title[:64])
     5from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer)
     6                                   
     7from waeup.sirp.university.vocabularies import (course_levels,
     8                                                semester, CourseSource)                                   
    289
    2910class IFaculty(IWAeUPContainer):
     
    151132        title = u'Semester/Term',
    152133        default = 0,
    153         vocabulary = SimpleWAeUPVocabulary(
    154             ('N/A', 0), ('First Semester', 1),
    155             ('Second Semester', 2), ('Combined', 3)),
     134        vocabulary = semester,
    156135        required = True,
    157136        )
     
    199178        )
    200179
    201     start_level = schema.TextLine(
     180    start_level = schema.Choice(
    202181        title = u'Start Level',
    203         default = u'100',
    204         required = True,
    205         )
    206    
    207     end_level = schema.TextLine(
     182        #source = LevelSource(),
     183        vocabulary = course_levels,
     184        default = 100,
     185        required = True,
     186        )
     187   
     188    end_level = schema.Choice(
    208189        title = u'End Level',
    209         default = u'500',
     190        #source = LevelSource(),
     191        vocabulary = course_levels,
     192        default = 500,
    210193        required = True,
    211194        )
     
    240223
    241224class ICertificateCourse(IWAeUPObject):
    242     """A certificatecourse is a course referenced by a certificate, which
     225    """A certificatecourse is referring a course and
    243226       provides some own attributes.
    244227    """
    245228    course = schema.Choice(
    246         title = u'Course referenced',
     229        title = u'Course referrer',
    247230        source = CourseSource(),
    248231        readonly = True,
    249232        )
    250233   
    251     level = schema.Int(
     234    level = schema.Choice(
    252235        title = u'Level',
    253236        required = True,
    254         default = 100,
     237        #source = LevelSource(),
     238        vocabulary = course_levels,
    255239        readonly = False,
    256240        )
     
    263247
    264248    def getCourseCode():
    265         """Return the code of the referenced course.
     249        """Return the code of the course referred to.
    266250
    267251        This is needed for cataloging.
     
    270254       
    271255class ICertificateCourseAdd(ICertificateCourse):
    272     """A certificatecourse is a course referenced by a certificate, which
     256    """A certificatecourse is referring a course and
    273257       provides some own attributes.
    274258    """
    275259    course = schema.Choice(
    276         title = u'Course to be referenced',
     260        title = u'Course',
    277261        source = CourseSource(),
    278262        readonly = False,
Note: See TracChangeset for help on using the changeset viewer.