Ignore:
Timestamp:
9 May 2012, 22:34:42 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement search page for applicants. Add fullname to applicants_catalog.
Plugins must be updated and /reindex?ctlg=applicants must be performed.

Tests will follow.

Rename ApplicantCatalog? to ApplicantsCatalog?. This does not affect persistent data.

Rename StudentIndexes? to StudentsCatalog?.

Add more localization.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py

    r8383 r8404  
    2020from cStringIO import StringIO
    2121from grok import index
     22from hurry.query import Eq, Text
     23from hurry.query.query import Query
    2224from zope.component import getUtility, createObject, getAdapter
    2325from zope.component.interfaces import IFactory
     
    3739from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit
    3840from waeup.kofa.applicants.workflow import application_states_dict
     41
     42def search(query=None, searchtype=None, view=None):
     43    if searchtype in ('fullname',):
     44        results = Query().searchResults(
     45            Text(('applicants_catalog', searchtype), query))
     46    else:
     47        results = Query().searchResults(
     48            Eq(('applicants_catalog', searchtype), query))
     49    return results
    3950
    4051class Applicant(grok.Container):
     
    157168Applicant = attrs_to_fields(Applicant)
    158169
    159 class ApplicantCatalog(grok.Indexes):
     170class ApplicantsCatalog(grok.Indexes):
    160171    """A catalog indexing :class:`Applicant` instances in the ZODB.
    161172    """
     
    164175    grok.context(IApplicant)
    165176
    166     #access_code = index.Field(attribute='access_code')
     177    fullname = index.Text(attribute='display_fullname')
    167178    applicant_id = index.Field(attribute='applicant_id')
    168179    reg_number = index.Field(attribute='reg_number')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8390 r8404  
    3636    IApplicantRegisterUpdate
    3737    )
     38from waeup.kofa.applicants.applicant import search
    3839from waeup.kofa.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED
    3940from waeup.kofa.browser import (
     
    6869    form_fields['description'].custom_widget = HTMLDisplayWidget
    6970    label = _('Application Section')
     71    search_button = _('Search')
    7072    pnav = 3
    7173
     
    8385            html = self.context.description_dict.get(portal_language,'')
    8486        return html
     87
     88class ApplicantsSearchPage(KofaPage):
     89    grok.context(IApplicantsRoot)
     90    grok.name('search')
     91    grok.require('waeup.viewApplication')
     92    label = _('Search applicants')
     93    search_button = _('Search')
     94    pnav = 3
     95
     96    def update(self, *args, **kw):
     97        datatable.need()
     98        form = self.request.form
     99        self.results = []
     100        if 'searchterm' in form and form['searchterm']:
     101            self.searchterm = form['searchterm']
     102            self.searchtype = form['searchtype']
     103        elif 'old_searchterm' in form:
     104            self.searchterm = form['old_searchterm']
     105            self.searchtype = form['old_searchtype']
     106        else:
     107            if 'search' in form:
     108                self.flash(_('Empty search string'))
     109            return
     110        self.results = search(query=self.searchterm,
     111            searchtype=self.searchtype, view=self)
     112        if not self.results:
     113            self.flash(_('No applicant found.'))
     114        return
    85115
    86116class ApplicantsRootManageFormPage(KofaEditFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r8262 r8404  
    8282        return self.view.application_url() + rel_link
    8383
     84class SearchApplicantsActionButton(ManageActionButton):
     85    grok.order(1)
     86    grok.context(IApplicantsRoot)
     87    grok.view(ApplicantsRootPage)
     88    grok.require('waeup.viewApplication')
     89    text = _('Search applicants')
     90    icon = 'actionicon_search.png'
     91    target = '@@search'
     92
    8493class ManageApplicantsRootActionButton(ManageActionButton):
     94    grok.order(2)
    8595    grok.context(IApplicantsRoot)
    8696    grok.view(ApplicantsRootPage)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8346 r8404  
    189189                self.searchterm = int(self.searchterm)
    190190            except ValueError:
    191                 self.flash('Only year dates allowed (e.g. 2011).')
     191                self.flash(_('Only year dates allowed (e.g. 2011).'))
    192192                return
    193193        self.hitlist = search(query=self.searchterm,
    194194            searchtype=self.searchtype, view=self)
    195195        if not self.hitlist:
    196             self.flash('No student found.')
     196            self.flash(_('No student found.'))
    197197        return
    198198
  • main/waeup.kofa/trunk/src/waeup/kofa/students/catalog.py

    r8244 r8404  
    3030from waeup.kofa.university.vocabularies import course_levels
    3131
    32 class StudentIndexes(grok.Indexes):
     32class StudentsCatalog(grok.Indexes):
    3333    """A catalog for students.
    3434    """
Note: See TracChangeset for help on using the changeset viewer.