Changeset 502 for WAeUP_SRP/trunk/Widgets.py
- Timestamp:
- 11 Sep 2006, 10:39:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Widgets.py
r488 r502 2 2 3 3 from cgi import escape 4 4 from types import * 5 5 from Globals import InitializeClass 6 6 ##from Products.CPSSchemas.Widget import CPSWidgetType … … 13 13 from DateTime.DateTime import DateTime 14 14 from AccessControl import getSecurityManager 15 15 from Products.WAeUP_SRP.Students import getStudentByRegNo 16 16 from re import compile 17 17 … … 211 211 ###) 212 212 213 ##def getStudentByRegNo(self,reg_no): 214 ## search = self.portal_catalog({'meta_type': 'StudentApplication', 215 ## 'jamb_reg_no': reg_no, 216 ## }) 217 ## if len(search) < 1: 218 ## return None 219 ## return search[0].getObject(). 220 213 221 class JambRegNoWidget(CPSStringWidget): ###( 214 222 """ JambRegNo Widget""" … … 232 240 err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str) 233 241 else: 234 search = self.portal_catalog({'meta_type': 'StudentApplication', 235 'jamb_reg_no': value, 236 }) 237 if len(search) < 1: 242 s = getStudentByRegNo(self,value) 243 if s is None: 238 244 err = 'No JAMB data for %s' % (value) 239 245 if err: … … 279 285 reference = '' 280 286 281 def prepare(self, datastructure, **kw): 287 def prepare(self, datastructure, **kw): ###( 282 288 """Prepare datastructure from datamodel.""" 283 289 datamodel = datastructure.getDataModel() 284 290 v = datamodel[self.fields[0]] 285 291 widget_id = self.getWidgetId() 292 if v and type(v) is StringType: 293 p,b,n = v.split('-') 294 v = ScratchCardPin(v,b,n) 286 295 if v: 287 296 b = '%s' % v.b … … 293 302 datastructure[widget_id+'_n'] = n 294 303 304 ###) 305 295 306 def validate(self, datastructure, **kw): 296 307 """Validate datastructure and update datamodel.""" … … 298 309 v = datastructure[widget_id] 299 310 err = 0 311 p = self.prefix 300 312 b = datastructure[widget_id+'_b'].strip() 301 313 n = datastructure[widget_id+'_n'].strip() 302 314 #import pdb; pdb.set_trace() 303 if not n in self.valid_pins: 304 err = 'invalid Pin' 315 pins = self.portal_pins 316 pin = "%(p)s%(b)s%(n)s" % vars() 317 ref = datastructure[self.reference] 318 import pdb;pdb.set_trace() 319 ok = pins.searchAndSetRecord(pin,ref) 320 while 1: 321 if ok == -1: 322 err = 'invalid Pin' 323 break 324 if ok == 0: 325 err = 'Pin already used' 326 break 327 if ok >= 1: 328 student = getStudentByRegNo(self,ref) 329 if student is None: 330 err = "Student not Found in validate SC" 331 break 332 s_id = student.getId() 333 if ok == 2: 334 break 335 break 305 336 if err: 306 337 datastructure.setError(widget_id, err) … … 311 342 datastructure[widget_id+'_b'] = b 312 343 datastructure[widget_id+'_n'] = n 344 datastructure['s_id'] = s_id 313 345 #import pdb;pdb.set_trace() 314 346 return not err 315 347 316 def render(self, mode, datastructure, **kw): 348 def render(self, mode, datastructure, **kw): ###( 317 349 """Render in mode from datastructure.""" 318 350 render_method = 'widget_scratch_card_pin_render' … … 327 359 datamodel = datastructure.getDataModel() 328 360 v = datamodel[self.fields[0]] 361 if v and type(v) is StringType: 362 p,b,n = v.split('-') 363 v = ScratchCardPin(v,b,n) 329 364 if v: 330 365 b = '%s' % v.b … … 338 373 datastructure[widget_id+'_n'] = n 339 374 375 ###) 376 340 377 341 378 return meth(mode=mode,
Note: See TracChangeset for help on using the changeset viewer.