rbarrois / django_xworkflows Goto Github PK
View Code? Open in Web Editor NEWLibrary to plug xworkflows into django models.
License: BSD 2-Clause "Simplified" License
Library to plug xworkflows into django models.
License: BSD 2-Clause "Simplified" License
currently this page https://django-xworkflows.readthedocs.org/en/latest/ returns a 403 where other documentations don't
The README defines the following model as an example:
class MyModel(xwf_models.WorkflowEnabled):
state = xwf_models.StateField(MyWorkflow)
After a small round of debugging and reading the tests, should this in fact be:
class MyModel(xwf_models.WorkflowEnabled, models.Model):
state = xwf_models.StateField(MyWorkflow)
Hello @rbarrois ,
this is exactly the support I've always dreamed of for managing workflows in a Django project. Thank you.
I failed to use GenericTransitionLog()
as my Models use UUID as pks.
At the moment I solved this at project level by introducing this variant, which seems to work:
class GenericTransitionLogWithUUID(xwf_models.GenericTransitionLog):
"""Abstract model for a minimal database logging setup.
Specializes GenericTransitionLog to use a GenericForeignKey with UUID as pk.
"""
content_id = models.UUIDField(_("Content id"), blank=True, null=True, db_index=True)
class Meta:
abstract = True
I think UUID should be considered first-citizens in the Django ecosystem sooner or later ... in case, I can add a specific unit test and prepare a PR. Let me know if you're interested; I do not mind a negative answer at all.
I would also add on_delete here and there to the ForeignKeys for better compatibility with recent versions of Django
Django 3.0 was released this month.
When we tried to upload our project to django 3.0, we realized django-xworflows
is not compatible.
Here is the problem we met:
python manage.py runserver
…
File "/home/aides/django_xworkflows/django_xworkflows/models.py", line 19, in <module>
from django.utils.encoding import force_text, python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (/home/aides/.virtualenvs/aides/lib/python3.7/site-packages/django/utils/encoding.py)
The issue is caused by the following removal of aliases from the django codebase.
I would like to save a record in the TransitionLog when the instance is initially created; conceptually when initial_state
is assigned
I wonder which is the cleanest approach, and most consistent with the current xWorkflows setup.
Any suggestion? Thanks
Ho hai,
Is it possible to set default longer max_length in for a state ?
Hello, very thank you for your provide the django workflow tools, but using a tool when you encounter a problem, please answer. Thanks
The question is:
class OnlinePublishFlow(xwf_models.WorkflowEnabled, models.Model):
online_state = xwf_models.StateField(OnlinePublishWorkflow)
publish = models.OneToOneField(APublish, verbose_name=u'test')
Execute python manage. Py makemigrations errors as follows:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 177, in handle
migration_name=self.migration_name,
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 47, in changes
changes = self._detect_changes(convert_apps, graph)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 198, in _detect_changes
self._optimize_migrations()
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 362, in _optimize_migrations
migration.operations = MigrationOptimizer().optimize(migration.operations, app_label=app_label)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/optimizer.py", line 38, in optimize
result = self.optimize_inner(operations, app_label)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/optimizer.py", line 53, in optimize_inner
result = operation.reduce(other, in_between, app_label)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 229, in reduce
return super(CreateModel, self).reduce(operation, in_between, app_label=app_label)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 40, in reduce
not operation.references_model(self.name, app_label)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 123, in references_model
model_app_label, model_name = self.model_to_key(model)
File "/root/workspaces/reapal-cmdb/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 137, in model_to_key
return model._meta.app_label, model._meta.object_name
AttributeError: type object 'WorkflowEnabled' has no attribute '_meta'
Looking forward to your answer thank you
Hello! 😄 first of all thanks for the library, it's so useful for my team!
I'd like to ask if there's any plan to support Django 4.x in a new release.
Thanks so much in advance!
I have copied the exaple in the readme in my existing project . then i did python manage.py makemigration and it fails
this is the error am getting
File "/home/mwas/PycharmProject/restframework_tutorial/example/models.py", line 81, in
class MyModel(xworkflows.WorkflowEnabled, models.Model):
File "/home/mwas/PycharmProject/restframework_tutorial/.venv/local/lib/python2.7/site-packages/xworkflows/base.py", line 1049, in new
cls = super(WorkflowEnabledMeta, mcs).new(mcs, name, bases, attrs)
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
am using django 1.7.1
This should be settable on a per-workflow basis, too.
The state of a WorkflowEnabled instance is not correctly displayed in Django admin.
Is it seen as a CharField + choice by Django (get_foo_display() method)?
Hello,
Is the release of the 0.9.4 planned ?
Thanks
BaselastTransitionLog
holds the latest transition informations but not the last update time, last_transition.timestamp
stays still.
BaseTransitionLog.MODIFIED_OBJECT_FIELD is not taken into account when creating transition logs (models.py#395).
Hello,
Great app ... thanks !
I'm looking for a way to have workflow "instance based". I have multiple instance of my model, say InstA and InstB, and I would like to assign them different workflows, based on, for example instance attribute (for instance the foo boolean field in my example below).
I tried this, but it doesn't work :
class MyModel(xwf_models.WorkflowEnabled, models.Model):
def __init__(self, *args, **kwargs):
# try to dynamically set the workflow based on a field for example
super(MyModel, self).__init__(*args, **kwargs)
if self.foo is True: # example of a thing I would like to achieve, to have custom workflow based on instance attribute
field = xwf_models.StateField(BaseWorkflow2)
field.contribute_to_class(CustomFormInstance, "state")
state = xwf_models.StateField(BaseWorkflow)
foo = models.BooleanField()
Is my problem clear, and do you thing django_xworkflows could face this use case ?
Regards,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.