Changeset 6447
- Timestamp:
- 21 Jun 2011, 11:09:33 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6368 r6447 31 31 ICertificateAdd, ICertificateCourse, ICertificateCourseAdd) 32 32 from waeup.sirp.browser.resources import warning, datepicker, tabs, datatable 33 from waeup.sirp.catalog import search_context34 33 from waeup.sirp.interfaces import( 35 34 IWAeUPObject, IUserContainer, IUserAccount, IDataCenter, … … 332 331 # Search pages... 333 332 # 334 class SearchStudentPage(WAeUPPage):335 grok.context(IUniversity)336 grok.name('searchstudent')337 grok.template('searchstudentpage')338 grok.require('waeup.viewStudents')339 title = u"Student Search"340 pnav = 2341 342 def update(self, query=None):343 self.search_result = []344 if query is not None:345 self.search_result = search_context(query)346 print "RESULT: ", list(self.search_result)347 348 333 349 334 class SearchPage(WAeUPPage): 350 grok.context(IUniversity) 335 """General search page for the academics section. 336 """ 337 grok.context(IFacultyContainer) 351 338 grok.name('search') 352 339 grok.template('searchpage') 353 340 grok.require('waeup.manageUniversity') 354 title = u"Site Search" 355 pnav = 2 341 title = u"Academics" 342 label = u"Search Academic Section" 343 pnav = 1 356 344 357 345 def update(self, *args, **kw): 346 datatable.need() 358 347 form = self.request.form 359 348 self.hitlist = [] -
main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css
r6341 r6447 52 52 } 53 53 54 .block .bd { 55 padding-bottom: 3em; 56 } 57 54 58 /* Define different styles for headlines in rendered restructured text */ 55 59 … … 91 95 .dataTables_wrapper { 92 96 min-height: 100px; 97 } 98 99 .dataTables_info { 100 padding-top: 10px; 101 } 102 103 .dataTables_paginate { 104 padding-top: 10px; 93 105 } 94 106 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/searchpage.pt
r4789 r6447 1 <h 3>Search the site</h3>1 <h2 i18n:translate="" tal:condition="view/label" tal:content="view/label">Label</h2> 2 2 <form method="post"> 3 3 <input type="text" name="query" 4 4 tal:attributes="value view/query" /> 5 <input type="submit" name="SUBMIT" value=" search..." />5 <input type="submit" name="SUBMIT" value="Search" /> 6 6 </form> 7 <div tal:condition="view/hitlist"> 8 <h4>Results (<span tal:replace="python: len(view.hitlist)" />):</h4> 9 <div tal:repeat="item view/hitlist"> 10 <a href="" 11 tal:attributes="href item/url" 12 tal:content="item/title">Search Item Title</a> 13 <div tal:content="item/description"> 14 Longer description of item... 15 </div> 16 </div> 17 </div> 7 <br /> 8 <span tal:condition="view/hitlist"> 9 <h3>Results:</h3> 10 <table class="display dataTable"> 11 <thead> 12 <tr> 13 <th>Code</th> 14 <th>Title</th> 15 <th>Type</th> 16 </tr> 17 </thead> 18 <tbody> 19 <tr tal:repeat="item view/hitlist" class="gradeB"> 20 <td> 21 <a href="" tal:attributes="href item/url" 22 tal:content="item/code">Code</a> 23 </td> 24 <td tal:content="item/title"> 25 Title 26 </td> 27 <td tal:content="item/type"> 28 Type 29 </td> 30 </tr> 31 </tbody> 32 </table> 33 </span> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/test_permissions.py
r6212 r6447 20 20 manager_pages = [ 21 21 # The pages that should only be accessible by manager... 22 '/@@manage', '/@@administration', '/ @@searchstudent', '/@@search',22 '/@@manage', '/@@administration', '/faculties/@@search', 23 23 '/users/@@index', '/users/@@add', '/users/alice/@@index', 24 24 '/datacenter/@@index', '/datacenter/@@upload', '/datacenter/@@import1', -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r6396 r6447 346 346 grok.view(FacultyContainerPage) 347 347 text = 'Manage academic section' 348 349 class SearchFacultyContainerActionButton(ManageActionButton): 350 """ 'Manage settings' button for faculties. 351 """ 352 grok.context(IFacultyContainer) 353 grok.view(FacultyContainerPage) 354 text = 'Search academic section' 355 icon = 'actionicon_search.png' 356 target = '@@search' 348 357 349 358 class ManageFacultyActionButton(ManageActionButton): -
main/waeup.sirp/trunk/src/waeup/sirp/catalog.py
r6207 r6447 12 12 from waeup.sirp.app import University 13 13 from waeup.sirp.interfaces import IQueryResultItem 14 from waeup.sirp.student.interfaces import IStudent15 14 15 # not yet used 16 16 class WAeUPQuery(Query): 17 17 """A hurry.query-like query that supports also ``apply``. … … 35 35 grok.global_utility(WAeUPQuery) 36 36 37 class StudentIndexes(grok.Indexes): 38 grok.site(University) 39 grok.name('students_catalog') 40 grok.context(IStudent) 41 42 name = grok.index.Field(attribute='name') 43 37 # not yet used 44 38 class QueryResultItem(object): 45 39 grok.implements(IQueryResultItem) … … 53 47 self.title = context.title 54 48 self.description = '' 55 56 def search_context(query):57 result = Query().searchResults(58 Eq(('students_catalog', 'name'), query)59 )60 return result -
main/waeup.sirp/trunk/src/waeup/sirp/university/catalog.py
r6220 r6447 2 2 """ 3 3 import grok 4 from hurry.query import Eq 4 from hurry.query import Eq, Text 5 from hurry.query.query import Query 5 6 from zope.catalog.interfaces import ICatalog 6 7 from zope.component import getUtility 7 8 from zope.component.interfaces import ComponentLookupError 9 from zope.index.text.parsetree import ParseError 8 10 from zope.intid import IIntIds 9 from waeup.sirp.catalog import QueryResultItem11 #from waeup.sirp.catalog import QueryResultItem 10 12 from waeup.sirp.index import UniqueField 11 from waeup.sirp.interfaces import IUniversity 13 from waeup.sirp.interfaces import IUniversity, IQueryResultItem 12 14 from waeup.sirp.university.interfaces import ( 13 15 ICourse, ICertificateCourse, IDepartment, 14 16 ICertificate, 15 17 ) 16 17 18 18 19 class CourseIndexes(grok.Indexes): … … 92 93 return 93 94 94 class CourseQueryResultItem(QueryResultItem): 95 class CoursesQueryResultItem(object): 96 grok.implements(IQueryResultItem) 97 95 98 def __init__(self, context, view): 96 99 self.context = context 97 100 self.url = view.url(context) 98 self.title = "COURSE: " + context.title 99 self.description = 'code: %s' % context.code 101 self.title = context.title 102 self.code = context.code 103 self.type = 'Course' 104 105 class CertificateCoursesQueryResultItem(object): 106 grok.implements(IQueryResultItem) 107 108 def __init__(self, context, view): 109 self.context = context 110 self.url = view.url(context) 111 self.title = context.course.title 112 self.code = context.getCourseCode 113 self.type = 'Course Referrer' 100 114 101 115 def search(query=None, view=None): 102 116 if not query: 103 return [] 104 cat = getUtility(ICatalog, name='courses_catalog') 105 results = list(cat.searchResults(code=(query, query))) 117 view.flash('Empty search string.') 118 return 106 119 107 120 hitlist = [] 108 results = Query().searchResults( 109 Eq(('courses_catalog', 'code'), query)) 110 for result in results: 111 hitlist.append(CourseQueryResultItem(result, view=view)) 121 try: 122 results = Query().searchResults( 123 Eq(('courses_catalog', 'code'), query)) 124 for result in results: 125 hitlist.append(CoursesQueryResultItem(result, view=view)) 126 results = Query().searchResults( 127 Text(('courses_catalog', 'title'), query)) 128 for result in results: 129 hitlist.append(CoursesQueryResultItem(result, view=view)) 112 130 113 results = Query().searchResults( 114 Text(('courses_catalog', 'title'), query)) 115 116 for result in results: 117 hitlist.append(CourseQueryResultItem(result, view=view)) 118 131 results = Query().searchResults( 132 Eq(('certcourses_catalog', 'course_code'), query)) 133 for result in results: 134 hitlist.append(CertificateCoursesQueryResultItem(result, view=view)) 135 except ParseError: 136 view.flash('Search string not allowed.') 137 return 119 138 return hitlist
Note: See TracChangeset for help on using the changeset viewer.