Ignore:
Timestamp:
19 Mar 2007, 10:06:30 (18 years ago)
Author:
joachim
Message:

set role CourseAdviser? also for the Student object, if the member is
CourseAdviser? for one of the StudyLevels? in the Students study_course.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/PatchCPSUserFolderUserFolder.py

    r1578 r1581  
    7171    ## patch to assign dynamic roles for WAeUP
    7272    while 1:
    73         #from pdb import set_trace;set_trace()
    7473        if self.isStudent():
    7574            break
     
    8786                                                   "StudentStudyLevel"):
    8887            break
    89 
     88        # don't test if it is not a proxy
     89        if real_object.portal_type == real_object.meta_type:
     90            break
    9091        # can be later simplified by replacing by students_catalog values - Henrik
    9192        # getattr works always because of acquisition ?! Henrik
     
    9394        if sc is None:
    9495            break
     96        #from pdb import set_trace;set_trace()
    9597        sc_obj = sc.getContent()
    9698        cert_id = sc_obj.study_course
     
    119121                                                )
    120122        if real_object.portal_type == "StudentStudyLevel":
    121             if real_object.meta_type == "StudentStudyLevel":
    122                 #if it is not a Proxy
    123                 break
    124123            context_obj = getattr(certificate_obj,real_object.getId(),None)
    125124            if context_obj is None:
    126125                break
    127             allowed = ('CourseAdviser', 'SectionManager')
     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
    128137        else:
    129138            res = self.portal_catalog(portal_type="Department",id=dep_id)
    130             allowed = ('ClearanceOfficer', 'SectionManager')
     139            allowed = set(('ClearanceOfficer', 'SectionManager'))
    131140            if len(res) != 1:
    132141                break
    133142            context_obj = res[0].getObject()
    134         dynamic_roles = self.getRolesInContext(context_obj)
    135         for dr in allowed:
    136             if dr in dynamic_roles:
    137                 roles.append(dr)
     143        dynamic_roles = set(self.getRolesInContext(context_obj))
     144        intersect = dynamic_roles & allowed
     145        if intersect:
     146            roles.extend(list(intersect))
    138147        break
    139148    return roles
Note: See TracChangeset for help on using the changeset viewer.