Commit fca54638 authored by Titia de Castro's avatar Titia de Castro

created reaction model in announcements app

parent 689eb431
...@@ -5,3 +5,16 @@ class Announcement(models.Model): ...@@ -5,3 +5,16 @@ class Announcement(models.Model):
announcement_title = models.CharField(max_length=200) announcement_title = models.CharField(max_length=200)
announcement_body = models.TextField() announcement_body = models.TextField()
pub_date = models.DateField(auto_now_add=True) pub_date = models.DateField(auto_now_add=True)
class Reaction(models.Model):
class ReactionNames(models.TextChoices):
LIKE = 'Like'
LOVE = 'Love'
ANGRY = 'Angry'
reaction_name = models.CharField(max_length=5, choices=ReactionNames.choices)
tally = models.IntegerField(default=0)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, related_name='reactions')
def __str__(self):
return '{} {} reactions'.format(self.announcement.announcement_title, self.reaction_name)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment