Changeset 1549


Ignore:
Timestamp:
15 Mar 2007, 09:01:02 (18 years ago)
Author:
joachim
Message:

isCourseAdviser now works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/PatchCPSUserFolderUserFolder.py

    r1548 r1549  
    7878            break
    7979
    80 
     80        #from pdb import set_trace;set_trace()
    8181        # can be later simplified by replacing by students_catalog values - Henrik
    8282        # getattr works always because of acquisition ?! Henrik
     
    8585            break
    8686        sc_obj = sc.getContent()
    87         res_sc = self.portal_catalog(portal_type="Certificate",
    88                                      id = sc_obj.study_course)
    89         if len(res_sc) != 1:
     87        cert_id = sc_obj.study_course
     88        res_cert = self.portal_catalog(id = cert_id)
     89        if len(res_cert) != 1:
    9090            break
    91         cert_path = res_sc[0].getPath().split('/')
     91        certificate_brain = res_cert[0]
     92        certificate_obj = certificate_brain.getObject()
     93        cert_path = certificate_brain.getPath().split('/')
    9294        fac_id = cert_path[-4]
    9395        dep_id = cert_path[-3]
     
    98100        if len(res) != 1:
    99101            break
    100         self.students_catalog.modifyRecord(id = student_id,
     102        st_entry = res[0]
     103        if st_entry.faculty != fac_id or\
     104           st_entry.department != dep_id or\
     105           st_entry.course != cert_id:
     106               self.students_catalog.modifyRecord(id = student_id,
    101107                                                faculty = fac_id,
    102108                                                department = dep_id,
    103                                                 course = sc_obj.study_course,
     109                                                course = cert_id
    104110                                                )
    105 
    106 
    107         res = self.portal_catalog(portal_type="Department",id=dep_id)
    108         if len(res) != 1:
    109             break
    110         dynamic_roles = self.getRolesInContext(res[0].getObject())
    111         for dr in ('ClearanceOfficer','CourseAdviser', 'SectionManager'):
     111        if real_object.portal_type == "StudentStudyLevel":
     112            context_obj = getattr(certificate_obj,real_object.getId())
     113            allowed = ('CourseAdviser', 'SectionManager')
     114        else:
     115            res = self.portal_catalog(portal_type="Department",id=dep_id)
     116            allowed = ('ClearanceOfficer', 'SectionManager')
     117            if len(res) != 1:
     118                break
     119            context_obj = res[0].getObject()
     120        dynamic_roles = self.getRolesInContext(context_obj)
     121        for dr in allowed:
    112122            if dr in dynamic_roles:
    113123                roles.append(dr)
Note: See TracChangeset for help on using the changeset viewer.