Changeset 7009
- Timestamp:
- 6 Nov 2011, 17:24:21 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7006 r7009 132 132 title = u'Accommodation' 133 133 134 #@property 135 #def target(self): 136 # prm = get_principal_role_manager() 137 # principal = get_current_principal() 138 # roles = [x[0] for x in prm.getRolesForPrincipal(principal.id)] 139 # if 'waeup.Student' in roles: 140 # return 'index' 141 # else: 142 # return 'manage' 143 134 144 class BedTicketBreadcrumb(Breadcrumb): 135 145 """A breadcrumb for bed tickets. 136 146 """ 137 147 grok.context(IBedTicket) 138 @property 139 148 149 @property 140 150 def title(self): 141 151 return 'Bed Ticket %s' % self.context.getSessionString() … … 1012 1022 # This manage form page is for both students and students officers. 1013 1023 class AccommodationManageFormPage(WAeUPEditFormPage): 1014 """ Page to manage the bed tickets1024 """ Page to manage bed tickets. 1015 1025 """ 1016 1026 grok.context(IStudentAccommodation) … … 1021 1031 title = 'Accommodation' 1022 1032 pnav = 4 1023 1024 def unremovable(self): 1025 prm = get_principal_role_manager() 1026 roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)] 1027 return ('waeup.Student' in roles) 1033 officers_only_actions = ['delBedTickets'] 1028 1034 1029 1035 def formatDatetime(self,datetimeobj): … … 1042 1048 return 1043 1049 1044 # We need an event handler which releases the bed space too. 1045 @grok.action('Remove selected tickets') 1046 def delBedTicket(self, **data): 1050 @grok.action('Remove selected') 1051 def delBedTickets(self, **data): 1047 1052 form = self.request.form 1048 1053 if form.has_key('val_id'): … … 1056 1061 deleted = [] 1057 1062 for id in child_id: 1058 # Students are not allowed to remove bed tickets 1059 if not self.unremovable(): 1060 try: 1061 del self.context[id] 1062 deleted.append(id) 1063 except: 1064 self.flash('Could not delete %s: %s: %s' % ( 1065 id, sys.exc_info()[0], sys.exc_info()[1])) 1063 try: 1064 del self.context[id] 1065 deleted.append(id) 1066 except: 1067 self.flash('Could not delete %s: %s: %s' % ( 1068 id, sys.exc_info()[0], sys.exc_info()[1])) 1066 1069 if len(deleted): 1067 1070 self.flash('Successfully removed: %s' % ', '.join(deleted)) … … 1070 1073 return 1071 1074 1072 @grok.action(' Add bed ticket')1075 @grok.action('Book accommodation') 1073 1076 def addBedTicket(self, **data): 1074 1077 self.redirect(self.url(self.context, '@@add')) 1078 1079 def isStudent(self): 1080 prm = get_principal_role_manager() 1081 roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)] 1082 return 'waeup.Student' in roles 1083 1084 @property 1085 def selected_actions(self): 1086 sa = self.actions 1087 if self.isStudent(): 1088 sa = [action for action in self.actions 1089 if not action in officers_only_actions] 1090 return sa 1075 1091 1076 1092 class BedTicketAddPage(WAeUPPage): -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/accommodationmanagepage.pt
r7007 r7009 30 30 <input type="checkbox" 31 31 name="val_id" 32 tal:attributes="value cl/__name__" 33 tal:condition="not: view/unremovable" /> 32 tal:attributes="value cl/__name__" /> 34 33 </td> 35 34 <td> <a tal:attributes="href cl/__name__"> … … 43 42 44 43 <div class="actionButtons" tal:condition="view/availableActions"> 45 <span tal:repeat="action view/ actions"44 <span tal:repeat="action view/selected_actions" 46 45 tal:omit-tag=""> 47 46 <input tal:replace="structure action/render"/> -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7006 r7009 497 497 self.assertTrue('Processing of 1 rows failed' in self.browser.contents) 498 498 self.assertTrue('Successfully processed 2 rows' in self.browser.contents) 499 return 499 500 500 501 def test_student_change_password(self): … … 741 742 self.assertMatches('...Clearance process has been started...', 742 743 self.browser.contents) 743 744 return 744 745 745 746 def test_student_payments(self): … … 834 835 self.browser.contents) 835 836 self.assertTrue(self.student.state,'school fee paid') 837 return 836 838 837 839 def test_manage_accommodation(self): … … 856 858 # Managers can use HOS code and book a bed space with it 857 859 self.browser.open(self.acco_student_path) 858 self.browser.getControl(" Add bed ticket").click()860 self.browser.getControl("Book accommodation").click() 859 861 self.assertMatches('...Wrong state...', 860 862 self.browser.contents) 861 863 IWorkflowInfo(self.student).fireTransition('admit') 862 self.browser.getControl(" Add bed ticket").click()864 self.browser.getControl("Book accommodation").click() 863 865 self.assertMatches('...Activation Code:...', 864 866 self.browser.contents) … … 872 874 self.assertTrue(bed.owner,self.student_id) 873 875 # BedTicketAddPage is now blocked 874 self.browser.getControl(" Add bed ticket").click()876 self.browser.getControl("Book accommodation").click() 875 877 self.assertMatches('...Ticket for 2004 already created...', 876 878 self.browser.contents) … … 889 891 self.browser.getControl("Remove selected", index=0).click() 890 892 self.assertMatches('...Successfully removed...', self.browser.contents) 891 # Due to an event handler also the bed has been released properly893 # The bed has been released properly by the event handler 892 894 bed = self.app['hostels']['hall-1']['hall-1_A_101_A'] 893 895 self.assertTrue(bed.owner == NOT_OCCUPIED) 896 return 894 897 895 898 def test_student_accommodation(self): 896 pass899 return
Note: See TracChangeset for help on using the changeset viewer.