Changeset 6917 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 21 Oct 2011, 08:46:51 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
r6907 r6917 352 352 >>> browser.open('http://localhost/myuniversity/faculties/manage') 353 353 >>> browser.getControl("Remove selected", index=0).click() 354 >>> 'No facultyselected' in browser.contents354 >>> 'No item selected' in browser.contents 355 355 True 356 356 >>> browser.open('http://localhost/myuniversity/faculties/manage') … … 500 500 >>> browser.open('http://localhost/myuniversity/faculties/TF/manage') 501 501 >>> browser.getControl("Remove selected", index=0).click() 502 >>> 'No departmentselected' in browser.contents502 >>> 'No item selected' in browser.contents 503 503 True 504 504 >>> browser.open('http://localhost/myuniversity/faculties/TF/manage') … … 670 670 >>> browser.getLink('Manage department').click() 671 671 >>> browser.getControl('Remove selected courses').click() 672 >>> 'No courseselected' in browser.contents672 >>> 'No item selected' in browser.contents 673 673 True 674 674 … … 820 820 821 821 >>> browser.getControl('Remove selected certificates').click() 822 >>> 'No certificateselected' in browser.contents822 >>> 'No item selected' in browser.contents 823 823 True 824 824 … … 992 992 True 993 993 >>> browser.getControl('Remove selected course referrers').click() 994 >>> 'No course referrerselected' in browser.contents994 >>> 'No item selected' in browser.contents 995 995 True 996 996 >>> browser.getControl(name='val_id').getControl(value='COURSE1_200').selected = True -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6916 r6917 43 43 from waeup.sirp.authentication import get_principal_role_manager 44 44 45 46 45 grok.context(IWAeUPObject) 47 46 grok.templatedir('templates') … … 90 89 return 91 90 91 def delSubobjects(view, redirect, tab=None, subcontainer=None): 92 form = view.request.form 93 if form.has_key('val_id'): 94 child_id = form['val_id'] 95 else: 96 view.flash('No item selected.') 97 if tab: 98 view.redirect(view.url(view.context, redirect)+'#tab-%s' % tab) 99 else: 100 view.redirect(view.url(view.context, redirect)) 101 return 102 if not isinstance(child_id, list): 103 child_id = [child_id] 104 deleted = [] 105 for id in child_id: 106 try: 107 if subcontainer: 108 container = getattr(view.context, subcontainer, None) 109 del container[id] 110 else: 111 del view.context[id] 112 deleted.append(id) 113 except: 114 view.flash('Could not delete %s: %s: %s' % ( 115 id, sys.exc_info()[0], sys.exc_info()[1])) 116 if len(deleted): 117 view.flash('Successfully removed: %s' % ', '.join(deleted)) 118 if tab: 119 view.redirect(view.url(view.context, redirect)+'#tab-%s' % tab) 120 else: 121 view.redirect(view.url(view.context, redirect)) 122 return 123 92 124 # 93 125 # Login/logout pages... … … 432 464 tabtwoactions = [ 433 465 'Add session configuration', 434 'Remove selected sesson configurations']466 'Remove selected'] 435 467 436 468 form_fields = grok.AutoFields(IConfigurationContainer) … … 462 494 463 495 # ToDo: Show warning message before deletion 464 @grok.action('Remove selected sesson configurations') 465 def delSubobjects(self, **data): 466 form = self.request.form 467 if form.has_key('val_id'): 468 child_id = form['val_id'] 469 else: 470 self.flash('No item selected.') 471 self.redirect(self.url(self.context, '@@index')+'#tab-2') 472 return 473 if not isinstance(child_id, list): 474 child_id = [child_id] 475 deleted = [] 476 for id in child_id: 477 try: 478 del self.context[id] 479 deleted.append(id) 480 except: 481 self.flash('Could not delete %s: %s: %s' % ( 482 id, sys.exc_info()[0], sys.exc_info()[1])) 483 if len(deleted): 484 self.flash('Successfully removed: %s' % ', '.join(deleted)) 485 self.redirect(self.url(self.context, '@@index')+'#tab-2') 496 @grok.action('Remove selected') 497 def delSessonConfigurations(self, **data): 498 delSubobjects(self, redirect='@@index', tab='2') 486 499 return 487 500 … … 1042 1055 @grok.action('Remove selected') 1043 1056 def delFaculties(self, **data): 1044 form = self.request.form 1045 if form.has_key('val_id'): 1046 child_id = form['val_id'] 1047 else: 1048 self.flash('No faculty selected.') 1049 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 1050 return 1051 if not isinstance(child_id, list): 1052 child_id = [child_id] 1053 deleted = [] 1054 for id in child_id: 1055 try: 1056 del self.context[id] 1057 deleted.append(id) 1058 except: 1059 self.flash('Could not delete %s: %s: %s' % ( 1060 id, sys.exc_info()[0], sys.exc_info()[1])) 1061 if len(deleted): 1062 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1063 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 1057 delSubobjects(self, redirect='@@manage', tab='1') 1064 1058 return 1065 1059 … … 1165 1159 # ToDo: Show warning message before deletion 1166 1160 @grok.action('Remove selected') 1167 def delSubobjects(self, **data): 1168 form = self.request.form 1169 if form.has_key('val_id'): 1170 child_id = form['val_id'] 1171 else: 1172 self.flash('No department selected.') 1173 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1174 return 1175 if not isinstance(child_id, list): 1176 child_id = [child_id] 1177 deleted = [] 1178 for id in child_id: 1179 try: 1180 del self.context[id] 1181 deleted.append(id) 1182 except: 1183 self.flash('Could not delete %s: %s: %s' % ( 1184 id, sys.exc_info()[0], sys.exc_info()[1])) 1185 if len(deleted): 1186 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1187 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1161 def delDepartments(self, **data): 1162 delSubobjects(self, redirect='@@manage', tab='2') 1188 1163 return 1189 1164 … … 1344 1319 @grok.action('Remove selected courses') 1345 1320 def delCourses(self, **data): 1346 form = self.request.form 1347 if form.has_key('val_id'): 1348 child_id = form['val_id'] 1349 else: 1350 self.flash('No course selected.') 1351 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1352 return 1353 if not isinstance(child_id, list): 1354 child_id = [child_id] 1355 deleted = [] 1356 for id in child_id: 1357 try: 1358 del self.context.courses[id] 1359 deleted.append(id) 1360 except: 1361 self.flash('Could not delete %s: %s: %s' % ( 1362 id, sys.exc_info()[0], sys.exc_info()[1])) 1363 if len(deleted): 1364 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1365 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1321 delSubobjects( 1322 self, redirect='@@manage', tab='2', subcontainer='courses') 1366 1323 return 1367 1324 1368 1325 @grok.action('Remove selected certificates') 1369 1326 def delCertificates(self, **data): 1370 form = self.request.form 1371 if form.has_key('val_id'): 1372 child_id = form['val_id'] 1373 else: 1374 self.flash('No certificate selected.') 1375 self.redirect(self.url(self.context, '@@manage')+'#tab-3') 1376 return 1377 if not isinstance(child_id, list): 1378 child_id = [child_id] 1379 deleted = [] 1380 for id in child_id: 1381 try: 1382 del self.context.certificates[id] 1383 deleted.append(id) 1384 except: 1385 self.flash('Could not delete %s: %s: %s' % ( 1386 id, sys.exc_info()[0], sys.exc_info()[1])) 1387 if len(deleted): 1388 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1389 self.redirect(self.url(self.context, u'@@manage')+'#tab-3') 1327 delSubobjects( 1328 self, redirect='@@manage', tab='3', subcontainer='certificates') 1390 1329 return 1391 1330 … … 1607 1546 @grok.action('Remove selected course referrers') 1608 1547 def delCertificateCourses(self, **data): 1609 form = self.request.form 1610 if form.has_key('val_id'): 1611 child_id = form['val_id'] 1612 else: 1613 self.flash('No course referrer selected.') 1614 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 1615 return 1616 if not isinstance(child_id, list): 1617 child_id = [child_id] 1618 deleted = [] 1619 for id in child_id: 1620 try: 1621 del self.context[id] 1622 deleted.append(id) 1623 except: 1624 self.flash('Could not delete %s: %s: %s' % ( 1625 id, sys.exc_info()[0], sys.exc_info()[1])) 1626 if len(deleted): 1627 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1628 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1629 return 1630 1548 delSubobjects(self, redirect='@@manage', tab='2') 1549 return 1631 1550 1632 1551 @grok.action('Add course referrer', validator=NullValidator)
Note: See TracChangeset for help on using the changeset viewer.