Ignore:
Timestamp:
7 Dec 2006, 18:18:28 (18 years ago)
Author:
joachim
Message:

student_search fixed for ClearanceOfficers?
getStudentInfo checks for access to not owned Student-Ids and logs them.
search Pins shows all used PIN's

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

Legend:

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

    r971 r1006  
    2020path_info = request.get('PATH_INFO').split('/')
    2121
     22import logging
     23logger = logging.getLogger('getStudentInfo')
     24
    2225info = {}
    2326member_id = str(member)
     27#from Products.zdb import set_trace
     28#set_trace()
     29student_id = None
    2430if student is None:
    25     if mtool.isAnonymousUser():
    26         return None
    27     elif not context.isStudent() and 'students' in path_info:
    28         student_id = path_info[path_info.index('students')+1]
    29     else:
     31    while True:
     32        if mtool.isAnonymousUser():
     33            return None
     34        try:
     35            requested_id = path_info[path_info.index('students')+1]
     36        except ValueError:
     37            student_id = member_id
     38            break
     39        if not context.isStudent() and 'students' in path_info:
     40            student_id = requested_id
     41            break
     42        if member_id != requested_id:
     43            logger.info("Student %s tried to access %s" % (member_id,requested_id))
     44            student_id = member_id
     45            #mtool.assertViewable(context)
     46            break
    3047        student_id = member_id
     48        break
    3149else:
    3250    student_id = student.getId()
     51
    3352roles = member.getRoles()
    3453student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
    3554student = context.restrictedTraverse(student_path,default=None)
    36 #from Products.zdb import set_trace
    37 #set_trace()
    3855
    39 if student is None or student.portal_type != 'Student':
     56if student is None or student.portal_type != "Student":
    4057    return None
    4158##res = context.portal_catalog(id = student_id,portal_type='Student')
  • WAeUP_SRP/trunk/skins/waeup_student/search_students.py

    r1000 r1006  
    4949path_info = request.get('PATH_INFO').split('/')
    5050validate = request.has_key("cpsdocument_edit_button")
     51
     52state = "all"
     53if "ClearanceOfficers" in member.getGroups():
     54    state = "clearance_requested"
    5155default = {'search_mode': 'name',
    52         'review_state': 'all',
     56        'review_state': state,
    5357        'search_string': ''
    5458        }
     
    152156if items:
    153157    for item in items:
    154         #if context.isClearanceOfficer(info):
     158        stcat = context.students_catalog
     159        record = stcat(id = item)[0]
    155160        info = {}
     161        for field in stcat.schema() + stcat.indexes():
     162            info[field] = getattr(record, field)
    156163        if "ClearanceOfficers" in member.getGroups():
    157164            co_view = True
    158 ##            droles = member.getRolesInContext(item)
    159 ##            if "ClearanceOfficer" in droles:
    160 ##                info = context.getStudentInfo(item)
    161 ##                students.append(info)
     165            res = context.portal_catalog(portal_type='Student', id = item)
     166            if len(res) != 1:
     167                continue
     168            droles = member.getRolesInContext(res[0].getObject())
     169            info['review_state'] = res[0].review_state
     170            if "ClearanceOfficer" in droles:
     171                students.append(info)
    162172        else:
    163             #info = context.getStudentInfo(item)
    164             info = context.students_catalog(id = item)
    165173            if len(info) == 1:
    166                 students.append(info[0])
     174                students.append(info)
    167175
    168176    return context.search_students_form(rendered = rend,
    169177                             psm = "",
    170                              #psm = "%d,%d matching Students found QS = %s" %\
    171                              #       (len(review_set),len(search_set),query_step),
    172                              #psm = "%d found QS = %s items: %s" % (len(items),query_step,items),
    173178                             students = students,
    174179                             allowed = True,
     
    177182return context.search_students_form(rendered = rend,
    178183                             psm = "No student found!",
    179                              #psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,len(items),st,what,state,bools),
    180184                             students = students,
    181185                             allowed = True,
  • WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt

    r971 r1006  
    6363                <td tal:condition="options/co_view|nothing">
    6464                       <a href="id"
    65                           tal:attributes="href string:${student/student/clearance/absolute_url}/external_clearance_edit_form"
     65                          tal:attributes="href string:${context/portal_url}/campus/students/${student/id}/clearance/external_clearance_edit_form"
    6666                          target="edit"
    6767                          onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
Note: See TracChangeset for help on using the changeset viewer.