Implement custom notification settings

This commit is contained in:
2022-12-18 17:21:52 +00:00
parent 4c463e88f2
commit 7ee698f457
9 changed files with 141 additions and 8 deletions

View File

@@ -97,6 +97,9 @@ class User(AbstractUser):
plan_list = [plan.name for plan in self.plans.all()]
return plan in plan_list
def get_notification_settings(self):
return NotificationSettings.objects.get_or_create(user=self)[0]
class Account(models.Model):
EXCHANGE_CHOICES = (("alpaca", "Alpaca"), ("oanda", "OANDA"))
@@ -363,6 +366,15 @@ class Strategy(models.Model):
return self.name
class NotificationSettings(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
ntfy_topic = models.CharField(max_length=255, null=True, blank=True)
ntfy_url = models.CharField(max_length=255, null=True, blank=True)
def __str__(self):
return f"Notification settings for {self.user}"
# class Perms(models.Model):
# class Meta:
# permissions = (