Esempio n. 1
0
    def accessible_target_list(self, checked_usergroups=[], mode="string"):
        """Return all the targets this usergroups give access to"""
        accessible_targets = []
        checked_usergroups.append(self)

        # 1. list all the directly attached targets
        for target in self.targets:
            if mode == "string":
                accessible_targets.append(target.name)
            else:
                accessible_targets.append(target)

        # 2. list all targets accessible through usergroups
        for usergroup in self.containedin:
            if usergroup not in checked_usergroups:
                checked_usergroups.append(usergroup)
                for target in usergroup.accessible_target_list(
                        checked_usergroups, mode="obj"):
                    if target not in accessible_targets:
                        if mode == "string":
                            accessible_targets.append(target.name)
                        else:
                            accessible_targets.append(target)

        # 3. list all the target accessible through targetgroups
        for targetgroup in self.tgmembers:
            for target in targetgroup.accessible_target_list():
                if target not in self.targets:
                    if mode == "string":
                        accessible_targets.append(target.name)
                    else:
                        accessible_targets.append(target)

        return accessible_targets
Esempio n. 2
0
    def accessible_target_list(self, checked_usergroups = [], mode="string"):
        """Return all the targets this usergroups give access to"""
        accessible_targets = []
        checked_usergroups.append(self)

        # 1. list all the directly attached targets
        for target in self.targets:
            if mode == "string":
                accessible_targets.append(target.name)
            else:
                accessible_targets.append(target)

        # 2. list all targets accessible through usergroups
        for usergroup in self.gmembers:
            if usergroup not in checked_usergroups:
                checked_usergroups.append(usergroup)
                for target in usergroup.accessible_target_list(checked_usergroups):
                    if target not in self.targets:
                        if mode == "string": 
                            accessible_targets.append(target.name)
                        else:
                            accessible_targets.append(target)

        # 3. list all the target accessible through targetgroups
        for targetgroup in self.tgmembers:
            for target in targetgroup.accessible_target_list():
                if target not in self.targets:
                    if mode == "string":
                        accessible_targets.append(target.name)
                    else:
                        accessible_targets.append(target)

        return accessible_targets
Esempio n. 3
0
    def accessible_target_list(self, style="object"):
        """Return targets accessible to the users (as object or names list)"""
        targets = []
        output = "Accessible directly: "

        # 1. list all the directly attached targets
        for target in self.targets:
            targets.append(target)
            output = output + target.show_name() + " ; "
        
        output = output + "\nAccessible through usergroups: "
        # 2. list all the targets accessible through usergroup
        for usergroup in self.usergroups:
            output = output + "\n" + usergroup.show_name() + ": "
            for target in usergroup.accessible_target_list(mode="obj"):
                output = output + target.show_name() + " ; "
                if target not in targets:
                    targets.append(target)

        output = output + "\nAccessible through targetgroups: "
        # 3. list all the targets accessible through targetgroup
        for targetgroup in self.targetgroups:
            output = output + "\n" + targetgroup.show_name() + ": "
            for target in targetgroup.accessible_target_list():
                output = output + target.show_name() + " ; "
                if target not in targets:
                    targets.append(target)


        # return target objects or names depending of style
        if style == "names":
            targetnames = []
            for target in targets:
                targetnames.append(target.show_name())
            targets = sorted(targetnames)
        elif style == "details":
            targets = output
        
        return targets
Esempio n. 4
0
    def accessible_target_list(self, style="object"):
        """Return targets accessible to the users (as object or names list)"""
        targets = []
        output = "Accessible directly: "

        # 1. list all the directly attached targets
        for target in self.targets:
            targets.append(target)
            output = output + target.show_name() + " ; "

        output = output + "\nAccessible through usergroups: "
        # 2. list all the targets accessible through usergroup
        for usergroup in self.usergroups:
            output = output + "\n" + usergroup.show_name() + ": "
            for target in usergroup.accessible_target_list(mode="obj"):
                output = output + target.show_name() + " ; "
                if target not in targets:
                    targets.append(target)

        output = output + "\nAccessible through targetgroups: "
        # 3. list all the targets accessible through targetgroup
        for targetgroup in self.targetgroups:
            output = output + "\n" + targetgroup.show_name() + ": "
            for target in targetgroup.accessible_target_list():
                output = output + target.show_name() + " ; "
                if target not in targets:
                    targets.append(target)

        # return target objects or names depending of style
        if style == "names":
            targetnames = []
            for target in targets:
                targetnames.append(target.show_name())
            targets = sorted(targetnames)
        elif style == "details":
            targets = output

        return targets