Exemplo n.º 1
0
    def getInfo(self):
        context = self.flatten()
        context.setdefault("permissions", {})
        for permission, value in DEFAULT_CONTEXT_PERMISSIONS.items():
            context["permissions"][permission] = context["permissions"].get(permission, value)

        return context
Exemplo n.º 2
0
    def subscription_permissions(self, base=[]):
        """
            Return a list of granted permissions on this context.

            To construct the list, three (maximum) possible sources will be looked up
            in the following order. For each of max contexts existing permissions. Once
            a value is found, the rest won't be looked up, and so not overriden.

            1. Provided base permissions
            2. Context permission policy for that permission, will grant it not restricted to.
            2. Default policy for that permission, will grant it not restricted to.
        """
        user_permissions = list(base)

        for permission, default in DEFAULT_CONTEXT_PERMISSIONS.items():
            if permission not in user_permissions:
                context_grants_permission = self.get_permission_policy(permission, default) != "restricted"
                if context_grants_permission:
                    user_permissions.append(permission)

        return user_permissions