Ignore:
Timestamp:
20 Oct 2006, 13:06:08 (18 years ago)
Author:
joachim
Message:

improved student import,
renamed layout/schema student_course_results to student_course_result

File:
1 edited

Legend:

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

    r680 r727  
    1212return Info about the current Student
    1313"""
    14 #from Products.ZCTextIndex.QueryParser import ParseError,QueryError
     14try:
     15    from Products.AdvancedQuery import Eq, Between, Le
     16    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
     17except:
     18    evalAdvancedQuery = None
     19   
    1520request = context.REQUEST
    1621form = request.form
     
    5358err = False
    5459with_review = state != "all"
     60onlyreview = with_review and not term
     61with_level_results = state.startswith("category") and evalAdvancedQuery is not None
     62bools = "with_review = %s<br\> onlyreview = %s<br\> with_level_results = %s" % (with_review,onlyreview,with_level_results)
    5563if not term and not with_review:
    5664    psm = "You must specify a search string when searching 'all states'."
     
    6674                             is_manager = is_manager,
    6775                             )
    68 with_review = state != "all"
    6976items = []
    7077res = []
    7178portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
    7279st_queries = ('jamb_reg_no','matric_no','name')
    73 onlyreview = with_review and not term
    74 if onlyreview:
    75     res = catalog(portal_type='Student',
    76                   review_state=state)
     80query_step = 0
     81if onlyreview and not with_level_results:
     82    query_step = 1
     83    query =  Eq('portal_type','Student') & Eq('review_state',state)
     84    res = evalAdvancedQuery(query)
     85##    res = catalog(portal_type='Student',
     86##                  review_state=state)
     87elif onlyreview and with_level_results:
     88    query_step = 2
     89    query =  Eq('portal_type','StudentStudyLevel') & Eq('review_state',state)
     90    res = evalAdvancedQuery(query)
    7791elif what == "student_id":
    7892    if with_review:
     93        query_step = 3
    7994        res = catalog(portal_type='Student',
    8095                      id = term.strip(),
    8196                      review_state=state)
    8297    else:
     98        query_step = 4
    8399        res = catalog(portal_type='Student',
    84100                      id = term.strip())
    85 elif what in st_queries:
     101elif what in st_queries and not with_level_results:
    86102    if what == "jamb_reg_no":
     103        query_step = 5
    87104        pt = 'StudentApplication'
    88105        st = "%s*" % term.strip().lower()
    89106    elif what == "matric_no":
     107        query_step = 6
    90108        pt = 'StudentClearance'
    91109        st = "%s*" % term.strip().lower()
    92110    elif what == "name":
     111        query_step = 7
    93112        pt = portal_type_query
    94113        st = "%s*" % term.strip()
     
    102121                             is_manager = is_manager,
    103122                             )
     123elif what in st_queries and with_level_results and evalAdvancedQuery:
     124    if what == "jamb_reg_no":
     125        query_step = 8
     126        pt = 'StudentApplication'
     127        st = "%s*" % term.strip().lower()
     128    elif what == "matric_no":
     129        query_step = 9
     130        pt = 'StudentClearance'
     131        st = "%s*" % term.strip().lower()
     132    elif what == "name":
     133        query_step = 10
     134        pt = portal_type_query
     135        st = "%s*" % term.strip()
     136    query = Eq('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip().lower())\
     137                | Eq('portal_type','StudentStudyLevel') & Eq('review_state',state)
     138    try:
     139        res = evalAdvancedQuery(query)
     140    except:
     141        return context.students_manager_view(rendered = rend,
     142                             psm = 'Advanced Query failed' % term,
     143                             #psm = "%s, %s" % (psm,ds),
     144                             students = items,
     145                             is_manager = is_manager,
     146                             )
    104147students = []
     148raw_res = len(res)
    105149if res:
    106150    for r in res:
    107         if r.portal_type in ("StudentApplication","StudentPersonal"):
     151        if r.portal_type in ("StudentApplication","StudentPersonal",):
    108152            student = r.getObject().aq_parent
     153        elif r.portal_type in ("StudentStudyLevel",):
     154            student = r.getObject().aq_parent.aq_parent
    109155##            pp = '/'.join(r.getPath().split('/')[:-1])
    110156##            student_cat = catalog(pathindex=pp,portal_type='Student')[0]
     
    114160            student = r.getObject()
    115161        student_rs = wf.getInfoFor(student,'review_state','keiner')
    116         if (with_review and student_rs != state) or student in items:
     162        if (with_review and student_rs != state and not with_level_results) or student in items:
    117163            continue
    118164        items.append(student)
     
    126172                             )
    127173return context.students_manager_view(rendered = rend,
    128                              psm = """Your search for "%s" in %s with state %s failed.""" % (st,what,state),
     174                             psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,raw_res,st,what,state,bools),
    129175                             students = students,
    130176                             is_manager = is_manager,
Note: See TracChangeset for help on using the changeset viewer.