Changeset 6007 for main/waeup.sirp/trunk
- Timestamp:
- 2 May 2011, 07:22:30 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
r6002 r6007 535 535 536 536 >>> browser.getControl(name='form.title').value = "Blah" 537 >>> browser.getControl('Cancel' ).click()537 >>> browser.getControl('Cancel',index=0).click() 538 538 539 539 Our certificate was indeed renamed to ``My renamed cert`` and not to … … 700 700 --------------------------- 701 701 702 We can delete certcourses by browsing the containing certificate and 703 clicking on the appropriate 'Delete' button. As we have only one 704 certcourse, there is only one 'Delete' button yet: 705 706 >>> browser.open(cert_url) 707 >>> 'COURSE1_200' in browser.contents 702 We can delete certcourses by browsing the containing certificate manage page: 703 704 >>> browser.open(cert_url + '/manage#tab-2') 705 >>> 'COURSE1_200</a>' in browser.contents 708 706 True 709 707 710 >>> browser.getControl('delete').click() 711 712 >>> browser.open(cert_url) 713 >>> 'COURSE1_200' in browser.contents 708 >>> browser.getControl(name='val_id').getControl(value='COURSE1_200').selected = True 709 >>> browser.getControl('Remove selected course referrers').click() 710 >>> 'Successfully removed: COURSE1_200' in browser.contents 711 True 712 713 >>> 'COURSE1_200</a>' in browser.contents 714 714 False 715 715 716 716 717 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6006 r6007 1344 1344 return "Certificate: %s (%s)" % (self.context.title, self.context.code) 1345 1345 1346 def update(self):1347 if 'delcourse' in self.request.form:1348 code = self.request.form['code']1349 level = self.request.form['level']1350 self.context.delCourseRef(code, level=level)1351 return1346 #def update(self): 1347 # if 'delcourse' in self.request.form: 1348 # code = self.request.form['code'] 1349 # level = self.request.form['level'] 1350 # self.context.delCourseRef(code, level=level) 1351 # return 1352 1352 1353 1353 def getCourseList(self): … … 1398 1398 1399 1399 class CertificateManageFormPage(WAeUPEditFormPage): 1400 """Manage the basicproperties of a `Certificate` instance.1400 """Manage the properties of a `Certificate` instance. 1401 1401 """ 1402 1402 grok.context(ICertificate) … … 1408 1408 form_fields = grok.AutoFields(ICertificate) 1409 1409 1410 pnav = 1 1411 grok.template('certificatemanagepage') 1412 taboneactions = ['Save','Cancel'] 1413 tabtwoactions = ['Add course referrer', 'Remove selected course referrers','Cancel'] 1414 1415 @property 1416 def label(self): 1417 return 'Manage certificate' 1418 1410 1419 @property 1411 1420 def title(self): 1412 return "Certificate: %s (%s)" % (self.context.title, self.context.code) 1413 1414 #@property 1415 #def title(self): 1416 # # Set certificate name as form label 1417 # return self.form_fields['title'].field.get(self.context) 1418 1421 return "Certificate: %s (%s)" % (self.context.title, self.context.code) 1422 1423 def update(self): 1424 tabs.need() 1425 #warning.need() 1426 return super(CertificateManageFormPage, self).update() 1427 1428 form_fields = grok.AutoFields(ICertificate) 1429 1419 1430 @grok.action('Save') 1420 1431 def save(self, **data): 1421 1432 self.applyData(self.context, **data) 1422 1423 #try: 1424 # self.applyData(self.context, **data) 1425 #except NoTransitionAvailableError: 1426 # self.status = Invalid('Review state cannot be changed to ' 1427 # 'requested state: no such transition ' 1428 # 'available in workflow.') 1429 #return 1430 1431 @grok.action('Save and return') 1432 def saveAndReturn(self, **data): 1433 self.applyData(self.context, **data) 1434 1435 #try: 1436 # self.applyData(self.context, **data) 1437 #except NoTransitionAvailableError: 1438 # self.status = Invalid('Review state cannot be changed to ' 1439 # 'requested state: no such transition ' 1440 # 'available in workflow.') 1441 # return 1442 1443 self.redirect(self.url(self.context)) 1444 return 1445 1433 return 1434 1435 # ToDo: Show warning message before deletion 1436 @grok.action('Remove selected course referrers') 1437 def delCertificateCourses(self, **data): 1438 form = self.request.form 1439 child_id = form['val_id'] 1440 if not isinstance(child_id, list): 1441 child_id = [child_id] 1442 deleted = [] 1443 for id in child_id: 1444 try: 1445 del self.context[id] 1446 deleted.append(id) 1447 except: 1448 self.flash('Could not delete %s: %s: %s' % ( 1449 id, sys.exc_info()[0], sys.exc_info()[1])) 1450 if len(deleted): 1451 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1452 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1453 return 1454 1455 1456 @grok.action('Add course referrer', validator=NullValidator) 1457 def addCertificateCourse(self, **data): 1458 self.redirect(self.url(self.context, 'addcertificatecourse')) 1459 return 1460 1446 1461 @grok.action('Cancel', validator=NullValidator) 1447 1462 def cancel(self, **data): 1448 1463 self.redirect(self.url(self.context)) 1449 1464 return 1450 1465 1466 1451 1467 class CertificateCourseAddFormPage(WAeUPAddFormPage): 1452 1468 """Add-page to add a course ref to a certificate … … 1475 1491 'this certificate') 1476 1492 return 1477 self.redirect(self.url(self.context ))1493 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1478 1494 1479 1495 @grok.action('Cancel', validator=NullValidator) -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatepage.pt
r5991 r6007 43 43 <th>Semester</th> 44 44 <th>Mandatory</th> 45 <th> </th>46 45 </tr> 47 46 </thead> … … 60 59 <td tal:content="python:semester[0]">semester</td> 61 60 <td tal:content="courseref/mandatory">mandatory</td> 62 <td>63 <form method="POST">64 <input type="hidden" name="code"65 value="" tal:attributes="value courseref/course/code" />66 <input type="hidden" name="level"67 value="" tal:attributes="value python:level[0]" />68 <input type="submit" name="delcourse" value="delete" />69 </form>70 </td>71 61 </tr> 72 62 </span>
Note: See TracChangeset for help on using the changeset viewer.