Beispiel #1
0
 def workflow_choices(self):
     """
         return valid choices. Is actually context dependend (not all states
         can be reached from a given state)
     """
     spoke = type_registry.get(self._meta.model.get_name())
     return core.workflow.get(spoke).states
Beispiel #2
0
    def allowed_spokes(self):
        """
            Return the spokes that can be added to the current instance.
            This can be either the spoke's class default, or an instance
            specific config (instance.allowed).

            If the specific config is an empty string, no subcontent is
            allowed.

            If the specific config is a list of comma separated type names,
            those are allowed (even non-implicit ones)

            If the specific config is None, de class default applies.
        """
        def addable(t):
            """ check it it's addable, implicitly or explicitly """
            if t.implicit_add:
                return True
            explicit = set(self.children or ()) | \
                       set(self.explicit_children or ())
            return t in explicit

        if self.instance.allowed == "":
            ch = ()
        elif self.instance.allowed is None:
            # Class default
            if self.children is None:
                ch = [t for t in type_registry.values() if addable(t)]
            else:
                ch = self.children
        else:
            ch = [type_registry.get(p)
                  for p in self.instance.allowed.split(",")]
            ## filter out stale entries. Log?
            ch = filter(None, ch)
        return ch
Beispiel #3
0
 def workflow_default(self):
     """
         Return default state for active workflow
     """
     spoke = type_registry.get(self._meta.model.get_name())
     return core.workflow.get(spoke).default