2023-03-05 20:09:31 +00:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.contrib.auth.models import AbstractUser
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
# from core.lib.customers import get_or_create, update_customer_fields
|
|
|
|
from core.util import logs
|
|
|
|
|
|
|
|
log = logs.get_logger(__name__)
|
|
|
|
|
2023-03-06 21:11:17 +00:00
|
|
|
SERVICE_CHOICES = (("nordigen", "Nordigen"),)
|
|
|
|
|
2023-03-05 20:09:31 +00:00
|
|
|
|
|
|
|
class User(AbstractUser):
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
payment_provider_id = models.CharField(max_length=255, null=True, blank=True)
|
|
|
|
billing_provider_id = models.CharField(max_length=255, null=True, blank=True)
|
|
|
|
email = models.EmailField(unique=True)
|
|
|
|
|
|
|
|
def get_notification_settings(self):
|
|
|
|
return NotificationSettings.objects.get_or_create(user=self)[0]
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationSettings(models.Model):
|
2023-03-06 21:11:17 +00:00
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
2023-03-05 20:09:31 +00:00
|
|
|
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}"
|
2023-03-06 21:11:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Aggregator(models.Model):
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
service = models.CharField(max_length=255, choices=SERVICE_CHOICES)
|