Changeset 6000 for main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
- Timestamp:
- 1 May 2011, 04:05:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r5999 r6000 155 155 return 156 156 157 class RemoveFormPage(WAeUPPage):158 grok.require('waeup.manageUniversity')159 grok.name('remove')160 grok.template('removesubobjectspage')161 pnav = 1162 163 def update(self):164 warning.need()165 form = self.request.form166 if 'CANCEL' in form.keys():167 self.redirect(self.url(self.context))168 if not 'REMOVE' in form.keys():169 return170 child_id = form['val_id']171 if not isinstance(child_id, list):172 child_id = [child_id]173 deleted = []174 for id in child_id:175 try:176 del self.context[id]177 deleted.append(id)178 except:179 self.flash('Could not delete %s: %s: %s' % (180 id, sys.exc_info()[0], sys.exc_info()[1]))181 if len(deleted):182 self.flash('Successfully removed: %s' % ', '.join(deleted))183 # We have to redirect to let flash messages appear immediately...184 self.redirect(self.url())185 return157 #class RemoveFormPage(WAeUPPage): 158 # grok.require('waeup.manageUniversity') 159 # grok.name('remove') 160 # grok.template('removesubobjectspage') 161 # pnav = 1 162 # 163 # def update(self): 164 # warning.need() 165 # form = self.request.form 166 # if 'CANCEL' in form.keys(): 167 # self.redirect(self.url(self.context)) 168 # if not 'REMOVE' in form.keys(): 169 # return 170 # child_id = form['val_id'] 171 # if not isinstance(child_id, list): 172 # child_id = [child_id] 173 # deleted = [] 174 # for id in child_id: 175 # try: 176 # del self.context[id] 177 # deleted.append(id) 178 # except: 179 # self.flash('Could not delete %s: %s: %s' % ( 180 # id, sys.exc_info()[0], sys.exc_info()[1])) 181 # if len(deleted): 182 # self.flash('Successfully removed: %s' % ', '.join(deleted)) 183 # # We have to redirect to let flash messages appear immediately... 184 # self.redirect(self.url()) 185 # return 186 186 187 187 class AdministrationPage(WAeUPPage): … … 846 846 grok.name('index') 847 847 title = 'Academics' 848 label = ' Faculties'848 label = 'Academic Section' 849 849 pnav = 1 850 850 grok.template('facultypage') … … 884 884 'in the database') 885 885 return 886 self.redirect(self.url(self.context ))886 self.redirect(self.url(self.context, u'@@manage')+'#tab-1') 887 887 888 888 @grok.action('Cancel') … … 890 890 self.redirect(self.url(self.context)) 891 891 892 class RemoveFacultyFormPage(RemoveFormPage):893 894 """895 grok.context(IFacultyContainer)896 title = "Remove faculty"897 pnav = 1892 #class RemoveFacultyFormPage(RemoveFormPage): 893 # """ Remove Faculty Page 894 # """ 895 # grok.context(IFacultyContainer) 896 # title = "Remove faculty" 897 # pnav = 1 898 898 899 899 # … … 953 953 'in the database') 954 954 return 955 self.redirect(self.url(self.context, u'@@manage') )955 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 956 956 957 957 @grok.action('Cancel') … … 969 969 taboneactions = ['Save','Save and return','Cancel'] 970 970 tabtwoactions = ['Add department', 'Remove selected','Cancel'] 971 subunits = 'Departments' 971 972 972 973 form_fields = grok.AutoFields(IFaculty) … … 1007 1008 if len(deleted): 1008 1009 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1010 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1009 1011 return 1010 1012 1011 1013 @grok.action('Add department', validator=NullValidator) 1012 1014 def addDepartment(self, **data): 1015 self.redirect(self.url(self.context, '@@add')) 1016 return 1017 1018 @grok.action('Cancel', validator=NullValidator) 1019 def cancel(self, **data): 1020 self.redirect(self.url(self.context)) 1021 return 1022 1023 class ManageFacultyContainerFormPage(WAeUPEditFormPage): 1024 """Manage the basic properties of a `Faculty` instance. 1025 """ 1026 grok.context(IFacultyContainer) 1027 grok.name('manage') 1028 grok.require('waeup.manageUniversity') 1029 grok.template('facultycontainermanagepage') 1030 pnav = 1 1031 taboneactions = ['Add faculty', 'Remove selected','Cancel'] 1032 subunits = 'Faculties' 1033 title = 'Academics' 1034 1035 @property 1036 def label(self): 1037 return 'Manage academic section' 1038 1039 def update(self): 1040 tabs.need() 1041 #warning.need() 1042 return super(ManageFacultyContainerFormPage, self).update() 1043 1044 # ToDo: Show warning message before deletion 1045 @grok.action('Remove selected') 1046 def delFaculties(self, **data): 1047 form = self.request.form 1048 child_id = form['val_id'] 1049 if not isinstance(child_id, list): 1050 child_id = [child_id] 1051 deleted = [] 1052 for id in child_id: 1053 try: 1054 del self.context[id] 1055 deleted.append(id) 1056 except: 1057 self.flash('Could not delete %s: %s: %s' % ( 1058 id, sys.exc_info()[0], sys.exc_info()[1])) 1059 if len(deleted): 1060 self.flash('Successfully removed: %s' % ', '.join(deleted)) 1061 self.redirect(self.url(self.context, '@@manage')+'#tab-1') 1062 return 1063 1064 @grok.action('Add faculty', validator=NullValidator) 1065 def addFaculty(self, **data): 1013 1066 self.redirect(self.url(self.context, '@@add')) 1014 1067 return
Note: See TracChangeset for help on using the changeset viewer.