Changeset 4516 for waeup/branches


Ignore:
Timestamp:
2 Aug 2009, 14:08:18 (15 years ago)
Author:
uli
Message:

Add some viewlets for certificate to

  • display containing faculty/dept.,
  • display contained cert courses.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/university/certificate.py

    r4503 r4516  
    1010                              ICertificateCourse, ICourse, IDepartment)
    1111from waeup.viewlets import FormWrapMixin, Index, Manage, MainArea
     12from waeup.utils.helpers import getName
    1213
    1314class Certificate(grok.Container):
     
    104105        return implementedBy(CertificateCourse)
    105106
     107class ContentHeader(grok.Viewlet):
     108    """A viewlet that renders the faculty, department and course title.
     109    """
     110    grok.viewletmanager(MainArea)
     111    grok.context(ICertificate)
     112    grok.view(Index)
     113    grok.order(2)
     114
     115    def render(self):
     116        return '''<h5>%s</h5><h4>%s</h4><h3>%s</h3>''' % (
     117            getName(self.context.__parent__.__parent__.__parent__),
     118            getName(self.context.__parent__.__parent__),
     119            self.context.title)
     120
    106121class DisplayForm(grok.DisplayForm):
    107122    grok.context(ICertificate)
     
    118133                                  # to be rendered in this viewlet.
    119134
     135
    120136class ManageForm(grok.EditForm):
    121137    """Manage the basic properties of a `Department` instance.
     
    156172                                 # be rendered in this viewlet.
    157173
     174class CourseList(grok.Viewlet):
     175    grok.viewletmanager(MainArea)
     176    grok.context(ICertificate)
     177    grok.view(Index)
     178    grok.order(2)
     179
     180    def render(self):
     181        result = '<h3>Courses</h4>\n'
     182        for key, course in self.context.items():
     183            certcourse = self.context[key]
     184            course = certcourse.course
     185            result += '<div><a href="%s">%s</a>%s (%s / %s)</div>' % (
     186                self.view.url(course), course.code, course.title,
     187                certcourse.level, certcourse.core_or_elective)
     188        return result
    158189   
    159190@grok.subscribe(ICourse, grok.IObjectRemovedEvent)
Note: See TracChangeset for help on using the changeset viewer.