- Timestamp:
- 16 Nov 2015, 09:05:30 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r13455 r13457 1928 1928 grok.template('accommodationmanagepage') 1929 1929 pnav = 4 1930 officers_only_actions = [_('Remove selected')] 1930 with_hostel_selection = True 1931 1932 @property 1933 def actionsgroup1(self): 1934 if not self.with_hostel_selection: 1935 return [] 1936 students_utils = getUtility(IStudentsUtils) 1937 acc_details = students_utils.getAccommodationDetails(self.context.student) 1938 error_message = students_utils.checkAccommodationRequirements( 1939 self.context.student, acc_details) 1940 if error_message: 1941 return [] 1942 return [_('Save')] 1943 1944 @property 1945 def actionsgroup2(self): 1946 if getattr(self.request.principal, 'user_type', None) == 'student': 1947 return [_('Book accommodation')] 1948 return [_('Book accommodation'), _('Remove selected')] 1931 1949 1932 1950 @property … … 1934 1952 return _('${a}: Accommodation', 1935 1953 mapping = {'a':self.context.__parent__.display_fullname}) 1954 1955 def getHostels(self): 1956 """Get a list of all stored hostels. 1957 """ 1958 yield(dict(name=None, title='--', selected='')) 1959 for val in grok.getSite()['hostels'].values(): 1960 selected = '' 1961 if val.hostel_id == self.context.desired_hostel: 1962 selected = 'selected' 1963 yield(dict(name=val.hostel_id, title=val.hostel_name, 1964 selected=selected)) 1965 1966 @action(_('Save'), style='primary') 1967 def save(self): 1968 hostel = self.request.form.get('hostel', None) 1969 self.context.desired_hostel = hostel 1970 self.flash(_('Your selection has been saved.')) 1971 return 1972 1973 @jsaction(_('Book accommodation'), style='primary') 1974 def bookAccommodation(self, **data): 1975 self.redirect(self.url(self.context, 'add')) 1976 return 1936 1977 1937 1978 @jsaction(_('Remove selected')) … … 1962 2003 self.redirect(self.url(self.context)) 1963 2004 return 1964 1965 @property1966 def selected_actions(self):1967 if getattr(self.request.principal, 'user_type', None) == 'student':1968 return [action for action in self.actions1969 if not action.label in self.officers_only_actions]1970 return self.actions1971 2005 1972 2006 class BedTicketAddPage(KofaPage): … … 2030 2064 if available_beds: 2031 2065 students_utils = getUtility(IStudentsUtils) 2032 bed = students_utils.selectBed(available_beds) 2066 bed = students_utils.selectBed( 2067 available_beds, self.context.desired_hostel) 2068 if bed is None: 2069 self.flash(_( 2070 'There is no free bed in your desired hostel. ' 2071 'Please try another hostel.'), 2072 type="warning") 2073 self.redirect(self.url(self.context)) 2074 return 2033 2075 # Safety belt for paranoids: Does this bed really exist 2034 2076 # in portal? … … 2045 2087 self.flash(_('There is no free bed in your category ${a}.', 2046 2088 mapping = {'a':acc_details['bt']}), type="warning") 2089 self.redirect(self.url(self.context)) 2047 2090 return 2048 2091 if self.with_ac:
Note: See TracChangeset for help on using the changeset viewer.