Skip to content

Commit

Permalink
finished marketplace models
Browse files Browse the repository at this point in the history
  • Loading branch information
minghansun1 committed Oct 21, 2024
1 parent 0e5da93 commit 165578c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions backend/marketplace/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __str__(self):
return f"Offer for {self.item} made by {self.user}"


class Category(Enum):
class Category(models.TextChoices):
SUBLET = "sublet"
APPLIANCE = "appliance"
COOKWARE = "cookware"
Expand All @@ -48,17 +48,19 @@ def __str__(self):

class Item(models.Model):
seller = models.ForeignKey(User, on_delete=models.CASCADE)
buyers = models.ManyToManyField(
User, through=Offer, related_name="items_offered", blank=True
tags = models.ManyToManyField(Tag, related_name="items", blank=True)
category = models.CharField(
max_length=50,
choices=Category.choices,
default=Category.OTHER,
)
favorites = models.ManyToManyField(User, related_name="items_favorited", blank=True)
tags = models.ManyToManyField(Tag, related_name="items", blank=True)

title = models.CharField(max_length=255)
description = models.TextField(null=True, blank=True)
external_link = models.URLField(max_length=255, null=True, blank=True)
price = models.IntegerField()
negotiable = models.BooleanField(default=True)
category = models.CharField(max_length=50, choices=[(category, category.value) for category in Category])
created_at = models.DateTimeField(auto_now_add=True)
expires_at = models.DateTimeField()

Expand Down

0 comments on commit 165578c

Please sign in to comment.