aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/payments/models.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-09 17:24:53 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-09 17:24:53 +0100
commit7550f31f604fa45f9030a32b9b8fbc2d0739bed7 (patch)
tree0ca1863f5ecaeaefba1e448e9e356a0e5c282ed8 /pyblackbird_cc/payments/models.py
parent0bef50c8097ab52df424c94176e913dcb1d8f7f5 (diff)
subscription and user is now uniquely constrained
Diffstat (limited to 'pyblackbird_cc/payments/models.py')
-rw-r--r--pyblackbird_cc/payments/models.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/pyblackbird_cc/payments/models.py b/pyblackbird_cc/payments/models.py
index cbf462c..174e3fe 100644
--- a/pyblackbird_cc/payments/models.py
+++ b/pyblackbird_cc/payments/models.py
@@ -57,5 +57,8 @@ class Subscription(models.Model):
start_date = models.DateTimeField(null=True, blank=True)
end_date = models.DateTimeField(null=True, blank=True)
+ class Meta:
+ constraints = [models.UniqueConstraint(fields=["user", "plan"], name="unique_user_plan")]
+
def __str__(self):
return f"Subscription for {self.user.username}"