@@ -0,0 +1,1650 @@
+from lbworkflow.models import Activity%0Afrom lbworkflow.models import Transition%0Afrom lbworkflow.models import App%0Afrom lbworkflow.models import Process%0A%0A%0Adef get_or_create(cls, uid, **kwargs):%0A    uid_field_name = kwargs.pop('uid_field_name', 'uuid')%0A    obj = cls.objects.filter(**%7Buid_field_name: uid%7D).first()%0A    if obj:%0A        return obj%0A    kwargs%5Buid_field_name%5D = uid%0A    return cls.objects.create(**kwargs)%0A%0A%0Adef create_app(uuid, name, **kwargs):%0A    return get_or_create(App, uuid, name=name, **kwargs)%0A%0A%0Adef create_process(code, name, **kwargs):%0A    return get_or_create(Process, code, name=name, uid_field_name='code', **kwargs)%0A%0A%0Adef create_activity(uuid, process, name, **kwargs):%0A    return get_or_create(Activity, uuid, process=process, name=name, **kwargs)%0A%0A%0Adef get_activity(process, name):%0A    %22%22%22%0A    get activity%0A    :param process: %0A    :param name: 'submit' or 'submit,5f31d065-4a87-487b-beea-641f0a6720c3' %0A    :return: activity%0A    %22%22%22%0A    name_and_uuid = %5Be.strip() for e in name.split(',') if e.strip()%5D%0A    qs = Activity.objects.filter(process=process)%0A    if len(name_and_uuid) == 1:%0A        qs = qs.filter(name=name_and_uuid%5B0%5D)%0A    else:%0A        qs = qs.filter(uuid=name_and_uuid%5B1%5D)%0A    return qs%5B0%5D%0A%0A%0Adef create_transition(uuid, process, from_activity, to_activity, app=None, **kwargs):%0A    from_activity = get_activity(process, from_activity)%0A    to_activity = get_activity(process, to_activity)%0A    if not app:%0A        app = App.objects.get(name='Simple URL')%0A    return get_or_create(%0A        Transition, uuid, process=process, input_activity=from_activity,%0A        output_activity=to_activity, app=app, **kwargs)

add core/datahelper.py