Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
scrungus committed Jul 4, 2024
1 parent 38e5725 commit 4e4ae36
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions coral_credits/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 4e4ae36

Please sign in to comment.