Ignore:
Timestamp:
15 Dec 2006, 13:42:56 (18 years ago)
Author:
joachim
Message:

improved search, modify studycourse, patchfor attribute error

File:
1 edited

Legend:

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

    r1056 r1065  
    1515form = request.form
    1616fget = form.get
    17 wftool = context.portal_workflow
     17#wftool = context.portal_workflow
    1818mtool = context.portal_membership
    1919member = mtool.getAuthenticatedMember()
    20 roles = member.getRolesInContext(context)
    21 students_folder = context.portal_url.getPortalObject().campus.students
     20#roles = member.getRolesInContext(context)
     21lt = context.portal_layouts
     22#pr = context.portal_registration
     23path_info = request.get('PATH_INFO').split('/')
    2224try:
    2325    from Products.AdvancedQuery import Eq, Between, Le,In
    2426    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
     27    aq_students = context.students_catalog.evalAdvancedQuery
    2528except:
    2629    evalAdvancedQuery = None
     
    3740                      "StudentStudyLevel",)
    3841
    39 student_objects = student_subobjects + ("Student",)
    40 
    41 info = {}
     42#student_objects = student_subobjects + ("Student",)
     43student_objects = ("Student",)
     44
     45user_info = {}
    4246items = []
    43 wf = context.portal_workflow
    44 #student_wf_states = wf.waeup_student_wf.states.keys()
    45 #info['wf_states'] = student_wf_states
    46 #info['wf_states'][0] = " ----- "
    47 lt = context.portal_layouts
    48 pr = context.portal_registration
    49 path_info = request.get('PATH_INFO').split('/')
    5047validate = request.has_key("cpsdocument_edit_button")
    5148
    5249state = "all"
     50user_info['member'] = str(member)
     51user_info['departments'] = []
     52user_info['faculties'] = []
     53#from Products.zdb import set_trace
     54#set_trace()
     55co_view = False
    5356if "ClearanceOfficers" in member.getGroups():
    5457    state = "clearance_requested"
     58    only_review = False
     59    co_view = True
     60    query = In('portal_type',('Faculty',)) &\
     61             In('localUsersWithRoles', ("user:%s" % member,))
     62    res = evalAdvancedQuery(query)
     63    faculties = []
     64    if res:
     65        faculties = [f.getId for f in res]
     66    user_info['faculties'] = faculties
     67    query = In('portal_type',('Department',)) &\
     68             In('localUsersWithRoles', ("user:%s" % member,))
     69    res = evalAdvancedQuery(query)
     70    departments = []
     71    if res:
     72        departments = [f.getId for f in res]
     73    user_info['departments'] = departments
    5574default = {'search_mode': 'name',
    5675        'review_state': state,
     
    7089                             psm = psm,
    7190                             #psm = "%s, %s" % (psm,ds),
     91                             info = user_info,
    7292                             students = [],
    7393                             allowed = True,
     
    90110                             psm = psm,
    91111                             #psm = "%s, %s" % (psm,ds),
     112                             info = user_info,
    92113                             students = items,
    93114                             allowed = True,
     
    104125if len(term) > 0:
    105126    if what == "student_id":
     127        students_folder = context.portal_url.getPortalObject().campus.students
    106128        query_step = 1
    107129        if hasattr(students_folder,term.strip()):
     
    135157                pl = r.getPath().split('/')
    136158                search_set.append(pl[pl.index('students') + 1])
     159elif co_view:
     160    #from Products.zdb import set_trace
     161    #set_trace()
     162    only_review = False
     163    query = In('faculty',faculties) | In('department',departments)
     164    res = aq_students(query)
     165    search_set = [r.id for r in res]
     166##        res = context.students_catalog(faculty=faculties[0],)
     167##        res = context.students_catalog(faculty=faculties,department=departments)
     168#set_trace()
    137169if with_review:
    138170    query_step += 10
    139     review_res = evalAdvancedQuery(In('portal_type',student_objects) & Eq('review_state',state))
     171    #review_res = evalAdvancedQuery(('portal_type',student_objects) & Eq('review_state',state))
     172    review_res = evalAdvancedQuery(Eq('review_state',state))
    140173review_set = []
    141174if review_res:
    142175    for r in review_res:
    143         pl = r.getPath().split('/')
    144         review_set.append(pl[pl.index('students') + 1])
     176        #pl = r.getPath().split('/')
     177        #review_set.append(pl[pl.index('students') + 1])
     178        review_set.append(r.getId)
    145179all = []
     180#set_trace()
    146181if only_review:
    147182    all = review_set
     
    152187else:
    153188    all = search_set
    154 for a in all[:500]:
    155     if a in items:
    156         continue
    157     items.append(a)
     189##for a in all[:50]:
     190##    if a in items:
     191##        continue
     192##    items.append(a)
     193items = all[:500]
    158194students = []
    159 items.sort()
    160 co_view = False
     195#items.sort()
     196
    161197if items:
    162198    for item in items:
     
    166202        for field in stcat.schema() + stcat.indexes():
    167203            info[field] = getattr(record, field)
    168         if "ClearanceOfficers" in member.getGroups():
    169             co_view = True
    170             res = context.portal_catalog(portal_type='Student', id = item)
    171             if len(res) != 1:
    172                 continue
    173             droles = member.getRolesInContext(res[0].getObject())
    174             info['review_state'] = res[0].review_state
    175             if "ClearanceOfficer" in droles:
    176                 students.append(info)
     204##        if "ClearanceOfficers" in member.getGroups():
     205##            co_view = True
     206##            res = context.portal_catalog(portal_type='Student', id = item)
     207##            if len(res) != 1:
     208##                continue
     209##            droles = member.getRolesInContext(res[0].getObject())
     210##            info['review_state'] = res[0].review_state
     211##            if "ClearanceOfficer" in droles:
     212##                students.append(info)
    177213        else:
    178214            students.append(info)
     
    180216    return context.search_students_form(rendered = rend,
    181217                             psm = "",
     218                             info = user_info,
    182219                             students = students,
    183220                             allowed = True,
     
    186223return context.search_students_form(rendered = rend,
    187224                             psm = "No student found!",
     225                             info = user_info,
    188226                             students = students,
    189227                             allowed = True,
Note: See TracChangeset for help on using the changeset viewer.