Changeset 750


Ignore:
Timestamp:
25 Oct 2006, 11:36:12 (18 years ago)
Author:
joachim
Message:

searchStudents now supports new review_states, not yet fully tested

Location:
WAeUP_SRP/trunk/skins/waeup_student
Files:
3 edited

Legend:

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

    r748 r750  
    8888        row['s_edit_link'] = "%s/%s" % (student.absolute_url(),se_link)
    8989    row['review_state'] = so.review_state
    90     row['display'] = so.review_state in ('opened','closed',) or so.portal_type == "StudentAccommodation"
     90    row['display'] = so.review_state in ('opened','closed',) or\
     91                     so.portal_type in ("StudentAccommodation","StudentStudyCourse")
    9192    items.append(row)
    9293info['items'] = items
  • WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py

    r731 r750  
    1313"""
    1414try:
    15     from Products.AdvancedQuery import Eq, Between, Le
     15    from Products.AdvancedQuery import Eq, Between, Le,In
    1616    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
    1717except:
     
    2121form = request.form
    2222fget = form.get
     23student_subobjects = ("StudentApplication",
     24                      "StudentPersonal",
     25                      "StudentStudyCourse",
     26                      "StudentAccommodation",
     27                      "StudentStudyLevel",)
    2328info = {}
     29items = []
    2430wf = context.portal_workflow
    2531catalog = context.portal_catalog
     
    3238is_manager = context.isManager
    3339validate = request.has_key("cpsdocument_edit_button")
    34 items = []
    3540default = {'search_mode': 'name',
    3641        'review_state': 'all',
     
    5964with_review = state != "all"
    6065onlyreview = with_review and not term
    61 with_level_results = state.startswith("category") or\
    62                      state in ('content_addable',) and\
    63                      evalAdvancedQuery is not None
    64 bools = "with_review = %s<br\> onlyreview = %s<br\> with_level_results = %s" % (with_review,onlyreview,with_level_results)
     66##with_level_results = state.startswith("category") or\
     67##                     state in ('content_addable',) and\
     68##                     evalAdvancedQuery is not None
     69bools = "with_review = %s<br\> onlyreview = %s<br\>" % (with_review,onlyreview)
    6570if not term and not with_review:
    6671    psm = "You must specify a search string when searching 'all states'."
     
    8186st_queries = ('jamb_reg_no','matric_no','name')
    8287query_step = 0
    83 if onlyreview and not with_level_results:
     88review_query = None
     89if onlyreview:
    8490    query_step = 1
    85     query =  Eq('portal_type','Student') & Eq('review_state',state)
    86     res = evalAdvancedQuery(query)
    87 ##    res = catalog(portal_type='Student',
    88 ##                  review_state=state)
    89 elif onlyreview and with_level_results:
    90     query_step = 2
    91     query =  (Eq('portal_type','StudentStudyLevel') |
    92              Eq('portal_type','StudentStudyCourse')) & Eq('review_state',state)
    93     res = evalAdvancedQuery(query)
     91    query =   In('portal_type',student_subobjects) & Eq('review_state',state)
     92    #res = evalAdvancedQuery(query)
    9493elif what == "student_id":
    9594    if with_review:
     
    102101        res = catalog(portal_type='Student',
    103102                      id = term.strip())
    104 elif what in st_queries and not with_level_results:
     103elif what in st_queries:
    105104    if what == "jamb_reg_no":
    106105        query_step = 5
    107         pt = 'StudentApplication'
     106        pt = ('StudentApplication',)
    108107        st = "%s*" % term.strip().lower()
    109108    elif what == "matric_no":
    110109        query_step = 6
    111         pt = 'StudentClearance'
     110        pt = ('StudentClearance',)
    112111        st = "%s*" % term.strip().lower()
    113112    elif what == "name":
     
    115114        pt = portal_type_query
    116115        st = "%s*" % term.strip()
    117     try:
    118         res = catalog(portal_type=pt,SearchableText=st)
    119     except:
    120         return context.students_manager_view(rendered = rend,
    121                              psm = 'Search string "%s" not allowed.' % term,
    122                              #psm = "%s, %s" % (psm,ds),
    123                              students = items,
    124                              is_manager = is_manager,
    125                              )
    126 elif what in st_queries and with_level_results and evalAdvancedQuery:
    127     if what == "jamb_reg_no":
    128         query_step = 8
    129         pt = 'StudentApplication'
    130         st = "%s*" % term.strip().lower()
    131     elif what == "matric_no":
    132         query_step = 9
    133         pt = 'StudentClearance'
    134         st = "%s*" % term.strip().lower()
    135     elif what == "name":
    136         query_step = 10
    137         pt = portal_type_query
    138         st = "%s*" % term.strip()
    139     query = Eq('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip().lower())\
    140                 | ((Eq('portal_type','StudentStudyLevel') |
    141                    Eq('portal_type','StudentStudyCourse')) & Eq('review_state',state))
    142     try:
    143         res = evalAdvancedQuery(query)
    144     except:
    145         return context.students_manager_view(rendered = rend,
    146                              psm = 'Advanced Query failed' % term,
    147                              #psm = "%s, %s" % (psm,ds),
    148                              students = items,
    149                              is_manager = is_manager,
    150                              )
     116    if with_review:
     117        review_query = In('portal_type',student_subobjects) & Eq('review_state',state)
     118    query = (In('portal_type',pt) & Eq('SearchableText',st))
     119##    try:
     120##        res = catalog(portal_type=pt,SearchableText=st)
     121##    except:
     122##        return context.students_manager_view(rendered = rend,
     123##                             psm = 'Search string "%s" not allowed.' % term,
     124##                             #psm = "%s, %s" % (psm,ds),
     125##                             students = items,
     126##                             is_manager = is_manager,
     127##                             )
     128##elif what in st_queries and with_level_results and evalAdvancedQuery:
     129##    if what == "jamb_reg_no":
     130##        query_step = 8
     131##        pt = 'StudentApplication'
     132##        st = "%s*" % term.strip().lower()
     133##    elif what == "matric_no":
     134##        query_step = 9
     135##        pt = 'StudentClearance'
     136##        st = "%s*" % term.strip().lower()
     137##    elif what == "name":
     138##        query_step = 10
     139##        pt = portal_type_query
     140##        st = "%s*" % term.strip()
     141##    query = Eq('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip().lower())\
     142##                | ((Eq('portal_type','StudentStudyLevel') |
     143##                   Eq('portal_type','StudentStudyCourse')) & Eq('review_state',state))
     144if review_query:
     145    res = evalAdvancedQuery(query | review_query)
     146else:
     147    res = evalAdvancedQuery(query)
     148##try:
     149##    if review_query:
     150##        res = evalAdvancedQuery(query) & evalAdvancedQuery(review_query)
     151##    else:
     152##        res = evalAdvancedQuery(query)
     153##except:
     154##    return context.students_manager_view(rendered = rend,
     155##                         psm = 'Advanced Query failed' % term,
     156##                         #psm = "%s, %s" % (psm,ds),
     157##                         students = items,
     158##                         is_manager = is_manager,
     159##                         )
    151160students = []
    152161raw_res = len(res)
     162all = []
    153163if res:
    154164    for r in res:
    155         if r.portal_type in ("StudentApplication","StudentPersonal","StudentStudyCourse",):
     165        if r.portal_type in ("StudentStudyLevel",):
     166            student = r.getObject().aq_parent.aq_parent
     167        elif r.portal_type in student_subobjects:
    156168            student = r.getObject().aq_parent
    157         elif r.portal_type in ("StudentStudyLevel",):
    158             student = r.getObject().aq_parent.aq_parent
    159 ##            pp = '/'.join(r.getPath().split('/')[:-1])
    160 ##            student_cat = catalog(pathindex=pp,portal_type='Student')[0]
    161 ##            student_rs = student_cat.review_state
    162 ##            student = student_cat.getObject()
    163169        else:
    164170            student = r.getObject()
    165         student_rs = wf.getInfoFor(student,'review_state','keiner')
    166         if (with_review and student_rs != state and not with_level_results) or student in items:
     171        if student in all:
     172            items.append(student)
    167173            continue
    168         items.append(student)
     174        all.append(student)
     175if onlyreview:
     176    items = all
    169177if items:
    170178    for item in items:
    171         students.append(context.getStudentInfo(item))
     179        info = context.getStudentInfo(item)
     180        students.append(info)
    172181    return context.students_manager_view(rendered = rend,
    173182                             psm = "%d matching Students found QS = %s" % (len(items),query_step),
     183                             #psm = "%d found QS = %s items: %s" % (len(items),query_step,items),
    174184                             students = students,
    175185                             is_manager = is_manager,
  • WAeUP_SRP/trunk/skins/waeup_student/students_manager_view.pt

    r603 r750  
    5252        <table class="contentListing" width="100%">
    5353          <span tal:repeat="rows batches" tal:omit-tag="">
    54             <tr tal:repeat="student rows"
    55                 tal:attributes="class python:test(repeat['student'].even(), 'even ajaxtd', 'odd ajaxtd')">
    56               <td><a href="id" tal:attributes="href string:${student/student/absolute_url}"
    57                      tal:content="student/id"></a></td>   
    58               <td>
    59                 <span tal:replace="python: student['per_doc'].firstname" />
    60                 <span tal:replace="python: student['per_doc'].middlename" />
    61                 <span tal:replace="python: student['per_doc'].lastname" />
    62               </td>   
    63               <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td>   
    64               <td><span tal:replace="student/review_state" /></td>   
    65             </tr>
     54            <span tal:repeat="student rows">
     55              <tr tal:condition="student"
     56                  tal:attributes="class python:test(repeat['student'].even(), 'even ajaxtd', 'odd ajaxtd')">
     57                <td><a href="id" tal:attributes="href string:${student/student/absolute_url}"
     58                       tal:content="student/id"></a></td>   
     59                <td>
     60                  <span tal:replace="python: student['per_doc'].firstname" />
     61                  <span tal:replace="python: student['per_doc'].middlename" />
     62                  <span tal:replace="python: student['per_doc'].lastname" />
     63                </td>   
     64                <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td>   
     65                <td><span tal:replace="student/review_state" /></td>   
     66              </tr>
     67            </span>
    6668          </span>
    6769        </table>
Note: See TracChangeset for help on using the changeset viewer.