Skip to content

Commit

Permalink
Merge pull request #1512 from sson68x/modified_notification_models
Browse files Browse the repository at this point in the history
Modify models.py
  • Loading branch information
brylie authored Dec 11, 2024
2 parents 6d9abf5 + 639de57 commit ba4f7fb
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions project/notification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@
Notifies users about new followers or replies.
"""
from django.db import models

from accounts.models import Profile
from threads.models import Civi, Thread
from enum import Enum

class ActivityType(Enum):
NEW_FOLLOWER = "new_follower"
RESPONSE_TO_CIVI = "response_to_your_civi"
REBUTTAL_TO_RESPONSE = "rebuttal_to_your_response"


class Notification(models.Model):
account = models.ForeignKey(
Profile, default=None, null=True, on_delete=models.PROTECT
Profile, null=True, on_delete=models.PROTECT,
help_text="The profile receiving the notification."
)
thread = models.ForeignKey(
Thread, default=None, null=True, on_delete=models.PROTECT
Thread, null=True, on_delete=models.PROTECT,
help_text="The thread related to the notification."
)
civi = models.ForeignKey(
Civi, default=None, null=True, on_delete=models.PROTECT
) # always a solution or null

# Need to go to bed but there are going to be SO MANY OF THESE
activity_CHOICES = (
("new_follower", "New follower"),
("response_to_yout_civi", "Response to your civi"),
("rebuttal_to_your_response", "Rebuttal to your response"),
Civi, null=True, on_delete=models.PROTECT,
help_text="The Civi solution associated with the notification, if any."
)

activity_CHOICES = [(tag.value, tag.name.replace("_", " ").capitalize()) for tag in ActivityType]
activity_type = models.CharField(
max_length=31, default="new_follower", choices=activity_CHOICES
max_length=31, default=ActivityType.NEW_FOLLOWER.value, choices=activity_CHOICES
)
read = models.BooleanField(default=False)

created = models.DateTimeField(auto_now_add=True, blank=True, null=True)
last_modified = models.DateTimeField(auto_now=True, blank=True, null=True)
created = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)

def __str__(self):
return f"Notification({self.account}, {self.activity_type})"

0 comments on commit ba4f7fb

Please sign in to comment.