From 4e4ae36b7273ae5e10834bc959ccf2ad72bb220e Mon Sep 17 00:00:00 2001 From: scrungus Date: Thu, 4 Jul 2024 17:52:09 +0100 Subject: [PATCH] black --- coral_credits/api/models.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/coral_credits/api/models.py b/coral_credits/api/models.py index 6c42c1b..f9d4ec1 100644 --- a/coral_credits/api/models.py +++ b/coral_credits/api/models.py @@ -32,22 +32,21 @@ class CreditAccount(models.Model): def __str__(self) -> str: return f"{self.name}" + class ResourceProviderAccount(models.Model): account = models.ForeignKey(CreditAccount, on_delete=models.CASCADE) provider = models.ForeignKey(ResourceProvider, on_delete=models.CASCADE) project_id = models.UUIDField() - + class Meta: unique_together = ( ( "account", "provider", ), - ( - "provider", - "project_id" - ), + ("provider", "project_id"), ) + def __str__(self) -> str: return f"{self.project_id} for {self.account} in {self.provider}" @@ -96,14 +95,16 @@ def __str__(self) -> str: class Consumer(models.Model): consumer_ref = models.CharField(max_length=200) consumer_uuid = models.UUIDField() - resource_provider_account = models.ForeignKey(ResourceProviderAccount, on_delete=models.DO_NOTHING) + resource_provider_account = models.ForeignKey( + ResourceProviderAccount, on_delete=models.DO_NOTHING + ) user_ref = models.UUIDField() created = models.DateTimeField(auto_now_add=True) start = models.DateTimeField() end = models.DateTimeField() class Meta: - # TODO(tylerchristie): allow either/or nullable? + # TODO(tylerchristie): allow either/or nullable? # constraints = [ # models.CheckConstraint( # check=Q(consumer_ref=False) | Q(consumer_uuid=False),