# Path: users/views.py
# def request_login(request):
#     messages.add_message(request, messages.INFO,
#                          "You must be logged in to do this")
#     return HttpResponseRedirect(reverse('frontpage'))
# 
# Path: notifications/models.py
# class Notification(models.Model):
#     NOTIFICATION_TYPES = (
#         ("proposal_response", ""),
#         ("proposal_comment", ""),
#         ("proposal_amendment", ""),
#         ("comment_reply", ""),
#         ("student_council_soon", ""),
#         ("comment_hidden", ""),
#         ("proposal_hidden", ""),
#         ("proposal_vote_up", ""),
#         ("proposal_vote_down", ""),
#         ("comment_vote_up", ""),
#         ("comment_vote_down", ""),
#         ("new_proposal", "")
#     )
# 
#     recipient = models.ForeignKey(settings.AUTH_USER_MODEL,
#                                   related_name="notifications")
#     type = models.CharField(max_length=50,
#                             choices=NOTIFICATION_TYPES,
#                             blank=False)
#     object_id = models.PositiveIntegerField()
#     content_type = models.ForeignKey(ContentType)
#     content = GenericForeignKey()
#     unread = models.BooleanField(default=True)
#     has_been_emailed = models.BooleanField(default=False)
#     created_at = models.DateTimeField(auto_now_add=True)
# 
#     objects = NotificationManager()
# 
#     def mark_as_read(self):
#         self.unread = False
#         self.save()
# 
#     def mark_as_emailed(self):
#         self.has_been_emailed = True
#         self.save()


from collections import Counter
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from users.views import request_login
from .models import Notification




def notifications(request):
    if not request.user.is_authenticated():
        request_login(request)
        return HttpResponseRedirect(reverse("frontpage"))
    else:
        template = "notifications.html"

        if request.is_ajax():
            template = "popover_notifications.html"

        unread = Notification.objects.get_unread(request.user)

# Path: users/views.py
# def request_login(request):
#     messages.add_message(request, messages.INFO,
#                          "You must be logged in to do this")
#     return HttpResponseRedirect(reverse('frontpage'))
# 
# Path: notifications/models.py
# class Notification(models.Model):
#     NOTIFICATION_TYPES = (
#         ("proposal_response", ""),
#         ("proposal_comment", ""),
#         ("proposal_amendment", ""),
#         ("comment_reply", ""),
#         ("student_council_soon", ""),
#         ("comment_hidden", ""),
#         ("proposal_hidden", ""),
#         ("proposal_vote_up", ""),
#         ("proposal_vote_down", ""),
#         ("comment_vote_up", ""),
#         ("comment_vote_down", ""),
#         ("new_proposal", "")
#     )
# 
#     recipient = models.ForeignKey(settings.AUTH_USER_MODEL,
#                                   related_name="notifications")
#     type = models.CharField(max_length=50,
#                             choices=NOTIFICATION_TYPES,
#                             blank=False)
#     object_id = models.PositiveIntegerField()
#     content_type = models.ForeignKey(ContentType)
#     content = GenericForeignKey()
#     unread = models.BooleanField(default=True)
#     has_been_emailed = models.BooleanField(default=False)
#     created_at = models.DateTimeField(auto_now_add=True)
# 
#     objects = NotificationManager()
# 
#     def mark_as_read(self):
#         self.unread = False
#         self.save()
# 
#     def mark_as_emailed(self):
#         self.has_been_emailed = True
#         self.save()


# Path: notifications/views.py
from collections import Counter
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from users.views import request_login
from .models import Notification





def notifications(request):
    if not request.user.is_authenticated():
        request_login(request)
        return HttpResponseRedirect(reverse("frontpage"))
    else:
        template = "notifications.html"

        if request.is_ajax():
            template = "popover_notifications.html"

        unread = Notification.objects.get_unread(request.user)

        read = Notification.objects.get_read(request.user)