-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathmodels.py
More file actions
22 lines (16 loc) · 660 Bytes
/
models.py
File metadata and controls
22 lines (16 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from django.contrib.auth import get_user_model
from django.db import models
from statemachine.mixins import MachineMixin
User = get_user_model()
class WorkflowSteps(models.TextChoices):
DRAFT = "draft"
PUBLISHED = "published"
class Workflow(models.Model, MachineMixin):
state_machine_name = "workflow.statemachines.WorfklowStateMachine"
state_machine_attr = "wf"
bind_events_as_methods = True
state = models.CharField(
max_length=30, choices=WorkflowSteps.choices, default=WorkflowSteps.DRAFT
)
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
is_active = models.BooleanField(default=False)