Repository: wagtail/wagtail

Issue:
custom workflow model
### Is your proposal related to a problem?

yes, need to add some fields to Workflow model

### Describe the solution you'd like

suggest to make Workflow model be able to customized, same as Document as Image

### Describe alternatives you've considered

i can add a field to Workflow model myself, but in the future that customized Workflow model is provided, I would  need to migrate

### Additional context

>  Is there anything else you can add about the proposal?

No.

### Working on this

Workflow model needs to be abstracted from AbstractWorkflow. def get_workflow_model(): needs to  be defined, same as Document and image models. 

Anyone can contribute to this. View our [contributing guidelines](https://docs.wagtail.org/en/latest/contributing/index.html), add a comment to the issue once you’re ready to start.



Discussion:
Hi @arshyia3000 - thanks for the suggestion. Can you give a specific example of where this might be useful?

We do already have the ability to [subclass the Task model](https://docs.wagtail.org/en/stable/extending/custom_tasks.html) - would this achieve what you want?
Also I did a blog post on adding fields, it should be possible to add a field (relation to another model) without needing to modify the underling task model.

https://dev.to/lb/adding-tasks-with-a-checklist-to-wagtail-workflows-29b8
Thank you, guys, for the quick reply and suggestions.

Yes, I'm aware of the ability to customize the Task model, but having the ability to customize the Workflow model would provide further capabilities.

Before explaining the reasons, I suggest reading this valuable text about scalability issues in Django projects by DoorDash folks: [Scalability Tips by DoorDash](https://medium.com/@DoorDash/tips-for-building-high-quality-django-apps-at-scale-a5a25917b2b5)

Reasons:
In our admin panel, we have different users with different profiles. Having the ability to make a customizable Workflow model would allow us to provide a viewset that can create workflows for themselves and view their own workflows.

Currently, this can be done in the Task model. By customizing and adding a profile field to the Task model, it can be handled for task-related objects, but not for workflow objects.

The Task, Image, and Document models are subclassed from Abstract models, making customization straightforward. However, the Workflow model does not inherit from an AbstractWorkflow model. I suggest that, even if making the Workflow model customizable is not a priority now, it would be a good idea for the first step to have it inherited from an abstract model. For example:



```python
#/home/content/venv/lib64/python3.10/site-packages/wagtail/models/__init__.py
class Workflow(ClusterableModel):
    name = models.CharField(max_length=255, verbose_name=_("name"))
    active = models.BooleanField(
        verbose_name=_("active"),
        default=True,
        help_text=_(
            "Active workflows can be added to pages/snippets. Deactivating a workflow does not remove it from existing pages/snippets."
        ),
    )
```

class A

```python
class AbstractWorkflow(ClusterableModel):
    name = models.CharField(max_length=255, verbose_name=_("name"))
    active = models.BooleanField(
        verbose_name=_("active"),
        default=True,
        help_text=_(
            "Active workflows can be added to pages/snippets. Deactivating a workflow does not remove it from existing pages/snippets."
        ),
    )
    class Meta:
        abstract = True



class Workflow(AbstractWorkflow):
   pass
```





I should add that my purpose can be achieved by showing the queryset of the workflow objects that is created by user, or their related profile. but having an abstract workflow model would give other capabilities to work around as well and customize workflow model more.
also, this can be achieved by injecting new filed to Workflow model, per this similar question:
https://stackoverflow.com/questions/2181039/how-do-i-extend-the-django-group-model

```python
if not hasattr(Workflow, 'extra_field'):
    field = models.CharField(max_length=180, null=True, blank=True)
    field.contribute_to_class(Workflow, 'extra_field')
```


Though, i think making Workflow abstracted would be beneficial. I'll try to make PR this week. 

Resolving patch:
diff --git a/wagtail/models/__init__.py b/wagtail/models/__init__.py
--- a/wagtail/models/__init__.py
+++ b/wagtail/models/__init__.py
@@ -3519,7 +3519,7 @@ def active(self):
         return self.filter(active=True)
 
 
-class Workflow(ClusterableModel):
+class AbstractWorkflow(ClusterableModel):
     name = models.CharField(max_length=255, verbose_name=_("name"))
     active = models.BooleanField(
         verbose_name=_("active"),
@@ -3608,6 +3608,11 @@ def all_pages(self):
     class Meta:
         verbose_name = _("workflow")
         verbose_name_plural = _("workflows")
+        abstract = True
+
+
+class Workflow(AbstractWorkflow):
+    pass
 
 
 class GroupApprovalTask(Task):


Test patch: