예제 #1
0
    def __show_group(self, group, path, errors = []):
        assert group is not None
        assert group.is_group()
        assert path is not None

        # Make sure that current_user has "view" permissions on it.
        current_user = self.api.get_current_user()
        if group.get_id() is not None:
            view = self.guard.get_action(handle = 'view', type = UserAction)
            assert view is not None
            if not self.guard.has_permission(current_user, view, group):
                group     = Group(group.get_name())
                errors    = [_("You do not have permission to view " +
                                  "this group.")]

        # Collect information for the browser.
        users    = []
        groups   = []
        if group.get_id() is not None:
            acls     = self.userdb.get_permission_list(group)
            parents  = self.guard.get_resource_parents(group)
            children = self.guard.get_resource_children(group)
            for child in children:
                if child.is_group():
                    groups.append(child)
                else:
                    users.append(child)
        else:
            parent_id = path.crop().get_current_id()
            parent    = self.guard.get_resource(id = parent_id)
            parents   = [parent]
            acls      = []

        # Render the template.
        self.api.render('group_editor.tmpl',
                        path         = path,
                        parents      = parents,
                        group        = group,
                        users        = users,
                        groups       = groups,
                        acls         = acls,
                        get_resource = self.guard.get_resource,
                        errors       = errors)