27 lines
915 B
Python
27 lines
915 B
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from api.core.models.trackable_model import TrackableModel
|
|
|
|
|
|
class M2M_TemplateStep(TrackableModel):
|
|
"""
|
|
Many to Many table for templates and steps (identified by the step type).
|
|
A template can have the same step type multiple times, but there can't be two entries with the same order for one template.
|
|
"""
|
|
|
|
template = models.ForeignKey("Template", on_delete=models.CASCADE)
|
|
step_type = models.ForeignKey("StepType", on_delete=models.CASCADE)
|
|
order = models.IntegerField(verbose_name=_("ordre"))
|
|
default_notes = models.TextField(
|
|
verbose_name=_("notes par défaut"), blank=True, default=""
|
|
)
|
|
|
|
class Meta:
|
|
constraints = [
|
|
models.UniqueConstraint(
|
|
fields=["template", "order"],
|
|
name="unique_template_order",
|
|
)
|
|
]
|