- Timestamp:
- 25 Oct 2007, 14:21:01 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTool.py
r2428 r2433 1298 1298 for field in f2t[pt]['fields']: 1299 1299 d[field] = mapping.get(field,'') 1300 if pt == "StudyCourse":1301 for von,zu in (('entry_mode','current_mode'),1302 ('entry_session','current_session')):1303 if mapping.get(zu,None) is None and mapping.get(von,None) is not None:1304 d[zu] = mapping[von]1300 # if pt == "StudyCourse": 1301 # for von,zu in (('entry_mode','current_mode'), 1302 # ('entry_session','current_session')): 1303 # if mapping.get(zu,None) is None and mapping.get(von,None) is not None: 1304 # d[zu] = mapping[von] 1305 1305 sub_doc.edit(mapping = d) 1306 1306 … … 1472 1472 em = 'not ignorable key(s): "%s" found in heading' % ", ".join(diff2schema) 1473 1473 return em 1474 if mode == "create": 1475 required_keys = [layout.getIdUnprefixed(id) 1476 for id,widget in layout.objectItems() 1477 if widget.is_required] 1478 #import pdb;pdb.set_trace() 1479 if not set(required_keys).issubset(set(import_keys)): 1480 diff2import = set(required_keys).difference(set(import_keys)) 1481 em = 'required key(s): "%s" not found in heading' % ", ".join(diff2import) 1482 return em 1474 1483 s = ','.join(['"%s"' % fn for fn in import_keys]) 1475 1484 open("%s/import/%s_not_imported%s.csv" % (i_home,filename,current),"a").write(s + ',"Error"'+ '\n') … … 1484 1493 error_string = "" 1485 1494 for k in import_keys: 1486 #import pdb;pdb.set_trace()1487 1495 if not validators[k](ds,mode=mode): 1488 1496 error_string += " %s : %s" % (k, … … 1490 1498 ds.getErrorMapping(k))) 1491 1499 if not error_string: 1492 item.update(dm) 1493 item['id'],error = importer(item) 1500 temp_item = item.copy() 1501 temp_item.update(dm) 1502 item['id'],error = importer(temp_item) 1494 1503 if error: 1495 1504 error_string += error 1505 else: 1506 item = temp_item 1496 1507 if error_string: 1497 1508 item['Error'] = error_string -
WAeUP_SRP/base/Widgets.py
r2428 r2433 488 488 def _getLGAs(self): 489 489 voc = getattr(self.portal_vocabularies,self.vocabulary) 490 if getattr(self,'_v_states',None) is not None and\ 491 getattr(self,'_v_lgas',None) is not None and\ 492 getattr(self,'_v_d',None) is not None: 493 return (_v_d,_v_states,_v_lgas) 490 494 states = [] 491 495 lgas = [] … … 506 510 lgas.append(lga) 507 511 d[k] = v 508 512 self._v_d = d 513 self._v_state = state 514 self._v_lga = lga 509 515 return (d,states,lgas) 510 516 … … 521 527 v = v.lower() 522 528 combined,states,lgas = self._getLGAs() 523 one_field = False524 if len(v) == 0:525 pass526 elif not self.state_field and not self.lga_field:527 one_field = True528 if v not in combined.keys():529 datamodel = datastructure.getDataModel() 530 if not self.state_field and not self.lga_field: 531 if len(v) == 0 and self.is_required: 532 datastructure.setError(widget_id, "%s required" % widget_id) 533 return 0 534 elif v not in combined.keys(): 529 535 datastructure.setError(widget_id, "'%s' not a valid lga key" % v) 530 536 return 0 531 else: 537 datamodel[self.fields[0]] = v 538 else: 539 state = datastructure.get(self.state_field,"").lower() 540 lga = datastructure.get(self.lga_field,"").lower() 532 541 if widget_id == self.state_field: 533 if vnot in states:542 if state not in states: 534 543 datastructure.setError(widget_id, "'%s' not a valid state" % v) 535 544 return 0 536 545 elif widget_id == self.lga_field: 537 if "_".join(re.split('\W+',v))not in lgas:546 if lga not in lgas: 538 547 datastructure.setError(widget_id, "'%s' not a valid lga" % v) 539 548 return 0 540 if datastructure[self.state_field]: 541 v = datastructure[self.state_field] + '_' + v 542 543 if self.is_required and not len(v): 544 datastructure.setError(widget_id, "lga required") 545 return 0 546 547 datamodel = datastructure.getDataModel() 548 if one_field: 549 datamodel[self.fields[0]] = v 550 else: 551 state = datastructure[self.state_field].lower() 552 lga = "_".join(datastructure[self.lga_field].lower().split()) 549 if len(state) == 0 or len(lga) == 0: 550 datastructure.setError(widget_id, "state AND lga must be given") 551 return 0 553 552 datamodel[self.fields[0]] = state + "_" + lga 554 553 return 1
Note: See TracChangeset for help on using the changeset viewer.