Ignore:
Timestamp:
29 Sep 2006, 14:14:40 (18 years ago)
Author:
joachim
Message:

student search should work now as follows:

if All States is selected a search string must be specified.
if another review state is specified, the searchstring can be empty.
if it is not empty, both are ANDed.

File:
1 edited

Legend:

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

    r589 r596  
    5454state = ds.get('review_state')
    5555term = ds.get('search_string')
    56 if state == " ----- ":
    57     state = ''
    5856err = False
    5957if not term and what in ('student_edit','jamb_id','name','matric_no'):
    60     psm = "You must specify a search string"
     58    psm = "You must specify a search string when searching in 'All States'"
    6159    err = True
    6260elif '*' in term:
    63     psm = "You cannot use '*'"
     61    psm = "you cannot use the '*' alone"
    6462    err = True
    6563if err:
     
    7068                             is_manager = is_manager,
    7169                             )
    72 onlyreview = state and what == "review_state"
     70with_review = state != "all"
    7371items = []
    7472res = []
    7573portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
    7674st_queries = ('jamb_id','matric_no','name')
     75onlyreview = with_review and not what
    7776if onlyreview:
    7877    res = catalog(portal_type=portal_type_query,
    7978                  review_state=state)
    8079elif what == "student_id":
    81     res = catalog(portal_type='Student',
    82                   id = term.strip())
     80    if with_review:
     81        res = catalog(portal_type='Student',
     82                      id = term.strip(),
     83                      review_state=state)
     84    else:
     85        res = catalog(portal_type='Student',
     86                      id = term.strip())
    8387elif what in st_queries:
    8488    if what == "jamb_id":
     
    9195        pt = portal_type_query
    9296        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                              )
     97    if with_review:
     98        try:
     99            res = catalog(portal_type=pt,SearchableText=st,
     100                          review_state=state)
     101        except:
     102            return context.students_manager_view(rendered = rend,
     103                                 psm = 'Searchstring "%s" not allowed' % term,
     104                                 #psm = "%s, %s" % (psm,ds),
     105                                 students = items,
     106                                 is_manager = is_manager,
     107                                 )
     108    else:
     109        try:
     110            res = catalog(portal_type=pt,SearchableText=st,)
     111        except:
     112            return context.students_manager_view(rendered = rend,
     113                                 psm = 'Searchstring "%s" not allowed' % term,
     114                                 #psm = "%s, %s" % (psm,ds),
     115                                 students = items,
     116                                 is_manager = is_manager,
     117                                 )
    102118           
    103119if res:
Note: See TracChangeset for help on using the changeset viewer.