Exemplo n.º 1
0
    def add_function(self, function):
        """
        Adds a FunctionXGraph record to this graph

        Arguments:
        node -- an object representing a FunctionXGraph instance or an actual models.CardModel instance

        """

        if not isinstance(function, models.FunctionXGraph):
            if isinstance(function, dict):
                functionobj = models.FunctionXGraph(**function.copy())
            else:
                functionobj = function.copy()
            function = models.FunctionXGraph()
            function.function_id = functionobj.function_id
            function.config = functionobj.config

        function.graph = self

        self._functions.append(function)

        return function
Exemplo n.º 2
0
    def copy_functions(self, other_graph, id_maps=[]):
        """
        Copies the graph_x_function relationships from a different graph and relates
        the same functions to this graph.

        """
        for function_x_graph in other_graph.functionxgraph_set.all():
            config_copy = self.replace_config_ids(function_x_graph.config,
                                                  id_maps)
            function_copy = models.FunctionXGraph(
                function=function_x_graph.function,
                config=config_copy,
                graph=self)
            function_copy.save()
Exemplo n.º 3
0
    def add_function(self, function):
        """
        Adds a card to this graph

        Arguments:
        node -- a dictionary representing a Card instance or an actual models.CardModel instance

        """

        if not isinstance(function, models.FunctionXGraph):
            functionobj = function.copy()
            function = models.FunctionXGraph()
            function.fuction_id = functionobj.functionid
            function.config = functionobj.config

        function.graph = self

        return function