# Path: notification/models.py
# class Notification(models.Model):
#     owner = models.ForeignKey(to='account.Account', related_name='notifications')
#     sender = models.ForeignKey(to='account.Account', related_name='sent_notifications')
#     post = models.ForeignKey(to='link.Post', null=True)
#     type = models.CharField(max_length=50)
#     viewed = models.BooleanField(default=False)
#     created_at = models.DateTimeField(auto_now_add=True)
#     updated_at = models.DateTimeField(auto_now=True)
# 
#     @staticmethod
#     def check_as_viewed(owner):
#         Notification.objects.filter(owner=owner).update(viewed=True)
# 
#     @staticmethod
#     def add(owner, sender, type, post=None):
#         notify = Notification(owner=owner, sender=sender, type=type.value, post=post)
#         notify.save()


from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from notification.models import Notification



class NotificationView:
    @staticmethod
    @login_required
    def list(request):
        owner = request.user.accounts.first()

# Path: notification/models.py
# class Notification(models.Model):
#     owner = models.ForeignKey(to='account.Account', related_name='notifications')
#     sender = models.ForeignKey(to='account.Account', related_name='sent_notifications')
#     post = models.ForeignKey(to='link.Post', null=True)
#     type = models.CharField(max_length=50)
#     viewed = models.BooleanField(default=False)
#     created_at = models.DateTimeField(auto_now_add=True)
#     updated_at = models.DateTimeField(auto_now=True)
# 
#     @staticmethod
#     def check_as_viewed(owner):
#         Notification.objects.filter(owner=owner).update(viewed=True)
# 
#     @staticmethod
#     def add(owner, sender, type, post=None):
#         notify = Notification(owner=owner, sender=sender, type=type.value, post=post)
#         notify.save()


# Path: notification/views.py
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from notification.models import Notification




class NotificationView:
    @staticmethod
    @login_required
    def list(request):
        owner = request.user.accounts.first()

        notifications = Notification.objects.filter(owner=owner).order_by('-created_at')