aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/models.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-12 16:09:17 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-12 16:09:17 +0100
commita0f2ae2c885f8bcc72fe0bbc549384fcc20b857b (patch)
treed4448250d4b4e78d6d4543cab9eedf4c7d4562b0 /ctrack/register/models.py
parent0bd4f8e84e4d1788d6119a78823881a96c039427 (diff)
cannot put constrain on abstract Meta class seemingly...
Diffstat (limited to '')
-rw-r--r--ctrack/register/models.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/ctrack/register/models.py b/ctrack/register/models.py
index 03a7d80..4404650 100644
--- a/ctrack/register/models.py
+++ b/ctrack/register/models.py
@@ -5,7 +5,7 @@ from typing import Optional, Dict
from django.contrib.auth import get_user_model
from django.db import models
-from django.db.models import Q, F
+from django.db.models import F
from ctrack.caf.models import CAF
from ctrack.organisations.models import Person
@@ -155,7 +155,7 @@ class CAFSingleDateEvent(EventBase, CAFMixin, SingleDateMixin):
# the type is declared with the Q expression.
models.UniqueConstraint(
fields=["date", "type_descriptor"],
- condition=~Q(type_descriptor="CAF_EMAILED_ROSA"),
+ condition=~models.Q(type_descriptor="CAF_EMAILED_ROSA"),
name="unique_caf_for_date",
),
]
@@ -179,12 +179,11 @@ class CAFTwinDateEvent(EventBase, CAFMixin, TwinDateMixin):
class Meta:
constraints = [
models.CheckConstraint(
- name="end_date_cannot_precede_start_date",
- check=~Q(end_date__lt=F("start_date")),
+ name="%(app_label)s_%(class)s_cannot_precede_start_date",
+ check=~models.Q(end_date__lt=F("start_date")),
)
]
-
# OLD CODE BELOW
class EngagementType(models.Model):
"""