Changeset 6626 for main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
- Timestamp:
- 25 Aug 2011, 12:01:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6622 r6626 45 45 from waeup.sirp.browser.resources import datepicker, tabs, datatable 46 46 from waeup.sirp.browser.viewlets import ( 47 ManageActionButton, PrimaryNavTab, LeftSidebarLink 47 ManageActionButton, PrimaryNavTab, LeftSidebarLink, AddActionButton, 48 48 ) 49 49 from waeup.sirp.image.browser.widget import ( … … 67 67 Student, 68 68 ) 69 from waeup.sirp.students.catalog import search 69 70 70 71 class StudentsTab(PrimaryNavTab): … … 84 85 return self.view.application_url('students') 85 86 86 class StudentsContainerPage(WAeUP DisplayFormPage):87 """The standard view for regularstudent containers.87 class StudentsContainerPage(WAeUPPage): 88 """The standard view for student containers. 88 89 """ 89 90 grok.context(IStudentsContainer) … … 92 93 grok.template('studentscontainerpage') 93 94 94 form_fields = grok.AutoFields(IStudentsContainer)95 #form_fields['description'].custom_widget = ReSTDisplayWidget96 97 95 @property 98 96 def title(self): … … 103 101 return self.title 104 102 105 class StudentssContainerManageActionButton(ManageActionButton): 103 def update(self, *args, **kw): 104 datatable.need() 105 form = self.request.form 106 self.hitlist = [] 107 if 'searchterm' in form and form['searchterm']: 108 self.searchterm = form['searchterm'] 109 self.searchtype = form['searchtype'] 110 elif 'old_searchterm' in form: 111 self.searchterm = form['old_searchterm'] 112 self.searchtype = form['old_searchtype'] 113 else: 114 if 'search' in form: 115 self.flash('Empty search string.') 116 return 117 self.hitlist = search(query=self.searchterm, 118 searchtype=self.searchtype, view=self) 119 if not self.hitlist: 120 self.flash('No student found.') 121 return 122 123 class StudentsContainerManageActionButton(ManageActionButton): 106 124 grok.order(1) 107 125 grok.context(IStudentsContainer) … … 110 128 text = 'Manage students' 111 129 112 class StudentsContainerManagePage(WAeUPDisplayFormPage): 113 """The standard view for regular student containers. 130 131 class StudentsContainerManagePage(WAeUPPage): 132 """The manage page for student containers. 114 133 """ 115 134 grok.context(IStudentsContainer) 116 135 grok.name('manage') 117 136 grok.require('waeup.manageStudents') 118 grok.template('studentscontainerpage') 119 120 form_fields = grok.AutoFields(IStudentsContainer) 137 grok.template('studentscontainermanagepage') 121 138 122 139 @property … … 128 145 return self.title 129 146 130 @grok.action('Add student', validator=NullValidator) 131 def addStudent(self, **data): 132 self.redirect(self.url(self.context, 'addstudent')) 147 def update(self, *args, **kw): 148 datatable.need() 149 form = self.request.form 150 self.hitlist = [] 151 if 'searchterm' in form and form['searchterm']: 152 self.searchterm = form['searchterm'] 153 self.searchtype = form['searchtype'] 154 elif 'old_searchterm' in form: 155 self.searchterm = form['old_searchterm'] 156 self.searchtype = form['old_searchtype'] 157 else: 158 if 'search' in form: 159 self.flash('Empty search string.') 160 return 161 #import pdb; pdb.set_trace() 162 if not 'entries' in form: 163 self.hitlist = search(query=self.searchterm, 164 searchtype=self.searchtype, view=self) 165 if not self.hitlist: 166 self.flash('No student found.') 167 return 168 entries = form['entries'] 169 if isinstance(entries, basestring): 170 entries = [entries] 171 deleted = [] 172 for entry in entries: 173 if 'remove' in form: 174 del self.context[entry] 175 deleted.append(entry) 176 self.hitlist = search(query=self.searchterm, 177 searchtype=self.searchtype, view=self) 178 if len(deleted): 179 self.flash('Successfully removed: %s' % ', '.join(deleted)) 133 180 return 181 182 class StudentsContainerAddActionButton(AddActionButton): 183 grok.order(1) 184 grok.context(IStudentsContainer) 185 grok.view(StudentsContainerManagePage) 186 grok.require('waeup.manageStudents') 187 text = 'Add student' 188 target = 'addstudent' 134 189 135 190 class StudentAddFormPage(WAeUPAddFormPage): … … 155 210 self.flash('The student id chosen already exists.') 156 211 return 212 self.flash('Student record created.') 157 213 self.redirect(self.url(self.context[student_id], 'index')) 158 214 return
Note: See TracChangeset for help on using the changeset viewer.