Beispiel #1
0
 def get_context(self):
     super_context = super(self.__class__,self).get_context()
     agents = Agent.objects.filter(enabled=True).order_by("name")
     actions = {}
     if not self.user.is_superuser:
         if self.user.has_perm('agent.show_widget_agent'):
             agents = get_objects_for_user(self.user, 'use_agent', Agent).filter(enabled=True).order_by("name")
             #Fix added to filter agents actions on set acls
             for agent in agents:
                 if not self.user.is_superuser:
                     current_actions = get_objects_for_user(self.user, 'use_action', Action).filter(agent=agent).order_by("name")
                     actions[agent.name] = current_actions
             if not actions:
                 agents = {}
         else: 
             agents = {}
     operations = Operation.objects.filter(enabled=True).order_by("name")
     if not self.user.is_superuser:
         operations = get_objects_for_user(self.user, 'execute_operation', Operation).filter(enabled=True).order_by("name")
         
     context_operations = kermit_modules.extract(ContextOperation)
     automatic_operations = {}
     if context_operations:
         for c_op in context_operations:
             if c_op.get_enabled(self.user):
                 menu_name = "Undefined"
                 if c_op.get_type():
                     menu_name = c_op.get_type()
                 if not menu_name in automatic_operations:
                     automatic_operations[menu_name] = []
                 automatic_operations[menu_name].extend(c_op.get_operations())
             else:
                 logger.debug("Excluding operation %s. Not enabled for user %s" % (c_op.get_type(), self.user))
     widget_context = {"agents":agents, "operations":operations, "actions": actions, 'automatic_operations':automatic_operations}
     return dict(super_context.items() + widget_context.items())
Beispiel #2
0
def check_context_operation_visibility(server): 
    context_operations = kermit_modules.extract(ContextOperation)
    classes = []
    if context_operations:
        for c_op in context_operations:
            if c_op.get_visible(server):
                current_class = c_op.get_type()
                if current_class and not current_class in classes:
                    classes.append(current_class)
    return classes
Beispiel #3
0
def check_context_operation_visibility(server):
    context_operations = kermit_modules.extract(ContextOperation)
    classes = []
    if context_operations:
        for c_op in context_operations:
            if c_op.get_visible(server):
                current_class = c_op.get_type()
                if current_class and not current_class in classes:
                    classes.append(current_class)
    return classes
Beispiel #4
0
    def get_context(self):
        super_context = super(self.__class__, self).get_context()
        agents = Agent.objects.filter(enabled=True).order_by("name")
        actions = {}
        if not self.user.is_superuser:
            if self.user.has_perm('agent.show_widget_agent'):
                agents = get_objects_for_user(
                    self.user, 'use_agent',
                    Agent).filter(enabled=True).order_by("name")
                #Fix added to filter agents actions on set acls
                for agent in agents:
                    if not self.user.is_superuser:
                        current_actions = get_objects_for_user(
                            self.user, 'use_action',
                            Action).filter(agent=agent).order_by("name")
                        actions[agent.name] = current_actions
                if not actions:
                    agents = {}
            else:
                agents = {}
        operations = Operation.objects.filter(enabled=True).order_by("name")
        if not self.user.is_superuser:
            operations = get_objects_for_user(
                self.user, 'execute_operation',
                Operation).filter(enabled=True).order_by("name")

        context_operations = kermit_modules.extract(ContextOperation)
        automatic_operations = {}
        if context_operations:
            for c_op in context_operations:
                if c_op.get_enabled(self.user):
                    menu_name = "Undefined"
                    if c_op.get_type():
                        menu_name = c_op.get_type()
                    if not menu_name in automatic_operations:
                        automatic_operations[menu_name] = []
                    automatic_operations[menu_name].extend(
                        c_op.get_operations())
                else:
                    logger.debug(
                        "Excluding operation %s. Not enabled for user %s" %
                        (c_op.get_type(), self.user))
        widget_context = {
            "agents": agents,
            "operations": operations,
            "actions": actions,
            'automatic_operations': automatic_operations
        }
        return dict(super_context.items() + widget_context.items())
Beispiel #5
0
    def get_context(self):
        super_context = super(self.__class__, self).get_context()
        agents = Agent.objects.filter(enabled=True)
        actions = {}
        if not self.user.is_superuser:
            agents = get_objects_for_user(self.user, 'use_agent',
                                          Agent).filter(enabled=True)
            #Fix added to filter agents actions on set acls
            for agent in agents:
                if not self.user.is_superuser:
                    current_actions = get_objects_for_user(
                        self.user, 'use_action', Action).filter(agent=agent)
                    actions[agent.name] = current_actions
#	if not actions:
#		agents = {}
        operations = Operation.objects.filter(enabled=True)
        if not self.user.is_superuser:
            operations = get_objects_for_user(self.user, 'execute_operation',
                                              Operation).filter(enabled=True)

        context_operations = kermit_modules.extract(ContextOperation)
        automatic_operations = {}
        for c_op in context_operations:
            menu_name = "Undefined"
            if c_op.get_type():
                menu_name = c_op.get_type()
            if not menu_name in automatic_operations:
                automatic_operations[menu_name] = []
            automatic_operations[menu_name].extend(c_op.get_operations())
#
#	if context_operations:
#            for c_op in context_operations:
#                menu_name = "Undefined"
#                if c_op.get_type():
#                    menu_name = c_op.get_type()
#                if not menu_name in automatic_operations:
#                    automatic_operations[menu_name] = []
#                automatic_operations[menu_name].extend(c_op.get_operations())

        widget_context = {
            "agents": agents,
            "operations": operations,
            "actions": actions,
            'automatic_operations': automatic_operations
        }
        return dict(super_context.items() + widget_context.items())
Beispiel #6
0
    def get_context(self):
        super_context = super(self.__class__,self).get_context()
        agents = Agent.objects.filter(enabled=True)
        actions = {}
        if not self.user.is_superuser:
            agents = get_objects_for_user(self.user, 'use_agent', Agent).filter(enabled=True)
            #Fix added to filter agents actions on set acls
            for agent in agents:
                if not self.user.is_superuser:
                    current_actions = get_objects_for_user(self.user, 'use_action', Action).filter(agent=agent)
                    actions[agent.name] = current_actions
#	if not actions:
#		agents = {}
        operations = Operation.objects.filter(enabled=True)
        if not self.user.is_superuser:
            operations = get_objects_for_user(self.user, 'execute_operation', Operation).filter(enabled=True)
            
        context_operations = kermit_modules.extract(ContextOperation)
        automatic_operations = {}
        for c_op in context_operations:
            menu_name = "Undefined"
            if c_op.get_type():
                menu_name = c_op.get_type()
            if not menu_name in automatic_operations:
                automatic_operations[menu_name] = []
            automatic_operations[menu_name].extend(c_op.get_operations())
#
#	if context_operations:
#            for c_op in context_operations:
#                menu_name = "Undefined"
#                if c_op.get_type():
#                    menu_name = c_op.get_type()
#                if not menu_name in automatic_operations:
#                    automatic_operations[menu_name] = []
#                automatic_operations[menu_name].extend(c_op.get_operations())

        widget_context = {"agents":agents, "operations":operations, "actions": actions, 'automatic_operations':automatic_operations}
        return dict(super_context.items() + widget_context.items())