Ignore:
Timestamp:
19 Mar 2007, 21:45:44 (18 years ago)
Author:
joachim
Message:

merged changes from trunk to joachim-event-branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/branches/joachim-event-branch/PatchCPSUserFolderUserFolder.py

    r1558 r1596  
    7171    ## patch to assign dynamic roles for WAeUP
    7272    while 1:
     73        if self.isStudent():
     74            break
     75        groups = self.portal_membership.getAuthenticatedMember().getGroups()
     76        if not ("ClearanceOfficers" in groups or "CourseAdvisers" in groups):
     77            break
    7378        if callable(real_object) and hasattr(real_object,'im_self'):
    7479            real_object = real_object.im_self
    7580
     81        if real_object is None:
     82            break
    7683        if hasattr(real_object,'portal_type') and\
    77                    real_object.portal_type not in ("Student","StudentClearance","StudentStudyLevel"):
     84                   real_object.portal_type not in ("Student",
     85                                                   "StudentClearance",
     86                                                   "StudentStudyLevel"):
    7887            break
    79 
    80         #from pdb import set_trace;set_trace()
     88        # don't test if it is not a proxy
     89        if real_object.portal_type == real_object.meta_type:
     90            break
    8191        # can be later simplified by replacing by students_catalog values - Henrik
    8292        # getattr works always because of acquisition ?! Henrik
     
    8494        if sc is None:
    8595            break
     96        #from pdb import set_trace;set_trace()
    8697        sc_obj = sc.getContent()
    8798        cert_id = sc_obj.study_course
     
    110121                                                )
    111122        if real_object.portal_type == "StudentStudyLevel":
    112             context_obj = getattr(certificate_obj,real_object.getId())
    113             allowed = ('CourseAdviser', 'SectionManager')
     123            context_obj = getattr(certificate_obj,real_object.getId(),None)
     124            if context_obj is None:
     125                break
     126            allowed = set(('CourseAdviser', 'SectionManager'))
     127        elif real_object.portal_type == "Student" and "CourseAdvisers" in groups:
     128            #we need some special processing since CourseAdvisers are only
     129            #specified per StudyLevel
     130            allowed = set(('CourseAdviser', 'SectionManager'))
     131            for context_obj in certificate_obj.objectValues():
     132                dynamic_roles = set(self.getRolesInContext(context_obj))
     133                intersect = dynamic_roles & allowed
     134                if intersect:
     135                    roles.extend(list(intersect))
     136            break
    114137        else:
    115138            res = self.portal_catalog(portal_type="Department",id=dep_id)
    116             allowed = ('ClearanceOfficer', 'SectionManager')
     139            allowed = set(('ClearanceOfficer', 'SectionManager'))
    117140            if len(res) != 1:
    118141                break
    119142            context_obj = res[0].getObject()
    120         dynamic_roles = self.getRolesInContext(context_obj)
    121         for dr in allowed:
    122             if dr in dynamic_roles:
    123                 roles.append(dr)
     143        dynamic_roles = set(self.getRolesInContext(context_obj))
     144        intersect = dynamic_roles & allowed
     145        if intersect:
     146            roles.extend(list(intersect))
    124147        break
    125148    return roles
Note: See TracChangeset for help on using the changeset viewer.