Changeset 3066 for WAeUP_SRP/base/skins


Ignore:
Timestamp:
30 Jan 2008, 14:59:03 (17 years ago)
Author:
joachim
Message:

store faculties, departments and certificate_levels in SESSION for
ClearanceOfficers? and CourseAdvisers?

File:
1 edited

Legend:

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

    r3024 r3066  
    5858co_view = False
    5959ca_view = False
    60 faculties =  fget('faculties')
    61 departments = fget('departments')
    62 certificate_levels = fget('certificate_levels')
    63 dep_str = fac_str = certificate_levels_str = ''
    64 
     60session_data = request.SESSION
     61faculties =  session_data.get('faculties',None)
     62departments = session_data.get('departments',None)
     63certificate_levels = session_data.get('certificate_levels',None)
    6564# determine local roles
    66 
    6765if "ClearanceOfficers" in member.getGroups():
    6866    default_state = "clearance_requested"
    6967    co_view = True
    70     if faculties or departments:
    71         #from Products.zdb import set_trace;set_trace()
    72         if faculties:
    73             fac_str = faculties
    74             faculties = faculties.split()
    75         if departments:
    76             dep_str = departments
    77             departments = departments.split()
    78     else:
    79         query = In('portal_type',('Faculty',)) &\
     68    if faculties is None or departments is None:
     69        logger.info('ClearanceOfficer %s initiated student_search' % member)
     70        query = In('portal_type',('Faculty','Department')) &\
    8071                 In('localUsersWithRoles', ("user:%s" % member,))
    8172        res = aq_portal(query)
    82         logger.info('ClearanceOfficer %s initiated student_search' % member)
    83         faculties = []
    84         if res:
    85             faculties = [f.getId for f in res]
    86         user_info['faculties'] = faculties
    87         fac_str = " ".join(faculties)
    88         query = In('portal_type',('Department',)) &\
    89                  In('localUsersWithRoles', ("user:%s" % member,))
    90         res = aq_portal(query)
    91         departments = []
    92         if res:
    93             departments = [f.getId for f in res]
    94         user_info['departments'] = departments
    95         dep_str = " ".join(departments)
     73        faculties = [f.getId for f in res if f.portal_type == 'Faculty']
     74        departments = [f.getId for f in res if f.portal_type == 'Department']
     75    user_info['faculties'] = session_data['faculties'] = faculties
     76    user_info['departments'] = session_data['departments'] =  departments
    9677elif "CourseAdvisers" in member.getGroups():
    9778    default_state = "courses_registered"
    9879    ca_view = True
    99     if certificate_levels:
    100         certificate_levels_str = certificate_levels
    101         certificate_levels = certificate_levels.split()
    102     else:
     80    if certificate_levels is None:
     81        logger.info('CourseAdviser %s initiated student_search' % member)
    10382        query = In('portal_type',('StudyLevel',)) &\
    10483                 In('localUsersWithRoles', ("user:%s" % member,))
    10584        res = aq_portal(query)
    106         logger.info('CourseAdviser %s initiated student_search' % member)
    107         certificate_levels = []
    108         if res:
    109             certificate_levels = ['/'.join(f.getPath().split('/')[-2:]) for f in res]
    110             cert_ids = []
    111             level_ids = []
    112             for cl in certificate_levels:
    113                 c,l = cl.split('/')
    114                 level_ids += l,
    115                 if c not in cert_ids:
    116                     cert_ids += c,
    117             cert_brains = aq_portal(In("id",cert_ids))
    118             end_levels = {}
    119             for cert_brain in cert_brains:
    120                 end_levels[cert_brain.getId] = cert_brain.getObject().getContent().end_level
    121             for cl in certificate_levels[:]:
    122                 c,l = cl.split('/')
    123                 for prob in (10,20):
    124                     certificate_levels += "%s/%s" % (c,int(l) + prob),
    125                 if l == end_levels[c]:
    126                     certificate_levels += "%s/%s" % (c,int(l) + 100),
    127         user_info['certificate_levels'] = certificate_levels
    128         certificate_levels_str = " ".join(certificate_levels)
     85        certificate_levels = ['/'.join(f.getPath().split('/')[-2:]) for f in res]
     86        cert_ids = []
     87        level_ids = []
     88        for cl in certificate_levels:
     89            c,l = cl.split('/')
     90            level_ids += l,
     91            if c not in cert_ids:
     92                cert_ids += c,
     93        cert_brains = aq_portal(In("id",cert_ids))
     94        end_levels = {}
     95        for cert_brain in cert_brains:
     96            end_levels[cert_brain.getId] = cert_brain.getObject().getContent().end_level
     97        for cl in certificate_levels[:]:
     98            c,l = cl.split('/')
     99            for prob in (10,20):
     100                certificate_levels += "%s/%s" % (c,int(l) + prob),
     101            if l == end_levels[c]:
     102                certificate_levels += "%s/%s" % (c,int(l) + 100),
     103    user_info['certificate_levels'] = session_data['certificate_levels'] = certificate_levels
    129104
    130105default = {'search_mode': 'student_id',
     
    139114                      layout_mode='edit',
    140115                      formaction="search_students",
    141                       faculties = fac_str,
    142                       departments = dep_str,
    143                       certificate_levels = certificate_levels_str,
    144116                      commit = False,
    145117                      )
Note: See TracChangeset for help on using the changeset viewer.