Changeset 463 for WAeUP_SRP/trunk/Widgets.py
- Timestamp:
- 1 Sep 2006, 10:33:30 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Widgets.py
r444 r463 207 207 208 208 InitializeClass(StudentIdWidget) 209 210 209 widgetRegistry.register(StudentIdWidget) 211 210 212 ##Class StudentIdWidgetType(CPSWidgetType): 213 ## """Student Id String widget type.""" 214 ## meta_type = "StudentId Widget Type" 215 ## cls = StudentIdWidget 216 211 ###) 212 213 class JambRegNoWidget(CPSStringWidget): ###( 214 """ JambRegNo Widget""" 215 meta_type = "JambRegNo Widget" 216 digits = 8 217 digits_str = "N"*digits 218 letters = 2 219 letters_str = "L"*letters 220 221 def validate(self, datastructure, **kw): 222 """Validate datastructure and update datamodel.""" 223 224 valid = CPSStringWidget.validate(self, datastructure, **kw) 225 if not valid: 226 return 0 227 else: 228 widget_id = self.getWidgetId() 229 value = datastructure[widget_id] 230 err = 0 231 if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()): 232 err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str) 233 else: 234 search = self.portal_catalog({'meta_type': 'StudentAdmission', 235 'jamb_reg_no': value, 236 }) 237 if len(search) < 1: 238 err = 'No JAMB data for %s' % (value) 239 if err: 240 datastructure.setError(widget_id, err) 241 else: 242 datamodel = datastructure.getDataModel() 243 datamodel[self.fields[0]] = value 244 245 return not err 246 247 InitializeClass(JambRegNoWidget) 248 249 widgetRegistry.register(JambRegNoWidget) 217 250 ###) 218 251
Note: See TracChangeset for help on using the changeset viewer.