Changeset 373


Ignore:
Timestamp:
15 Aug 2006, 14:33:10 (18 years ago)
Author:
joachim
Message:

added verification of Courses

Location:
WAeUP_SRP/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Widgets.py

    r295 r373  
    7272###)
    7373
    74 class CPSStringWidgetForRecord(CPSStringWidget):
     74class CPSStringWidgetForRecord(CPSStringWidget): ###(
    7575    """String widget."""
    7676    meta_type = 'String Widget For Record'
     
    106106
    107107widgetRegistry.register(CPSStringWidgetForRecord)
     108
     109###)
     110
     111class CertificateCourseIdWidget(CPSStringWidget): ###(
     112    """ CertificateCourseId Widget"""
     113    meta_type = "CertificateCourseId Widget"
     114   
     115    def validate(self, datastructure, **kw):
     116        """Validate datastructure and update datamodel."""
     117       
     118        valid = CPSStringWidget.validate(self, datastructure, **kw)
     119        if not valid:
     120            return 0
     121        else:
     122            widget_id = self.getWidgetId()
     123            value = datastructure[widget_id].upper()
     124            err = 0
     125            c_ids = [c.id for c in self.portal_catalog({'meta_type': "Course"})]
     126            if value not in c_ids:
     127                err = 'Course %s does not exist' % (value)
     128            if err:
     129                datastructure.setError(widget_id, err)
     130            else:
     131                datamodel = datastructure.getDataModel()
     132                datamodel[self.fields[0]] = value
     133           
     134            return not err
     135
     136InitializeClass(CertificateCourseIdWidget)
     137
     138widgetRegistry.register(CertificateCourseIdWidget)
     139
     140
     141###)
    108142
    109143class StudentIdWidget(CPSStringWidget): ###(
  • WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py

    r370 r373  
    3333
    3434ob = getattr(context, id)
     35ob.getContent().edit(mapping=datamodel)
    3536
    3637context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
Note: See TracChangeset for help on using the changeset viewer.