Changeset 6622 for main/waeup.sirp/trunk/src
- Timestamp:
- 24 Aug 2011, 20:25:44 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/README.txt
r6621 r6622 33 33 >>> u['students'] 34 34 <waeup.sirp.students.container.StudentsContainer object at 0x...> 35 36 >>> u['hostels']37 <waeup.sirp.hostel.hostelcontainer.HostelContainer object at 0x...>38 35 39 36 We can export universities. For this we lookup an appropriate exporter -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6598 r6622 458 458 459 459 class ApplicantAddFormPage(WAeUPAddFormPage): 460 """Add-form to add certificate to a department.460 """Add-form to add an applicant. 461 461 """ 462 462 grok.context(IApplicantsContainer) -
main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
r6202 r6622 40 40 grok.name('waeup.viewStudents') 41 41 42 class ManageStudents(grok.Permission): 43 grok.name('waeup.manageStudents') 44 42 45 # Local Roles 43 46 class DepartmentOfficer(grok.Role): … … 58 61 'waeup.View', 'waeup.Public','waeup.manageACBatches', 59 62 'waeup.manageDataCenter','waeup.managePortalSettings', 60 'waeup.manageApplications', 'waeup.handleApplication') 63 'waeup.manageApplications', 'waeup.handleApplication', 64 'waeup.viewStudents', 'waeup.manageStudents') 61 65 62 66 def getRoles(): -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6621 r6622 24 24 from zope.securitypolicy.interfaces import IPrincipalRoleManager 25 25 from zope.traversing.browser import absoluteURL 26 from zope.component import ( 27 createObject,) 26 28 27 29 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState … … 60 62 MultiListWidget, MultiListDisplayWidget) 61 63 from waeup.sirp.students.interfaces import ( 62 IStudentsContainer, 64 IStudentsContainer, IStudent, 65 ) 66 from waeup.sirp.students.students import ( 67 Student, 63 68 ) 64 69 … … 86 91 grok.require('waeup.viewStudents') 87 92 grok.template('studentscontainerpage') 88 pnav = 389 93 90 form_fields = grok.AutoFields(IStudentsContainer) .omit('title')94 form_fields = grok.AutoFields(IStudentsContainer) 91 95 #form_fields['description'].custom_widget = ReSTDisplayWidget 92 96 … … 98 102 def label(self): 99 103 return self.title 104 105 class StudentssContainerManageActionButton(ManageActionButton): 106 grok.order(1) 107 grok.context(IStudentsContainer) 108 grok.view(StudentsContainerPage) 109 grok.require('waeup.manageStudents') 110 text = 'Manage students' 111 112 class StudentsContainerManagePage(WAeUPDisplayFormPage): 113 """The standard view for regular student containers. 114 """ 115 grok.context(IStudentsContainer) 116 grok.name('manage') 117 grok.require('waeup.manageStudents') 118 grok.template('studentscontainerpage') 119 120 form_fields = grok.AutoFields(IStudentsContainer) 121 122 @property 123 def title(self): 124 return "Students" 125 126 @property 127 def label(self): 128 return self.title 129 130 @grok.action('Add student', validator=NullValidator) 131 def addStudent(self, **data): 132 self.redirect(self.url(self.context, 'addstudent')) 133 return 134 135 class StudentAddFormPage(WAeUPAddFormPage): 136 """Add-form to add a student. 137 """ 138 grok.context(IStudentsContainer) 139 grok.require('waeup.manageStudents') 140 grok.name('addstudent') 141 grok.template('studentaddpage') 142 form_fields = grok.AutoFields(IStudent) 143 title = 'Students' 144 label = 'Add student' 145 146 @grok.action('Create student record') 147 def addStudent(self, **data): 148 student_id = self.request.form.get('form.student_id') 149 student = createObject(u'waeup.Student') 150 self.applyData(student, **data) 151 #import pdb; pdb.set_trace() 152 try: 153 self.context[student_id] = student 154 except KeyError: 155 self.flash('The student id chosen already exists.') 156 return 157 self.redirect(self.url(self.context[student_id], 'index')) 158 return 159 160 class DisplayStudent(WAeUPDisplayFormPage): 161 grok.context(IStudent) 162 grok.name('index') 163 grok.require('waeup.viewStudents') 164 form_fields = grok.AutoFields(IStudent) 165 166 @property 167 def title(self): 168 return 'Student: %s' % self.context.name 169 170 @property 171 def label(self): 172 return self.context.name -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainerpage.pt
r6621 r6622 1 1 <h2 tal:content="view/label">Title</h2> 2 2 3 <form method="POST"> 3 4 <table class="zebra" tal:condition="layout/isAuthenticated"> 4 5 <tbody> … … 13 14 </tr> 14 15 </tal:block> 16 <tr> 17 <td> 18 <div class="actionButtons" tal:condition="view/availableActions"> 19 <span tal:repeat="action view/actions" tal:omit-tag=""> 20 <input tal:replace="structure action/render"/> 21 </span> 22 </div> 23 </td> 24 </tr> 15 25 </tbody> 16 26 </table> 27 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6621 r6622 8 8 """Representation of a student. 9 9 """ 10 student_id = schema.TextLine( 11 title = u'Student Id', 12 default = u'None', 13 required = True, 14 ) 15 10 16 name = schema.TextLine( 11 17 title = u'Name of student', … … 13 19 required = True, 14 20 ) 21 15 22 16 23 class IStudentsContainer(IWAeUPObject): -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6621 r6622 104 104 # Anonymous users can't access students containers 105 105 self.assertRaises( 106 Unauthorized, self.browser.open, self.container_path) 107 self.assertRaises( 106 108 Unauthorized, self.browser.open, self.manage_container_path) 107 109 return … … 114 116 self.assertEqual(self.browser.headers['Status'], '200 Ok') 115 117 self.assertEqual(self.browser.url, self.container_path) 118 self.browser.getLink("Manage students").click() 119 self.assertEqual(self.browser.headers['Status'], '200 Ok') 120 self.assertEqual(self.browser.url, self.manage_container_path) 116 121 return 122 123 def test_add_students(self): 124 # Managers can add students 125 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 126 self.add_student_path = self.container_path + '/addstudent' 127 self.container_manage_path = self.container_path + '/@@manage' 128 self.browser.open(self.container_manage_path) 129 self.browser.getControl("Add student").click() 130 self.assertEqual(self.browser.headers['Status'], '200 Ok') 131 self.assertEqual(self.browser.url, self.add_student_path) 132 self.browser.getControl(name="form.student_id").value = 'A123456' 133 self.browser.getControl(name="form.name").value = 'Bob Tester' 134 self.browser.getControl("Create student record").click()
Note: See TracChangeset for help on using the changeset viewer.