Changeset 881


Ignore:
Timestamp:
16 Nov 2006, 22:42:08 (18 years ago)
Author:
joachim
Message:

some fixes and renames

Location:
WAeUP_SRP/trunk
Files:
4 edited
1 copied
2 moved

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/PatchCPSUserFolderUserFolder.py

    r880 r881  
    88security.declarePublic('getRolesInContext')
    99def getRolesInContext(self, object):
    10     """Return the list of roles assigned to the user,
    11        including local roles assigned in context of
    12        the passed in object."""
     10    """Get the list of roles assigned to the user.
     11    This includes local roles assigned in the context of
     12    the passed in object.
     13    Knows about local roles blocking (roles starting with '-').
     14    """
    1315    name = self.getUserName()
    1416    roles = self.getRoles()
    15     groups = self.getGroups() + ('role:Anonymous',)
    16     if 'Authenticated' in roles:
    17         groups = groups + ('role:Authenticated',)
     17    # deal with groups
     18    groups = self.getComputedGroups()
     19    # end groups
    1820    local = {}
    1921    stop_loop = 0
     22    real_object = object
    2023    object = aq_inner(object)
    2124    while 1:
     
    5558        if stop_loop:
    5659            break
    57         inner = getattr(object, 'aq_inner', object)
    58         parent = getattr(inner, 'aq_parent', None)
    59         if parent is not None:
    60             object = parent
     60        if hasattr(object, 'aq_parent'):
     61            object = aq_inner(object.aq_parent)
    6162            continue
    6263        if hasattr(object, 'im_self'):
    63             object = object.im_self
    64             object = getattr(object, 'aq_inner', object)
     64            object = aq_inner(object.im_self)
    6565            continue
    6666        break
     
    7070            roles.append(r)
    7171    ## patch to assign dynamic roles for WAeUP
    72     info = self.getStudentInfo()
    7372    while 1:
    74         if info is None:
     73        if not hasattr(real_object,'portal_type'):
    7574            break
    76         if info['course'] is None:
     75        if real_object.portal_type != "Student":
    7776            break
    78         res = self.portal_catalog(portal_type="Department",id=info['course_doc'].department)
     77        #import pdb;pdb.set_trace()
     78        dep_id = real_object.study_course.getContent().department
     79        res = self.portal_catalog(portal_type="Department",id=dep_id)
    7980        if len(res) != 1:
    8081            break
     
    8687    return roles
    8788
    88 security.declarePublic('allowed')
    89 def allowed(self, object, object_roles=None):
    90     """Check whether the user has access to object. The user must
    91        have one of the roles in object_roles to allow access."""
    92 
    93     if object_roles is _what_not_even_god_should_do:
    94         return 0
    95 
    96     # Short-circuit the common case of anonymous access.
    97     if object_roles is None or 'Anonymous' in object_roles:
    98         return 1
    99 
    100     # Provide short-cut access if object is protected by 'Authenticated'
    101     # role and user is not nobody
    102     if 'Authenticated' in object_roles and (
    103         self.getUserName() != 'Anonymous User'):
    104         return 1
    105 
    106     # Check for a role match with the normal roles given to
    107     # the user, then with local roles only if necessary. We
    108     # want to avoid as much overhead as possible.
    109     user_roles = self.getRoles()
    110     for role in object_roles:
    111         if role in user_roles:
    112             if self._check_context(object):
    113                 return 1
    114             return None
    115 
    116     # Check local roles, calling getRolesInContext to avoid too much
    117     # complexity, at the expense of speed.
    118     for role in self.getRolesInContext(object):
    119         if role in object_roles:
    120             return 1
    121 
    122     return None
    123 
    124 from Products.CPSUserFolder import UserFolderWithGroups 
    125 UserFolderWithGroups.getRolesInContext = getRolesInContext
    126 UserFolderWithGroups.allowed = allowed
     89from Products.CPSUserFolder.CPSUserFolder import CPSUser
     90CPSUser.getRolesInContext = getRolesInContext
  • WAeUP_SRP/trunk/PatchCPSUserFolderUserFolderWithGroups.py

    r880 r881  
    1919    stop_loop = 0
    2020    object = aq_inner(object)
     21    import pdb; pdb.set_trace()
    2122    while 1:
    2223        # Collect all roles info
  • WAeUP_SRP/trunk/__init__.py

    r880 r881  
    1414import PatchCatalogToolXMLAdapter
    1515import PatchCPSSchemasAttributeStorageAdapter
     16import PatchCPSUserFolderUserFolderWithGroups
     17import PatchCPSUserFolderUserFolder
    1618import PatchBasicWidgetsCPSStringWidget
    17 import PatchCPSUserFolderUserFolderWithGroups
    1819# Only for CPS 3.4.1. In 3.4.2 and later this should be fixed.
    1920import PatchCPSDefaultImportExport
  • WAeUP_SRP/trunk/exportimport.py

    r502 r881  
    7474    site = context.getSite()
    7575    pm = site.portal_membership
    76     pm.setLocalGroupRoles(site,['role:Authenticated',],'SectionReader')
     76    #pm.setLocalGroupRoles(site,['group:ClearanceOfficers',],'SectionReader')
    7777
    7878    importWAeUPTable(site.portal_accommodation, '', context,'accommodation')
  • WAeUP_SRP/trunk/skins/waeup_student/co_searchStudents.py

    r875 r881  
    1 ## Script (Python) "co_search"
     1## Script (Python) "co_searchStudents"
    22##bind container=container
    33##bind context=context
     
    6262                      ob=default,
    6363                      layout_mode='edit',
    64                       formaction="co_search"
     64                      formaction="co_searchStudents"
    6565                      )
    6666if psm == '':
     
    160160if items:
    161161    for item in items:
    162         info = context.getStudentInfo(item)
    163         if context.isClearanceOfficer(info):
     162        #if context.isClearanceOfficer(info):
     163        droles = member.getRolesInContext(item)
     164        if "ClearanceOfficer" in droles:
     165            info = context.getStudentInfo(item)
    164166            students.append(info)
    165     return context.co_search_form(rendered = rend,
     167    return context.co_search_view(rendered = rend,
    166168                             psm = "%d,%d matching Students found QS = %s" %\
    167169                                    (len(review_set),len(search_set),query_step),
     
    170172                             is_manager = is_manager,
    171173                             )
    172 return context.co_search_form(rendered = rend,
     174return context.co_search_view(rendered = rend,
    173175                             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),
    174176                             students = students,
  • WAeUP_SRP/trunk/skins/waeup_student/students_index.py

    r874 r881  
    2424
    2525if "ClearanceOfficers" in member.getGroups():
    26     return redirect("%s/co_search" % students_url)
     26    return redirect("%s/co_searchStudents" % students_url)
    2727if context.isManager():
    2828    return redirect("%s/searchStudents" % students_url)
Note: See TracChangeset for help on using the changeset viewer.