Changeset 7017 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 7 Nov 2011, 09:42:01 (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
r7015 r7017 1032 1032 title = 'Accommodation' 1033 1033 pnav = 4 1034 officers_only_actions = [' delBedTickets']1034 officers_only_actions = ['Remove selected'] 1035 1035 1036 1036 def formatDatetime(self,datetimeobj): … … 1049 1049 return 1050 1050 1051 @property 1052 def is_student(self): 1053 prm = get_principal_role_manager() 1054 roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)] 1055 return 'waeup.Student' in roles 1056 1051 1057 @grok.action('Remove selected') 1052 1058 def delBedTickets(self, **data): 1059 if self.is_student: 1060 self.flash('You are not allowed to remove bed tickets.') 1061 self.redirect(self.url(self.context)) 1062 return 1053 1063 form = self.request.form 1054 1064 if form.has_key('val_id'): … … 1074 1084 return 1075 1085 1076 def isStudent(self):1077 prm = get_principal_role_manager()1078 roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]1079 return 'waeup.Student' in roles1080 1081 1086 @property 1082 1087 def selected_actions(self): 1083 1088 sa = self.actions 1084 if self.is Student():1089 if self.is_student: 1085 1090 sa = [action for action in self.actions 1086 if not action inofficers_only_actions]1091 if not action.label in self.officers_only_actions] 1087 1092 return sa 1088 1093 -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/accommodationmanagepage.pt
r7009 r7017 18 18 <thead> 19 19 <tr> 20 <th > </th>20 <th tal:condition="not: view/is_student"> </th> 21 21 <th>Session</th> 22 22 <th>Booking Date</th> … … 27 27 <tbody> 28 28 <tr tal:repeat="cl context/values"> 29 <td >29 <td tal:condition="not: view/is_student"> 30 30 <input type="checkbox" 31 31 name="val_id" -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7015 r7017 751 751 752 752 def test_student_payments(self): 753 # Set up SessionConfiguration object753 # Login 754 754 self.browser.open(self.login_path) 755 755 self.browser.getControl(name="form.login").value = self.student_id … … 915 915 916 916 def test_student_accommodation(self): 917 return 917 # Login 918 self.browser.open(self.login_path) 919 self.browser.getControl(name="form.login").value = self.student_id 920 self.browser.getControl(name="form.password").value = 'spwd' 921 self.browser.getControl("Login").click() 922 923 # Students can add online booking fee payment tickets and open the 924 # callback view (see test_manage_payments) 925 self.browser.getLink("Payments").click() 926 self.browser.getControl("Add online payment ticket").click() 927 self.browser.getControl(name="form.p_category").value = ['bed_allocation'] 928 self.browser.getControl("Create ticket").click() 929 ctrl = self.browser.getControl(name='val_id') 930 value = ctrl.options[0] 931 self.browser.getLink(value).click() 932 self.browser.open(self.browser.url + '/callback') 933 # The new HOS-0 pin has been created 934 self.assertEqual(len(self.app['accesscodes']['HOS-0']),1) 935 pin = self.app['accesscodes']['HOS-0'].keys()[0] 936 ac = self.app['accesscodes']['HOS-0'][pin] 937 ac.owner = self.student_id 938 parts = pin.split('-')[1:] 939 sfeseries, sfenumber = parts 940 # Students can use HOS code and book a bed space with it 941 self.browser.open(self.acco_student_path) 942 self.browser.getLink("Book accommodation").click() 943 self.assertMatches('...You are in the wrong...', 944 self.browser.contents) 945 IWorkflowInfo(self.student).fireTransition('admit') 946 self.browser.getLink("Book accommodation").click() 947 self.assertMatches('...Activation Code:...', 948 self.browser.contents) 949 self.browser.getControl(name="ac_series").value = sfeseries 950 self.browser.getControl(name="ac_number").value = sfenumber 951 self.browser.getControl("Create bed ticket").click() 952 self.assertMatches('...Hall 1, Block A, Room 101, Bed A...', 953 self.browser.contents) 954 # Bed has been allocated 955 bed = self.app['hostels']['hall-1']['hall-1_A_101_A'] 956 self.assertTrue(bed.owner == self.student_id) 957 # BedTicketAddPage is now blocked 958 self.browser.getLink("Book accommodation").click() 959 self.assertMatches('...You already booked a bed space...', 960 self.browser.contents) 961 # The bed ticket displays the data correctly 962 self.browser.open(self.acco_student_path + '/2004') 963 self.assertMatches('...Hall 1, Block A, Room 101, Bed A...', 964 self.browser.contents) 965 self.assertMatches('...2004/2005...', self.browser.contents) 966 self.assertMatches('...regular_male_fr...', self.browser.contents) 967 self.assertMatches('...%s...' % pin, self.browser.contents) 968 # Students can't relocate themselves 969 self.assertFalse('Relocate' in self.browser.contents) 970 relocate_path = self.acco_student_path + '/2004/relocate' 971 self.assertRaises( 972 Unauthorized, self.browser.open, relocate_path) 973 # Students can't the Remove button and check boxes 974 self.browser.open(self.acco_student_path) 975 self.assertFalse('Remove' in self.browser.contents) 976 self.assertFalse('val_id' in self.browser.contents) 977 return
Note: See TracChangeset for help on using the changeset viewer.