Changeset 6002 for main/waeup.sirp/trunk
- Timestamp:
- 1 May 2011, 12:00:22 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
r6001 r6002 248 248 249 249 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') 250 >>> browser.getLink(' Editdepartment').click()250 >>> browser.getLink('Manage department').click() 251 251 252 252 Let's set a new title and save the form: … … 256 256 257 257 Clicking 'Save' we will stay on the settings form. So we can change 258 the department again. This time we will return to the overview page 259 afterwards: 258 the department again. 260 259 261 260 >>> browser.getControl(name='form.title').value = "My renamed dept" 262 >>> ctrl = browser.getControl("Save and return")261 >>> ctrl = browser.getControl("Save") 263 262 >>> ctrl.click() 264 263 265 If we go to the settings page and click ``Cancel`` nothing will be 266 changed: 267 268 >>> browser.getLink('Edit department').click() 269 >>> browser.getControl(name='form.title').value = "Blah" 270 >>> browser.getControl('Cancel').click() 271 272 Our department was indeed renamed to ``My renamed dept`` and not to 273 ``Blah``: 264 265 Our department was indeed renamed to ``My renamed dept``: 274 266 275 267 >>> browser.open('http://localhost/myuniversity/faculties/TF') … … 414 406 ---------------- 415 407 416 We can delete courses by browsing the containing department and 417 clicking on the appropriate 'Delete' button. As we have only one 418 course, there is only one 'Delete' button yet: 419 420 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') 408 We can delete courses by browsing the manage page of the containing department and 409 checking the appropriate select box and clicking the ´´Remove selected´´ button. 410 411 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-2') 421 412 >>> 'My renamed course' in browser.contents 422 413 True 423 414 424 >>> browser.getControl('Delete').click() 415 >>> browser.getControl(name='val_id').getControl(value='COURSE1').selected = True 416 >>> browser.getControl('Remove selected courses').click() 425 417 426 418 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') … … 518 510 519 511 >>> browser.open(dept_url + '/certificates/CERT1') 520 >>> browser.getLink(' Editcertificate').click()512 >>> browser.getLink('Manage certificate').click() 521 513 522 514 When modifying a certificate, we cannot change the code any more: … … 533 525 534 526 Clicking 'Save' we will stay on the settings form. So we can change 535 the cert again. This time we will return to the overview page 536 afterwards: 527 the cert again. 537 528 538 529 >>> browser.getControl(name='form.title').value = "My renamed cert" 539 >>> ctrl = browser.getControl("Save and return")530 >>> ctrl = browser.getControl("Save",index=0) 540 531 >>> ctrl.click() 541 532 … … 543 534 changed: 544 535 545 >>> browser.getLink('Edit certificate').click()546 536 >>> browser.getControl(name='form.title').value = "Blah" 547 537 >>> browser.getControl('Cancel').click() … … 561 551 --------------------- 562 552 563 We can delete certificates by browsing the containing department and 564 clicking on the appropriate 'Delete' button. As we have only one 565 certificate, there is only one 'Delete' button yet: 566 567 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') 553 We can delete certificates by browsing the manage page of the containing department and 554 checking the appropriate select box and clicking the ´´Remove selected´´ button. 555 556 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/@@manage#tab-3') 568 557 >>> 'My renamed cert' in browser.contents 569 558 True 570 559 571 >>> browser.getControl('Delete').click() 572 573 >>> browser.open('http://localhost/myuniversity/faculties/TF/TD') 560 >>> browser.getControl(name='val_id').getControl(value='CERT1').selected = True 561 >>> browser.getControl('Remove selected certificates').click() 574 562 >>> 'My renamed cert' in browser.contents 575 563 False -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6000 r6002 1091 1091 grok.name('index') 1092 1092 pnav = 1 1093 label = 'Courses and Certificates' 1093 1094 1094 1095 @property 1095 1096 def title(self): 1096 #import pdb; pdb.set_trace()1097 1097 return self.context.longtitle() 1098 1098 1099 1099 def update(self): 1100 yui.tabview.need()1101 if 'delcourse' in self.request.form:1102 code = self.request.form['code']1103 del self.context.courses[code]1104 if 'delcert' in self.request.form:1105 code = self.request.form['code']1106 del self.context.certificates[code]1100 tabs.need() 1101 #if 'delcourse' in self.request.form: 1102 # code = self.request.form['code'] 1103 # del self.context.courses[code] 1104 #if 'delcert' in self.request.form: 1105 # code = self.request.form['code'] 1106 # del self.context.certificates[code] 1107 1107 self.tables = ITableProvider(self.context).getTables(view=self) 1108 1108 self.coursetable = self.tables[0] … … 1116 1116 grok.name('manage') 1117 1117 grok.require('waeup.manageUniversity') 1118 title = u'Edit department' 1119 pnav = 1 1118 pnav = 1 1119 grok.template('departmentmanagepage') 1120 taboneactions = ['Save','Cancel'] 1121 tabtwoactions = ['Add course', 'Remove selected courses','Cancel'] 1122 tabthreeactions = ['Add certificate', 'Remove selected certificates', 'Cancel'] 1123 1124 @property 1125 def label(self): 1126 return 'Manage department' 1127 1128 @property 1129 def title(self): 1130 return self.context.longtitle() 1131 1132 def update(self): 1133 tabs.need() 1134 self.tables = ITableProvider(self.context).getTables(view=self) 1135 self.coursetable = self.tables[0] 1136 self.certificatetable = self.tables[1] 1137 self.coursetable.need() 1120 1138 1121 1139 form_fields = grok.AutoFields(IDepartment) … … 1125 1143 self.applyData(self.context, **data) 1126 1144 return 1127 1128 @grok.action('Save and return') 1129 def saveAndReturn(self, **data): 1130 self.applyData(self.context, **data) 1131 self.redirect(self.url(self.context)) 1132 return 1133 1145 1146 # ToDo: Show warning message before deletion 1147 @grok.action('Remove selected courses') 1148 def delCourses(self, **data): 1149 form = self.request.form 1150 child_id = form['val_id'] 1151 if not isinstance(child_id, list): 1152 child_id = [child_id] 1153 deleted = [] 1154 for id in child_id: 1155 try: 1156 del self.context.courses[id] 1157 deleted.append(id) 1158 except: 1159 self.flash('Could not delete %s: %s: %s' % ( 1160 id, sys.exc_info()[0], sys.exc_info()[1])) 1161 if len(deleted): 1162 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1163 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1164 return 1165 1166 @grok.action('Remove selected certificates') 1167 def delCertificates(self, **data): 1168 form = self.request.form 1169 child_id = form['val_id'] 1170 if not isinstance(child_id, list): 1171 child_id = [child_id] 1172 deleted = [] 1173 for id in child_id: 1174 try: 1175 del self.context.certificates[id] 1176 deleted.append(id) 1177 except: 1178 self.flash('Could not delete %s: %s: %s' % ( 1179 id, sys.exc_info()[0], sys.exc_info()[1])) 1180 if len(deleted): 1181 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1182 self.redirect(self.url(self.context, u'@@manage')+'#tab-3') 1183 return 1184 1185 @grok.action('Add course', validator=NullValidator) 1186 def addCourse(self, **data): 1187 self.redirect(self.url(self.context, 'addcourse')) 1188 return 1189 1190 @grok.action('Add certificate', validator=NullValidator) 1191 def addCertificate(self, **data): 1192 self.redirect(self.url(self.context, 'addcertificate')) 1193 return 1194 1134 1195 @grok.action('Cancel', validator=NullValidator) 1135 1196 def cancel(self, **data): … … 1161 1222 'in the database') 1162 1223 return 1163 self.redirect(self.url(self.context ))1224 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1164 1225 1165 1226 @grok.action('Cancel', validator=NullValidator) … … 1202 1263 'in the database') 1203 1264 return 1204 self.redirect(self.url(self.context ))1265 self.redirect(self.url(self.context, u'@@manage')+'#tab-3') 1205 1266 1206 1267 @grok.action('Cancel', validator=NullValidator) -
main/waeup.sirp/trunk/src/waeup/sirp/browser/tables.py
r5945 r6002 48 48 delcol = Col(header=' ', sortable=False, 49 49 data = [ 50 '<form method="post">' 51 '<input type="submit" name="delcourse" value="Delete" />' 52 '<input type="hidden" name="code" value="%s" />' 53 '</form>' % (data[x].code) 54 for x in data]) 50 '<input type="checkbox" name="val_id" value="%s" />' 51 % (data[x].code) for x in data]) 55 52 56 53 if checkPermission('waeup.manageUniversity', self.context.courses): 57 54 cols = list(cols) 58 cols .append(delcol)55 cols = [delcol] + cols 59 56 cols = tuple(cols) 60 57 self.coursetable = Table('Courses', cols=cols) … … 75 72 delcol = Col(header=' ', sortable=False, 76 73 data = [ 77 '<form method="post">' 78 '<input type="submit" name="delcert" value="Delete" />' 79 '<input type="hidden" name="code" value="%s" />' 80 '</form>' % (data[x].code) 81 for x in data]) 74 '<input type="checkbox" name="val_id" value="%s" />' 75 % (data[x].code) for x in data]) 82 76 83 77 if checkPermission('waeup.manageUniversity', self.context.certificates): 84 78 certcols = list(certcols) 85 certcols .append(delcol)79 certcols = [delcol] + certcols 86 80 certcols = tuple(certcols) 87 81 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentpage.pt
r4789 r6002 1 1 <script type="text/javascript"> 2 2 var tabView = new YAHOO.widget.TabView('table-tabs'); 3 </script> 4 <div id="table-tabs" class="yui-navset"> 5 <ul class="yui-nav"> 6 <li class="selected"><a href="#tab1"><em>Courses</em></a></li> 7 <li><a href="#tab2"><em>Certificates</em></a></li> 8 </ul> 9 <div class="yui-content"> 10 <div id="tab1"> 11 12 <div name="thecoursetable" 13 tal:condition="python: len(context.courses.keys())"> 14 <div tal:replace="structure view/coursetable/renderHTML" /> 15 </div> 3 </script> 16 4 5 <h2 i18n:translate="" 6 tal:condition="view/label" 7 tal:content="view/label">Label</h2> 8 9 <div id="tabs"> 10 <ul> 11 <li><a href="#tab-1"><span>Courses</span></a></li> 12 <li><a href="#tab-2"><span>Certificates</span></a></li> 13 </ul> 14 <div id="tab-1"> 15 <div name="thecoursetable" tal:condition="python: len(context.courses.keys())"> 16 <div tal:replace="structure view/coursetable/renderHTML"></div> 17 </div> 18 </div> 19 <div id="tab-2"> 20 <div name="thecerttable"> 21 <div tal:replace="structure view/certificatetable/renderHTML"></div> 22 </div> 17 23 </div> 18 <div id="tab2">19 20 <div name="thecerttable">21 <div tal:replace="structure view/certificatetable/renderHTML" />22 </div>23 24 </div>25 </div>26 24 </div> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r6000 r6002 326 326 327 327 class ManageDepartmentActionButton(ManageActionButton): 328 """ ' Editsettings' button for departments.328 """ 'Manage settings' button for departments. 329 329 """ 330 330 grok.context(IDepartment) 331 331 grok.view(DepartmentPage) 332 text = ' Editdepartment'332 text = 'Manage department' 333 333 334 334 class ManageCourseActionButton(ManageActionButton): … … 340 340 341 341 class ManageCertificateActionButton(ManageActionButton): 342 """ ' Editsettings' button for certificates.342 """ 'Manage settings' button for certificates. 343 343 """ 344 344 grok.context(ICertificate) 345 345 grok.view(CertificatePage) 346 text = ' Editcertificate'346 text = 'Manage certificate' 347 347 348 348 class ManageCertificateCourseActionButton(ManageActionButton): 349 """ ' Editsettings' button for certificate courses.349 """ 'Manage settings' button for certificate courses. 350 350 """ 351 351 grok.context(ICertificateCourse) … … 373 373 # text = 'Add department' 374 374 375 class AddCertificateActionButton(AddActionButton):376 grok.context(IDepartment)377 grok.view(DepartmentPage)378 grok.order(3)379 text = 'Add certificate'380 target = 'addcertificate'381 382 class AddCourseActionButton(AddActionButton):383 grok.context(IDepartment)384 grok.view(DepartmentPage)385 grok.order(4)386 text = 'Add course'387 target = 'addcourse'388 389 class AddCertificateCourseActionButton(AddActionButton):390 grok.context(ICertificate)391 grok.view(CertificatePage)392 grok.order(4)393 text = 'Add course referrer'394 target = 'addcertificatecourse'375 #class AddCertificateActionButton(AddActionButton): 376 # grok.context(IDepartment) 377 # grok.view(DepartmentPage) 378 # grok.order(3) 379 # text = 'Add certificate' 380 # target = 'addcertificate' 381 382 #class AddCourseActionButton(AddActionButton): 383 # grok.context(IDepartment) 384 # grok.view(DepartmentPage) 385 # grok.order(4) 386 # text = 'Add course' 387 # target = 'addcourse' 388 389 #class AddCertificateCourseActionButton(AddActionButton): 390 # grok.context(ICertificate) 391 # grok.view(CertificatePage) 392 # grok.order(4) 393 # text = 'Add course referrer' 394 # target = 'addcertificatecourse' 395 395 396 396 #
Note: See TracChangeset for help on using the changeset viewer.