Changeset 6162


Ignore:
Timestamp:
20 May 2011, 11:02:42 (14 years ago)
Author:
uli
Message:

Retrieve title from role, not from arbitrary dicts.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.py

    r6160 r6162  
    109109
    110110    Objects that want to offer certain local roles, can do so by
    111     setting a (preferably class-) attribute to a list of dictionaries.
     111    setting a (preferably class-) attribute to a list of role ids.
    112112
    113113    You can also define different adapters for different contexts to
     
    122122    def __init__(self, context):
    123123        self.context = context
    124         self._roles = getattr(context, 'local_roles', self._roles)
     124        role_ids = getattr(context, 'local_roles', self._roles)
     125        self._roles = [(name, role) for name, role in getRoles()
     126                       if name in role_ids]
    125127        return
    126128
     
    130132        to assign each role to).
    131133        """
    132         list_of_dict = [dict(name=x, title=self._roles[x]) for x in self._roles.keys()]
    133         return list_of_dict
     134        return [
     135            dict(
     136                name=name,
     137                title=role.title,
     138                description =role.description)
     139            for name, role in self._roles]
    134140
    135141    def roles(self):
    136142        """Return a list of roles assignable to the context object.
    137143        """
    138         return self._roles.keys()
     144        return [name for name, role in self._roles]
  • main/waeup.sirp/trunk/src/waeup/sirp/university/department.py

    r6160 r6162  
    1515    @property       # Make this method read_only and looking like an attr.
    1616    def local_roles(cls):
    17         return {
    18             'waeup.local.DepartmentOfficer':'Department Officer',
    19             }
     17        return ['waeup.local.DepartmentOfficer']
    2018
    2119    # A simple counter for ids.
  • main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py

    r6160 r6162  
    1616    @property       # Make this method read_only and looking like an attr.
    1717    def local_roles(cls):
    18         return {
    19             'waeup.local.DepartmentOfficer':'Department Officer',
    20             }
     18        return ['waeup.local.DepartmentOfficer']
    2119
    2220    def __init__(self,
Note: See TracChangeset for help on using the changeset viewer.