Changeset 6631 for main/waeup.sirp
- Timestamp:
- 26 Aug 2011, 08:00:10 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6629 r6631 45 45 from waeup.sirp.browser.resources import datepicker, tabs, datatable 46 46 from waeup.sirp.browser.viewlets import ( 47 ManageActionButton, PrimaryNavTab, LeftSidebarLink, AddActionButton, 47 ManageActionButton, PrimaryNavTab, LeftSidebarLink, 48 AddActionButton, ActionButton, 48 49 ) 49 50 from waeup.sirp.image.browser.widget import ( … … 62 63 MultiListWidget, MultiListDisplayWidget) 63 64 from waeup.sirp.students.interfaces import ( 64 IStudentsContainer, IStudent, 65 IStudentsContainer, IStudent, IStudentClearance, 66 IStudentPersonal, IStudentBase 65 67 ) 66 68 from waeup.sirp.students.students import ( … … 220 222 return 221 223 222 class DisplayStudent(WAeUPDisplayFormPage): 224 class StudentBaseDisplayFormPage(WAeUPDisplayFormPage): 225 """ Page to display student base data 226 """ 223 227 grok.context(IStudent) 224 228 grok.name('index') 225 229 grok.require('waeup.viewStudents') 226 form_fields = grok.AutoFields(IStudent) 227 228 @property 229 def title(self): 230 return 'Student: %s' % self.context.name 231 232 @property 233 def label(self): 234 return self.context.name 230 form_fields = grok.AutoFields(IStudentBase) 231 232 @property 233 def title(self): 234 return 'Student: %s' % self.context.name 235 236 @property 237 def label(self): 238 return '%s: Base Data' % self.context.name 239 240 class StudentBaseManageActionButton(ManageActionButton): 241 grok.order(1) 242 grok.context(IStudent) 243 grok.view(StudentBaseDisplayFormPage) 244 grok.require('waeup.manageStudents') 245 text = 'Edit base data' 246 target = 'edit_base' 247 248 class StudentClearanceViewActionButton(ActionButton): 249 grok.order(2) 250 icon = 'actionicon_view.png' 251 grok.context(IStudent) 252 grok.view(StudentBaseDisplayFormPage) 253 grok.require('waeup.viewStudents') 254 text = 'View clearance data' 255 target = 'view_clearance' 256 257 class StudentPersonalViewActionButton(ActionButton): 258 grok.order(3) 259 icon = 'actionicon_view.png' 260 grok.context(IStudent) 261 grok.view(StudentBaseDisplayFormPage) 262 grok.require('waeup.viewStudents') 263 text = 'View personal data' 264 target = 'view_personal' 265 266 class StudentBaseManageFormPage(WAeUPEditFormPage): 267 """ View to edit student base data 268 """ 269 grok.context(IStudent) 270 grok.name('edit_base') 271 grok.require('waeup.manageStudents') 272 form_fields = grok.AutoFields(IStudentBase).omit('student_id') 273 #grok.template('editstudentbase') 274 label = 'Edit base data' 275 276 @property 277 def title(self): 278 return 'Student: %s' % self.context.name 279 280 class StudentClearanceDisplayFormPage(WAeUPDisplayFormPage): 281 """ Page to display student clearance data 282 """ 283 grok.context(IStudent) 284 grok.name('view_clearance') 285 grok.require('waeup.viewStudents') 286 form_fields = grok.AutoFields(IStudentClearance) 287 288 @property 289 def title(self): 290 return 'Student: %s' % self.context.name 291 292 @property 293 def label(self): 294 return '%s: Clearance Data' % self.context.name 295 296 class StudentClearanceManageActionButton(ManageActionButton): 297 grok.order(1) 298 grok.context(IStudent) 299 grok.view(StudentClearanceDisplayFormPage) 300 grok.require('waeup.manageStudents') 301 text = 'Edit clearance data' 302 target = 'edit_clearance' 303 304 class StudentClearanceManageFormPage(WAeUPEditFormPage): 305 """ Page to edit student clearance data 306 """ 307 grok.context(IStudent) 308 grok.name('edit_clearance') 309 grok.require('waeup.viewStudents') 310 form_fields = grok.AutoFields(IStudentClearance) 311 label = 'Edit clearance data' 312 313 @property 314 def title(self): 315 return 'Student: %s' % self.context.name 316 317 class StudentPersonalDisplayFormPage(WAeUPDisplayFormPage): 318 """ Page to display student personal data 319 """ 320 grok.context(IStudent) 321 grok.name('view_personal') 322 grok.require('waeup.viewStudents') 323 form_fields = grok.AutoFields(IStudentPersonal) 324 325 @property 326 def title(self): 327 return 'Student: %s' % self.context.name 328 329 @property 330 def label(self): 331 return '%s: Personal Data' % self.context.name 332 333 class StudentPersonalManageActionButton(ManageActionButton): 334 grok.order(1) 335 grok.context(IStudent) 336 grok.view(StudentPersonalDisplayFormPage) 337 grok.require('waeup.manageStudents') 338 text = 'Edit personal data' 339 target = 'edit_personal' 340 341 class StudentPersonalManageFormPage(WAeUPEditFormPage): 342 """ Page to edit student clearance data 343 """ 344 grok.context(IStudent) 345 grok.name('edit_personal') 346 grok.require('waeup.viewStudents') 347 form_fields = grok.AutoFields(IStudentPersonal) 348 label = 'Edit personal data' 349 350 @property 351 def title(self): 352 return 'Student: %s' % self.context.name -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentaddpage.pt
r6622 r6631 9 9 <td><label for="form.student_id">Student Id:</label></td> 10 10 <td> 11 <input name="form.student_id" type="text" size=" 10" maxlength="10"11 <input name="form.student_id" type="text" size="7" maxlength="7" 12 12 value="" /> 13 13 </td> 14 14 </tr> 15 15 <tr> 16 <td><label for="form.name"> Name:</label></td>16 <td><label for="form.name">Full Name:</label></td> 17 17 <td> 18 <input name="form.name" type="text" size=" 10" maxlength="10"18 <input name="form.name" type="text" size="30" maxlength="30" 19 19 value="" /> 20 20 </td> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainermanagepage.pt
r6626 r6631 31 31 <tr tal:repeat="item view/hitlist"> 32 32 <td><input type="checkbox" name="entries" 33 tal:attributes="value item/student_id" /></td> 34 <td tal:content="item/student_id">A123456</td> 33 tal:attributes="value item/context/__name__" /></td> 34 <td> <a tal:attributes="href item/url"> 35 <span tal:content="item/student_id">A123456</span></a> 36 </td> 35 37 <td tal:content="item/name">Bob</td> 36 38 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainerpage.pt
r6630 r6631 29 29 <tbody> 30 30 <tr tal:repeat="item view/hitlist"> 31 <td tal:content="item/student_id">A123456</td> 31 <td> <a tal:attributes="href item/url"> 32 <span tal:content="item/student_id">A123456</span></a> 33 </td> 32 34 <td tal:content="item/name">Bob</td> 33 35 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6622 r6631 5 5 from waeup.sirp.interfaces import IWAeUPObject 6 6 7 class IStudent (IWAeUPObject):8 """Representation of a student.7 class IStudentBase(IWAeUPObject): 8 """Representation of student base data. 9 9 """ 10 10 student_id = schema.TextLine( … … 15 15 16 16 name = schema.TextLine( 17 title = u' Name of student',17 title = u'Full Name', 18 18 default = u'Nobody', 19 19 required = True, 20 20 ) 21 21 22 class IStudentClearance(IWAeUPObject): 23 """Representation of student clearance data. 24 """ 25 26 date_of_birth = schema.Date( 27 title = u'Date of Birth', 28 required = True, 29 ) 30 31 class IStudentPersonal(IWAeUPObject): 32 """Representation of student personal data. 33 """ 34 35 perm_address = schema.Date( 36 title = u'Permanent Address', 37 required = False, 38 ) 39 40 class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): 41 """Representation of a student. 42 """ 22 43 23 44 class IStudentsContainer(IWAeUPObject): -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6626 r6631 71 71 setSite(app) 72 72 73 74 # Add student 75 student = Student() 76 student.name = u'Anna Tester' 77 student.student_id = u'Z654321' 78 self.app['students'][student.student_id] = student 79 73 80 self.container_path = 'http://localhost/app/students' 74 81 self.manage_container_path = self.container_path + '/@@manage' 75 82 self.add_student_path = self.container_path + '/addstudent' 83 self.student_path = self.container_path + '/Z654321' 84 self.manage_student_path = self.student_path + '/edit_base' 85 self.clearance_student_path = self.student_path + '/view_clearance' 86 self.personal_student_path = self.student_path + '/view_personal' 87 self.edit_clearance_student_path = self.student_path + '/edit_clearance' 88 self.edit_personal_student_path = self.student_path + '/edit_personal' 76 89 77 90 # Populate university … … 166 179 self.assertTrue('No student found' in self.browser.contents) 167 180 181 class StudentUITests(StudentsFullSetup): 182 # Tests for Student class views and pages 183 184 layer = FunctionalLayer 185 186 def test_manage_access(self): 187 # Managers can access the pages of students 188 # and can perform actions 189 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 190 self.browser.open(self.student_path) 191 self.assertEqual(self.browser.headers['Status'], '200 Ok') 192 self.assertEqual(self.browser.url, self.student_path) 193 self.browser.getLink("Edit base data").click() 194 self.assertEqual(self.browser.headers['Status'], '200 Ok') 195 self.assertEqual(self.browser.url, self.manage_student_path) 196 self.browser.open(self.student_path) 197 self.browser.getLink("View clearance data").click() 198 self.assertEqual(self.browser.headers['Status'], '200 Ok') 199 self.assertEqual(self.browser.url, self.clearance_student_path) 200 self.browser.getLink("Edit clearance data").click() 201 self.assertEqual(self.browser.headers['Status'], '200 Ok') 202 self.assertEqual(self.browser.url, self.edit_clearance_student_path) 203 self.browser.open(self.student_path) 204 self.browser.getLink("View personal data").click() 205 self.assertEqual(self.browser.headers['Status'], '200 Ok') 206 self.assertEqual(self.browser.url, self.personal_student_path) 207 self.browser.getLink("Edit personal data").click() 208 self.assertEqual(self.browser.headers['Status'], '200 Ok') 209 self.assertEqual(self.browser.url, self.edit_personal_student_path) 210 return
Note: See TracChangeset for help on using the changeset viewer.