# Path: django_workflow/utils.py
# def import_from(module, name):
#     module = __import__(module, fromlist=[name])
#     return getattr(module, name)
# 
# def import_from_path(full_path):
#     parts = full_path.rsplit(".", 1)
#     return import_from(parts[0], parts[1])


import threading
import json
from datetime import timedelta, datetime
from typing import Tuple, TypeVar
from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.db.models import SET_NULL
from django.utils.timezone import now as django_now
from django.utils.translation import ugettext_lazy
from django.db.models.deletion import PROTECT
from django_workflow.utils import import_from, import_from_path
            if last and last.state.active:
                return False
            elif self.initial_transition is not None:
                conditions = self.initial_transition.condition_set.all()
                if len(conditions) == 0:
                    if automatic:
                        return self.initial_transition.automatic
                    else:
                        return not self.initial_transition.automatic
                else:
                    root_condition = conditions.first()
                    if root_condition.check_condition(user=user, object_id=object_id, object_state=last):
                        if automatic:
                            return self.initial_transition.automatic
                        else:
                            return not self.initial_transition.automatic
                    else:
                        return False
            else:
                return False

    def natural_key(self):
        return (self.name,)

    def add_object(self, object_id, execute_async=True):
        process = CurrentObjectState.objects.create(object_id=object_id, state=self.initial_state)
        _execute_atomatic_transitions(self.initial_state, object_id, process.id, execute_async=execute_async)
        return process

    def object_class(self):

# Path: django_workflow/utils.py
# def import_from(module, name):
#     module = __import__(module, fromlist=[name])
#     return getattr(module, name)
# 
# def import_from_path(full_path):
#     parts = full_path.rsplit(".", 1)
#     return import_from(parts[0], parts[1])


# Path: django_workflow/models.py
import threading
import json
from datetime import timedelta, datetime
from typing import Tuple, TypeVar
from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.db.models import SET_NULL
from django.utils.timezone import now as django_now
from django.utils.translation import ugettext_lazy
from django.db.models.deletion import PROTECT
from django_workflow.utils import import_from, import_from_path

            if last and last.state.active:
                return False
            elif self.initial_transition is not None:
                conditions = self.initial_transition.condition_set.all()
                if len(conditions) == 0:
                    if automatic:
                        return self.initial_transition.automatic
                    else:
                        return not self.initial_transition.automatic
                else:
                    root_condition = conditions.first()
                    if root_condition.check_condition(user=user, object_id=object_id, object_state=last):
                        if automatic:
                            return self.initial_transition.automatic
                        else:
                            return not self.initial_transition.automatic
                    else:
                        return False
            else:
                return False

    def natural_key(self):
        return (self.name,)

    def add_object(self, object_id, execute_async=True):
        process = CurrentObjectState.objects.create(object_id=object_id, state=self.initial_state)
        _execute_atomatic_transitions(self.initial_state, object_id, process.id, execute_async=execute_async)
        return process

    def object_class(self):

        return import_from_path(self.object_type)