Ejemplo n.º 1
0
    def get_objects(self):
        """
        Returns all objects which have this workflow assigned. Globally
        (via the object's content type) or locally (via the object itself).        
        """
        
        from dynflows import utils
        
        objs = []

        # Get all objects whose content type has this workflow
        for wmr in WorkflowModelRelation.objects.filter(workflow=self):
            ctype = wmr.content_type
            # We have also to check whether the global workflow is not
            # overwritten.
            for obj in ctype.model_class().objects.all():
                if utils.get_workflow(obj) == self:
                    objs.append(obj)

        # Get all objects whose local workflow this workflow
        for wor in WorkflowObjectRelation.objects.filter(workflow=self):
            if wor.content not in objs:
                objs.append(wor.content)

        return objs
Ejemplo n.º 2
0
    def get_workflow(self):
        """
        Returns the current workflow of the object.
        """

        return utils.get_workflow(self)