Changeset 589


Ignore:
Timestamp:
29 Sep 2006, 06:59:13 (18 years ago)
Author:
joachim
Message:

studentSearch enhenced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py

    r587 r589  
    1212return Info about the current Student
    1313"""
     14#from Products.ZCTextIndex.QueryParser import ParseError,QueryError
    1415request = context.REQUEST
    1516form = request.form
     
    5556if state == " ----- ":
    5657    state = ''
     58err = False
    5759if not term and what in ('student_edit','jamb_id','name','matric_no'):
     60    psm = "You must specify a search string"
     61    err = True
     62elif '*' in term:
     63    psm = "You cannot use '*'"
     64    err = True
     65if err:
    5866    return context.students_manager_view(rendered = rend,
    59                              psm = "You must specify a search string",
     67                             psm = psm,
    6068                             #psm = "%s, %s" % (psm,ds),
    6169                             students = items,
     
    6674res = []
    6775portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
     76st_queries = ('jamb_id','matric_no','name')
    6877if onlyreview:
    6978    res = catalog(portal_type=portal_type_query,
     
    7281    res = catalog(portal_type='Student',
    7382                  id = term.strip())
    74 elif what == "jamb_id":
    75     res = catalog(portal_type='StudentApplication',
    76                   SearchableText="%s*" % term.strip().lower())
    77 elif what == "matric_no":
    78     res = catalog(portal_type='StudentClearance',
    79                   SearchableText="%s*" % term.strip().lower())
    80 elif what == "name":
    81     res = catalog(portal_type=portal_type_query,
    82                   SearchableText="%s*" % term.strip())
     83elif what in st_queries:
     84    if what == "jamb_id":
     85        pt = 'StudentApplication'
     86        st = "%s*" % term.strip().lower()
     87    elif what == "matric_no":
     88        pt = 'StudentClearance'
     89        st = "%s*" % term.strip().lower()
     90    elif what == "name":
     91        pt = portal_type_query
     92        st = "%s*" % term.strip()
     93    try:
     94        res = catalog(portal_type=pt,SearchableText=st,)
     95    except:
     96        return context.students_manager_view(rendered = rend,
     97                             psm = 'Searchstring "%s" not allowed' % term,
     98                             #psm = "%s, %s" % (psm,ds),
     99                             students = items,
     100                             is_manager = is_manager,
     101                             )
     102           
    83103if res:
    84104    for r in res:
    85         row = {}
    86105        if r.portal_type in ("StudentApplication","StudentPersonal"):
    87             items.append(r.getObject().aq_parent)
     106            student = r.getObject().aq_parent
    88107        else:
    89             items.append(r.getObject())
     108            student = r.getObject()
     109        if student not in items:
     110            items.append(student)
    90111students = []
    91112if items:
Note: See TracChangeset for help on using the changeset viewer.