Ignore:
Timestamp:
21 Jun 2011, 11:09:33 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement search function for academic section. The courses_catalog and the certcourses_catalog are searched.

Remove search pages for students. Student search will be done in the upcoming student package.

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  
    3131    ICertificateAdd, ICertificateCourse, ICertificateCourseAdd)
    3232from waeup.sirp.browser.resources import warning, datepicker, tabs, datatable
    33 from waeup.sirp.catalog import search_context
    3433from waeup.sirp.interfaces import(
    3534    IWAeUPObject, IUserContainer, IUserAccount, IDataCenter,
     
    332331# Search pages...
    333332#
    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 = 2
    341 
    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 
    348333
    349334class SearchPage(WAeUPPage):
    350     grok.context(IUniversity)
     335    """General search page for the academics section.
     336    """
     337    grok.context(IFacultyContainer)
    351338    grok.name('search')
    352339    grok.template('searchpage')
    353340    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
    356344
    357345    def update(self, *args, **kw):
     346        datatable.need()
    358347        form = self.request.form
    359348        self.hitlist = []
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css

    r6341 r6447  
    5252}
    5353
     54.block .bd {
     55    padding-bottom: 3em;
     56}
     57
    5458/* Define different styles for headlines in rendered restructured text */
    5559
     
    9195.dataTables_wrapper {
    9296  min-height: 100px;
     97}
     98
     99.dataTables_info {
     100  padding-top: 10px;
     101}
     102
     103.dataTables_paginate {
     104  padding-top: 10px;
    93105}
    94106
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/searchpage.pt

    r4789 r6447  
    1 <h3>Search the site</h3>
     1<h2 i18n:translate="" tal:condition="view/label" tal:content="view/label">Label</h2>
    22<form method="post">
    33  <input type="text" name="query"
    44         tal:attributes="value view/query" />
    5     <input type="submit" name="SUBMIT" value="search..." />
     5    <input type="submit" name="SUBMIT" value="Search" />
    66</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  
    2020manager_pages = [
    2121    # The pages that should only be accessible by manager...
    22     '/@@manage', '/@@administration', '/@@searchstudent', '/@@search',
     22    '/@@manage', '/@@administration', '/faculties/@@search',
    2323    '/users/@@index', '/users/@@add', '/users/alice/@@index',
    2424    '/datacenter/@@index', '/datacenter/@@upload', '/datacenter/@@import1',
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r6396 r6447  
    346346    grok.view(FacultyContainerPage)
    347347    text = 'Manage academic section'
     348
     349class 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'
    348357   
    349358class ManageFacultyActionButton(ManageActionButton):
  • main/waeup.sirp/trunk/src/waeup/sirp/catalog.py

    r6207 r6447  
    1212from waeup.sirp.app import University
    1313from waeup.sirp.interfaces import IQueryResultItem
    14 from waeup.sirp.student.interfaces import IStudent
    1514
     15# not yet used
    1616class WAeUPQuery(Query):
    1717    """A hurry.query-like query that supports also ``apply``.
     
    3535grok.global_utility(WAeUPQuery)
    3636
    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
    4438class QueryResultItem(object):
    4539    grok.implements(IQueryResultItem)
     
    5347        self.title = context.title
    5448        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  
    22"""
    33import grok
    4 from hurry.query import Eq
     4from hurry.query import Eq, Text
     5from hurry.query.query import Query
    56from zope.catalog.interfaces import ICatalog
    67from zope.component import getUtility
    78from zope.component.interfaces import ComponentLookupError
     9from zope.index.text.parsetree import ParseError
    810from zope.intid import IIntIds
    9 from waeup.sirp.catalog import QueryResultItem
     11#from waeup.sirp.catalog import QueryResultItem
    1012from waeup.sirp.index import UniqueField
    11 from waeup.sirp.interfaces import IUniversity
     13from waeup.sirp.interfaces import IUniversity, IQueryResultItem
    1214from waeup.sirp.university.interfaces import (
    1315    ICourse, ICertificateCourse, IDepartment,
    1416    ICertificate,
    1517    )
    16 
    1718
    1819class CourseIndexes(grok.Indexes):
     
    9293    return
    9394
    94 class CourseQueryResultItem(QueryResultItem):
     95class CoursesQueryResultItem(object):
     96    grok.implements(IQueryResultItem)
     97
    9598    def __init__(self, context, view):
    9699        self.context = context
    97100        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
     105class 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'
    100114
    101115def search(query=None, view=None):
    102116    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
    106119
    107120    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))
    112130
    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
    119138    return hitlist
Note: See TracChangeset for help on using the changeset viewer.