Changeset 1804
- Timestamp:
- 22 May 2007, 17:55:24 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py
r1629 r1804 48 48 if not_found: 49 49 self._logger.info("%s modified." % na[1][1]) 50 #self._initProperties(node)51 #self._initObjects(node)50 self._initProperties(node) 51 self._initObjects(node) 52 52 if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table 53 53 self._initIndexes(node) -
WAeUP_SRP/trunk/WAeUPTool.py
r1798 r1804 698 698 'nationality', 699 699 'lga', 700 'birthday', 700 701 ) 701 702 }, … … 893 894 dm = DataModel(item, adapters,context=self) 894 895 logger.info('%s starts import from %s.csv' % (member,filename)) 895 import_keys = item.keys() 896 diff_set = set(import_keys).difference(set(schema.keys())) 897 if diff_set: 898 logger.error('%s not in schema.' % diff_set) 899 return 900 diff_set = set(import_keys).difference(set(layout.keys())) 901 if diff_set: 902 logger.error('%s not in layout.' % diff_set) 903 return 896 import_keys = [k for k in item.keys() if not k.startswith('ignore')] 897 diff2schema = set(import_keys).difference(set(schema.keys())) 898 diff2layout = set(import_keys).difference(set(layout.keys())) 899 if diff2schema: 900 em = "not ignorable key(s) %s found in heading" % diff2schema 901 return em 904 902 s = ','.join(['"%s"' % fn for fn in import_keys]) 905 903 open("%s/import/%s_not_imported%s.csv" % (i_home,filename,current),"a").write(s + ',"Error"'+ '\n') … … 912 910 error_string = "" 913 911 for k in import_keys: 912 # if k == "birthday": 913 # from pdb import set_trace; set_trace() 914 914 if not validators[k](ds): 915 915 error_string += " %s : %s" % (k,ds.getError(k)) -
WAeUP_SRP/trunk/Widgets.py
r1793 r1804 175 175 ###) 176 176 177 class WAeUPSessionWidget(CPSSelectWidget): ###( 178 """WAeUP Session widget.""" 179 meta_type = 'WAeUP Session Widget' 180 181 def _getSessions(self): 182 current_year = DateTime().year() 183 d = {'xx': 'unknown'} 184 for y in range(current_year - 9,current_year + 1): 185 d['%s' % str(y)[-2:]] = '%4d/%4d' % (y,y+1) 186 return d 187 188 def validate(self, datastructure, **kw): 189 """Validate datastructure and update datamodel.""" 190 widget_id = self.getWidgetId() 191 value = datastructure[widget_id] 192 try: 193 v = str(value) 194 except ValueError: 195 datastructure.setError(widget_id, "'%s' not a valid session key" % value) 196 return 0 197 198 if len(v) == 1: 199 v = value = '0%c' % v 200 elif not value: 201 v = value = self.getSessionId()[-2:] 202 #import pdb;pdb.set_trace() 203 sessions = self._getSessions() 204 if not sessions.has_key(value): 205 datastructure.setError(widget_id, "'%s' not a valid session key" % v) 206 return 0 207 if self.is_required and not len(v): 208 datastructure.setError(widget_id, "session key required") 209 return 0 210 211 datamodel = datastructure.getDataModel() 212 datamodel[self.fields[0]] = v 213 return 1 214 215 def render(self, mode, datastructure, **kw): 216 """Render in mode from datastructure.""" 217 value = datastructure[self.getWidgetId()] 218 sessions = self._getSessions() 219 if mode == 'view': 220 return escape(sessions.get(value, value)) 221 elif mode == 'edit': 222 html_widget_id = self.getHtmlWidgetId() 223 res = renderHtmlTag('select', name=html_widget_id, id=html_widget_id) 224 in_selection = 0 225 vocabulary_items = sessions.items() 226 if self.sorted: 227 vocabulary_items.sort(key=operator.itemgetter(1)) 228 for k, v in vocabulary_items: 229 kw = {'value': k, 'contents': v} 230 if value == k: 231 kw['selected'] = 'selected' 232 in_selection = 1 233 res += renderHtmlTag('option', **kw) 234 if value and not in_selection: 235 kw = {'value': value, 'contents': 'invalid: '+ str(value), 236 'selected': 'selected'} 237 res += renderHtmlTag('option', **kw) 238 res += '</select>' 239 return res 240 raise RuntimeError('unknown mode %s' % mode) 241 242 InitializeClass(WAeUPSessionWidget) 243 244 widgetRegistry.register(WAeUPSessionWidget) 245 246 ###) 247 248 class WAeUPLevelWidget(CPSSelectWidget): ###( 249 """WAeUP Level Widget.""" 250 meta_type = 'WAeUP Level Widget' 251 252 def _getLevels(self): 253 d = {'999':'unknown'} 254 for y in range(100,800,100): 255 d['%s' % str(y)] = 'Year %1d (%3d Level)' % (y/100,y) 256 return d 257 258 def validate(self, datastructure, **kw): 259 """Validate datastructure and update datamodel.""" 260 widget_id = self.getWidgetId() 261 value = datastructure[widget_id] 262 try: 263 v = str(value) 264 except ValueError: 265 datastructure.setError(widget_id, "'%s' not a valid level key" % value) 266 return 0 267 268 if not value: 269 v = value = '100' 270 #import pdb;pdb.set_trace() 271 levels = self._getLevels() 272 if not levels.has_key(value): 273 datastructure.setError(widget_id, "'%s' not a valid level" % v) 274 return 0 275 if self.is_required and not len(v): 276 datastructure.setError(widget_id, "level key required") 277 return 0 278 279 datamodel = datastructure.getDataModel() 280 datamodel[self.fields[0]] = v 281 return 1 282 283 def render(self, mode, datastructure, **kw): 284 """Render in mode from datastructure.""" 285 value = datastructure[self.getWidgetId()] 286 levels = self._getLevels() 287 if mode == 'view': 288 return escape(levels.get(value, value)) 289 elif mode == 'edit': 290 html_widget_id = self.getHtmlWidgetId() 291 res = renderHtmlTag('select', name=html_widget_id, id=html_widget_id) 292 in_selection = 0 293 vocabulary_items = levels.items() 294 if self.sorted: 295 vocabulary_items.sort(key=operator.itemgetter(1)) 296 for k, v in vocabulary_items: 297 kw = {'value': k, 'contents': v} 298 if value == k: 299 kw['selected'] = 'selected' 300 in_selection = 1 301 res += renderHtmlTag('option', **kw) 302 if value and not in_selection: 303 kw = {'value': value, 'contents': 'invalid: '+ str(value), 304 'selected': 'selected'} 305 res += renderHtmlTag('option', **kw) 306 res += '</select>' 307 return res 308 raise RuntimeError('unknown mode %s' % mode) 309 310 InitializeClass(WAeUPLevelWidget) 311 312 widgetRegistry.register(WAeUPLevelWidget) 313 314 ###) 315 316 class WAeUPVerdictWidget(CPSSelectWidget): ###( 317 """WAeUP Verdict widget.""" 318 meta_type = 'WAeUP Verdict Widget' 319 320 # XXX make a menu for the vocabulary. 321 vocabulary = 'verdicts' 322 translated = False 323 sorted = False 324 325 # Associating the widget label with an input area to improve the widget 326 # accessibility. 327 has_input_area = True 328 329 def _getVerdicts(self,datastructure): 330 voc = getattr(self.portal_vocabularies,self.vocabulary) 331 d = {} 332 for k,v in voc.items(): 333 d[k] = v 334 return d 335 336 def validate(self, datastructure, **kw): 337 """Validate datastructure and update datamodel.""" 338 widget_id = self.getWidgetId() 339 value = datastructure[widget_id] 340 try: 341 v = str(value) 342 except ValueError: 343 datastructure.setError(widget_id, "'%s' not a valid verdict key" % value) 344 return 0 345 #import pdb;pdb.set_trace() 346 verdicts = self._getVerdicts(datastructure) 347 if not value: 348 v = value = verdicts['N/A'] 349 if not verdicts.has_key(value): 350 datastructure.setError(widget_id, "'%s' not a valid verdict key" % v) 351 return 0 352 if self.is_required and not len(v): 353 datastructure.setError(widget_id, "verdict required") 354 return 0 355 356 datamodel = datastructure.getDataModel() 357 datamodel[self.fields[0]] = v 358 return 1 359 360 def render(self, mode, datastructure, **kw): 361 """Render in mode from datastructure.""" 362 value = datastructure[self.getWidgetId()] 363 verdicts = self._getVerdicts(datastructure) 364 if mode == 'view': 365 return escape(verdicts.get(value, value)) 366 elif mode == 'edit': 367 html_widget_id = self.getHtmlWidgetId() 368 res = renderHtmlTag('select', name=html_widget_id, id=html_widget_id) 369 in_selection = 0 370 vocabulary_items = verdicts.items() 371 if self.sorted: 372 vocabulary_items.sort(key=operator.itemgetter(1)) 373 for k, v in vocabulary_items: 374 kw = {'value': k, 'contents': v} 375 if value == k: 376 kw['selected'] = 'selected' 377 in_selection = 1 378 res += renderHtmlTag('option', **kw) 379 if value and not in_selection: 380 kw = {'value': value, 'contents': 'invalid: '+ str(value), 381 'selected': 'selected'} 382 res += renderHtmlTag('option', **kw) 383 res += '</select>' 384 return res 385 raise RuntimeError('unknown mode %s' % mode) 386 387 InitializeClass(WAeUPVerdictWidget) 388 389 widgetRegistry.register(WAeUPVerdictWidget) 390 391 ###) 392 177 393 class WAeUPReservedRoomsWidget(CPSStringWidget): ###( 178 394 """ WAeUPReservedRooms Widget""" … … 298 514 """Validate datastructure and update datamodel.""" 299 515 valid = CPSStringWidget.validate(self, datastructure, **kw) 300 #import pdb;pdb.set_trace()301 516 jamb_nr_catalog = getattr(self,self.catalog) 302 517 widget_id = self.getWidgetId() … … 390 605 ###) 391 606 392 class WAeUPSexWidget(CPSBooleanWidget): 607 class WAeUPSexWidget(CPSBooleanWidget): ###( 393 608 """WAeUP sex widget.""" 394 609 meta_type = 'WAeUP Sex Widget' … … 418 633 419 634 widgetRegistry.register(WAeUPSexWidget) 635 636 ###) 420 637 421 638 class MatricNoWidget(CPSStringWidget): ###( … … 915 1132 return meth(mode=mode, datastructure=datastructure, **img_info) 916 1133 917 ###)918 919 920 921 1134 InitializeClass(WAeUPImageWidget) 922 1135 923 1136 widgetRegistry.register(WAeUPImageWidget) 1137 ###) 924 1138 925 1139 -
WAeUP_SRP/trunk/__init__.py
r1737 r1804 20 20 import PatchCPSStackingDirectoryStorageAdapter 21 21 import PatchBasicWidgetsCPSStringWidget 22 import PatchExtendedWidgetsCPSDateTimeWidget 22 23 import PatchBasicWidgetsUnprepare 23 24 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed. -
WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml
r1786 r1804 114 114 <property name="hidden_readonly_layout_modes"/> 115 115 </widget> 116 <widget name="entry_mode" meta_type="Select Widget"> 116 <widget name="birthday" meta_type="DateTime Widget"> 117 <property name="title">Birthday</property> 118 <property name="fields"> 119 <element value="birthday"/> 120 </property> 121 <property name="label">Birthday</property> 122 <property name="label_edit">Birthday</property> 123 <property name="readonly_layout_modes"/> 124 <property name="hidden_layout_modes"/> 125 <property name="hidden_readonly_layout_modes"/> 126 <property name="view_format">iso8601</property> 127 <property name="time_setting">False</property> 128 <property name="time_hour_default">00</property> 129 </widget> 130 <widget name="entry_mode" meta_type="Select Widget"> 117 131 <property name="title">Entry Mode</property> 118 132 <property name="fields"> … … 138 152 <property name="vocabulary">entry_modes</property> 139 153 </widget> 140 <widget name="current_session" meta_type=" SelectWidget">154 <widget name="current_session" meta_type="WAeUP Session Widget"> 141 155 <property name="title">Current Session</property> 142 156 <property name="fields"> … … 152 166 <property name="vocabulary">sessions</property> 153 167 </widget> 154 <widget name="current_level" meta_type=" SelectWidget">168 <widget name="current_level" meta_type="WAeUP Level Widget"> 155 169 <property name="title">Current Level</property> 156 170 <property name="fields"> … … 166 180 <property name="vocabulary">courselevel</property> 167 181 </widget> 168 <widget name="current_verdict" meta_type=" Select Widget">182 <widget name="current_verdict" meta_type="WAeUP Verdict Widget"> 169 183 <property name="title">Current Verdict</property> 170 184 <property name="fields"> -
WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml
r1786 r1804 6 6 <field name="lastname" meta_type="CPS String Field"/> 7 7 <field name="sex" meta_type="CPS String Field"/> 8 <field name="birthday" meta_type="CPS String Field"/> 8 9 <field name="matric_no" meta_type="CPS String Field"/> 9 10 <field name="jamb_reg_no" meta_type="CPS String Field"/>
Note: See TracChangeset for help on using the changeset viewer.