Changeset 10646 for main/waeup.kofa/trunk/src/waeup/kofa/browser
- Timestamp:
- 24 Sep 2013, 12:39:44 (11 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r10541 r10646 26 26 from datetime import datetime, timedelta 27 27 from urllib import urlencode 28 from hurry.query import Eq, Text 29 from hurry.query.query import Query 28 30 from zope import schema 29 31 from zope.i18n import translate … … 72 74 73 75 from waeup.kofa.students.export import EXPORTER_NAMES as STUDENT_EXPORTERS 76 from waeup.kofa.students.catalog import StudentQueryResultItem 74 77 75 78 FORBIDDEN_CHARACTERS = (160,) … … 1850 1853 return del_local_roles(self,3,**data) 1851 1854 1855 class FindStudentsPage(KofaPage): 1856 """Search students in faculty. 1857 """ 1858 grok.context(IFaculty) 1859 grok.name('find_students') 1860 grok.require('waeup.showStudents') 1861 grok.template('findstudentspage') 1862 label = _('Find students') 1863 search_button = _('Find student') 1864 pnav = 1 1865 1866 def _find_students(self,query=None, searchtype=None, view=None): 1867 hitlist = [] 1868 if searchtype in ('fullname',): 1869 results = Query().searchResults( 1870 Text(('students_catalog', searchtype), query) & 1871 Eq(('students_catalog', 'faccode'), self.context.code) 1872 ) 1873 else: 1874 results = Query().searchResults( 1875 Eq(('students_catalog', searchtype), query) & 1876 Eq(('students_catalog', 'faccode'), self.context.code) 1877 ) 1878 for result in results: 1879 hitlist.append(StudentQueryResultItem(result, view=view)) 1880 return hitlist 1881 1882 def update(self, *args, **kw): 1883 datatable.need() 1884 form = self.request.form 1885 self.hitlist = [] 1886 if 'searchterm' in form and form['searchterm']: 1887 self.searchterm = form['searchterm'] 1888 self.searchtype = form['searchtype'] 1889 elif 'old_searchterm' in form: 1890 self.searchterm = form['old_searchterm'] 1891 self.searchtype = form['old_searchtype'] 1892 else: 1893 if 'search' in form: 1894 self.flash(_('Empty search string')) 1895 return 1896 self.hitlist = self._find_students(query=self.searchterm, 1897 searchtype=self.searchtype, view=self) 1898 if not self.hitlist: 1899 self.flash(_('No student found.')) 1900 return 1901 1852 1902 class DepartmentAddFormPage(KofaAddFormPage): 1853 1903 """Add a department to a faculty. -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r10633 r10646 446 446 text = _('Manage faculty') 447 447 448 class StudentSearchActionButton(ManageActionButton): 449 grok.order(2) 450 grok.context(IFaculty) 451 grok.view(FacultyPage) 452 grok.require('waeup.showStudents') 453 text = _('Find students') 454 icon = 'actionicon_search.png' 455 target = 'find_students' 456 448 457 class ManageDepartmentActionButton(ManageActionButton): 449 458 """ 'Manage settings' button for departments.
Note: See TracChangeset for help on using the changeset viewer.