Changeset 3487


Ignore:
Timestamp:
3 May 2008, 15:10:45 (17 years ago)
Author:
joachim
Message:

add WAeUP Boolean Widget;
use it in import_course_result

Location:
WAeUP_SRP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Widgets.py

    r3486 r3487  
    10301030
    10311031widgetRegistry.register(WAeUPSexWidget)
     1032
     1033###)
     1034
     1035class WAeUPBooleanWidget(CPSBooleanWidget): ###(
     1036    """WAeUP boolean widget."""
     1037    meta_type = 'WAeUP Boolean Widget'
     1038
     1039    def validate(self, datastructure, **kw):
     1040        """Validate datastructure and update datamodel."""
     1041        value = datastructure[self.getWidgetId()]
     1042
     1043        if self.render_format not in self.render_formats:
     1044            self.render_format = 'select'
     1045        true = value.upper() in ('T','1','TRUE',True)
     1046        false = value.upper() in ('F','0','FALSE',False)
     1047        if not true and not false:
     1048            datastructure.setError(self.getWidgetId(),
     1049                                   "invalid boolean %s" % value)
     1050            return 0
     1051        elif true:
     1052            v = True
     1053        else:
     1054            v = False
     1055        datamodel = datastructure.getDataModel()
     1056        datamodel[self.fields[0]] = v
     1057        return 1
     1058
     1059InitializeClass(WAeUPBooleanWidget)
     1060
     1061widgetRegistry.register(WAeUPBooleanWidget)
    10321062
    10331063###)
  • WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml

    r3450 r3487  
    9797  </widget>
    9898
    99   <widget name="core_or_elective" meta_type="Boolean Widget">
     99  <widget name="core_or_elective" meta_type="WAeUP Boolean Widget">
    100100    <property name="title">Core or Elective</property>
    101101    <property name="fields">
     
    111111  </widget>
    112112
    113   <widget name="carry_over" meta_type="Boolean Widget">
     113  <widget name="carry_over" meta_type="WAeUP Boolean Widget">
    114114    <property name="title">carry over</property>
    115115    <property name="fields">
Note: See TracChangeset for help on using the changeset viewer.