Changeset 1006 for WAeUP_SRP/trunk/skins


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
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py

    r1004 r1006  
    4848member = mtool.getAuthenticatedMember()
    4949
    50 if not is_anon:
    51     if "Student" in member.getRoles():
    52         to_waeup_student_home = True
    53         students = context.portal_url.getPortalObject().campus.students
    54         student = getattr(students,str(member))
    55         student_app = getattr(student,'application')
    56         student_pume = getattr(student,'pume',None)
    57         s_review_state = wftool.getInfoFor(student,'review_state',None)
    58         a_review_state = wftool.getInfoFor(student_app,'review_state',None)
    59         logger.info('%s review_state %s' % (member,s_review_state))
    60         app_doc = student_app.getContent()
    61         #from Products.zdb import set_trace
    62         #set_trace()
    63         if s_review_state in ("student_created","admitted") and\
    64         a_review_state == 'created' :
    65             wftool.doActionFor(student_app,'open')
    66             if student_pume is not None:
    67               wftool.doActionFor(student_pume,'close')
    68             da = {}
    69             pin = request.get('pin')
    70             if not pin:
     50if redirect_url.endswith('/logged_out'):
     51    redirect_to_portal = True   
     52else:
     53    if not is_anon:
     54        if "Student" in member.getRoles():
     55            to_waeup_student_home = True
     56            students = context.portal_url.getPortalObject().campus.students
     57            student = getattr(students,str(member))
     58            student_app = getattr(student,'application')
     59            student_pume = getattr(student,'pume',None)
     60            s_review_state = wftool.getInfoFor(student,'review_state',None)
     61            a_review_state = wftool.getInfoFor(student_app,'review_state',None)
     62            logger.info('%s review_state %s' % (member,s_review_state))
     63            app_doc = student_app.getContent()
     64            #from Products.zdb import set_trace
     65            #set_trace()
     66            if s_review_state in ("student_created","admitted") and\
     67            a_review_state == 'created' :
     68                wftool.doActionFor(student_app,'open')
     69                if student_pume is not None:
     70                  wftool.doActionFor(student_pume,'close')
     71                da = {}
     72                pin = request.get('pin')
     73                if not pin:
     74                    jamb_reg_no = app_doc.jamb_reg_no
     75                    for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
     76                        res = context.portal_pins(student=reg_no)
     77                        if len(res) > 0:
     78                            break
     79                    if len(res) > 0:
     80                        p = res[0].pin
     81                        if len(p) > 10:
     82                            pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
     83                        else:
     84                            pin = p
     85                da['app_ac_pin'] = pin
     86                da['app_ac_date'] = current
     87                app_doc.edit(mapping = da)
     88            elif s_review_state in ("admitted") and a_review_state == 'opened' and\
     89            not app_doc.app_ac_pin:
    7190                jamb_reg_no = app_doc.jamb_reg_no
    7291                for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
     
    8099                    else:
    81100                        pin = p
    82             da['app_ac_pin'] = pin
    83             da['app_ac_date'] = current
    84             app_doc.edit(mapping = da)
    85         elif s_review_state in ("admitted") and a_review_state == 'opened' and\
    86         not app_doc.app_ac_pin:
    87             jamb_reg_no = app_doc.jamb_reg_no
    88             for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
    89                 res = context.portal_pins(student=reg_no)
    90                 if len(res) > 0:
    91                     break
    92             if len(res) > 0:
    93                 p = res[0].pin
    94                 if len(p) > 10:
    95                     pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
    96                 else:
    97                     pin = p
    98                 da = {}
    99                 da['app_ac_pin'] = pin
    100                 app_doc.edit(mapping = da)
    101     elif "Manager" in member.getRoles():
    102         pass
    103     else:
    104         to_member_home, to_workspaces = checkRedirect(portal, mtool)
     101                    da = {}
     102                    da['app_ac_pin'] = pin
     103                    app_doc.edit(mapping = da)
     104        elif "Manager" in member.getRoles():
     105            pass
     106        else:
     107            to_member_home, to_workspaces = checkRedirect(portal, mtool)
    105108if (not to_member_home) and (not to_workspaces):
    106109    redirect_to_portal = True
  • WAeUP_SRP/trunk/skins/waeup_custom/standard_error_message.pt

    r535 r1006  
    88                        p_props here/portal_properties;
    99                       ">
     10<tal:Anauthorized condition="python:error_type == 'Unauthorized'">
     11    <metal:block use-macro="here/error_not_found/macros/not_found" />
     12</tal:Anauthorized>
     13
     14<tal:Anauthorized condition="python:error_type != 'Unauthorized'">
    1015<metal:body use-macro="here/main_template/macros/master">
    1116
     
    5358</metal:main>
    5459</metal:body>
     60</tal:Anauthorized>
    5561</metal:html>
  • WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py

    r1002 r1006  
    1212list Students for ClearanceOfficers
    1313"""
     14
    1415request = REQUEST
    1516wftool = context.portal_workflow
     
    4748
    4849if what == 'student':
    49     items_2 = context.portal_pins(student = term)
    5050    items_1 = context.portal_pins(student = term.upper())
     51    items_2 = context.portal_pins(student = term.lower())
    5152    items = items_1 + items_2
    5253elif what == 'pin':
     
    5556    items = []
    5657l = []
     58students_url = "%s/%s" % (context.portal_url(),'students')
     59pins = []
    5760for i in items:
    5861    item = {}
     
    6164    item['serial'] = i.serial
    6265    item['pin'] = i.pin
     66    if i.pin in pins:
     67        continue
     68    pins.append(i.pins)
    6369    if len(sno)==10:
    64     #if bd.prefix == "APP":
    6570        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
    6671        res = context.students_catalog(jamb_reg_no=sno.upper())
    6772        if len(res) > 0:
    68             item['student_url'] = "%s/%s" % (context.portal_url(),res[0].id)
     73            item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
    6974            item['student_id'] = res[0].id
    7075        else:
    7176            item['student_url'] = None
    7277            item['student_id'] = ''
     78    elif sno:
     79        item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
     80        item['student_id'] = student
    7381    else:
    74         item['student_url'] = '%s/%s' % (students_url,item['student'])
    75         item['student_id'] = student
     82        item['student_url'] = ''
     83        item['student_id'] = "not used"
    7684    l.append(item)
    7785   
  • 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.