Example #1
0
 def test_notification_mark_unseen(self):
     self.assertFalse(self.notification.seen)
     ns = NotificationSet.get_unread(self.teacher)
     self.assertEqual(ns.count, 1)
     ns = NotificationSet.get_course(self.course_instance, self.teacher)
     self.assertEqual(ns.count_and_mark_unseen(), 1)
     self.assertTrue(self.notification in ns.notifications)
     ns = NotificationSet.get_unread(self.teacher)
     self.assertEqual(ns.count, 0)
     ns = NotificationSet.get_course(self.course_instance, self.teacher)
     self.assertEqual(ns.count, 1)
     self.assertEqual(ns.count_and_mark_unseen(), 0)
Example #2
0
    def test_notification_unread_count(self):

        self.notification1 = Notification.objects.create(
            subject="test1",
            notification="testNotification1",
            sender=self.superuser_profile,
            recipient=self.student_profile,
            course_instance=self.course_instance
        )

        self.notification2 = Notification.objects.create(
            subject="test2",
            notification="testNotification2",
            sender=self.superuser_profile,
            recipient=self.teacher_profile,
            course_instance=self.course_instance
        )

        self.notification3 = Notification.objects.create(
            subject="test3",
            notification="testNotification3",
            sender=self.superuser_profile,
            recipient=self.student_profile,
            course_instance=self.course_instance2
        )

        self.notification4 = Notification.objects.create(
            subject="test4",
            notification="testNotification4",
            sender=self.superuser_profile,
            recipient=self.teacher_profile,
            course_instance=self.course_instance
        )

        self.notification5 = Notification.objects.create(
            subject="test5",
            notification="testNotification5",
            sender=self.superuser_profile,
            recipient=self.student_profile,
            course_instance=self.course_instance2
        )
        self.notification.seen = True
        self.notification.save()
        unread = NotificationSet.get_unread(self.student)
        self.assertEqual(3, unread.count)
        unread = NotificationSet.get_unread(self.teacher)
        self.assertEqual(2, unread.count)
        unread = NotificationSet.get_unread(self.superuser)
        self.assertEqual(0, unread.count)
Example #3
0
def _unread_messages(context):
    unread = []
    user = _context_user(context)
    if user:
        unread = NotificationSet.get_unread(user)
    return {
        "unread": unread,
    }
Example #4
0
def _unread_messages(context):
    unread = []
    message = ""
    user = _context_user(context)
    if user:
        unread = NotificationSet.get_unread(user)
        message = ungettext('new notification', 'new notifications',
                            unread.count)
    return {
        "unread": unread,
        "unread_message": message,
    }
Example #5
0
def _unread_messages(context):
    unread = []
    message = ""
    user = _context_user(context)
    if user:
        unread = NotificationSet.get_unread(user)
        message = ungettext(
            'new notification',
            'new notifications',
            unread.count
        )
    return {
        "unread": unread,
        "unread_message": message,
    }
Example #6
0
def notification_count(context):
    user = _context_user(context)
    if user and "instance" in context:
        return NotificationSet.get_course_new_count(context["instance"], user)
    return 0
Example #7
0
def notification_count(context):
    user = _context_user(context)
    if user and "instance" in context:
        return NotificationSet.get_course_new_count(context["instance"], user)
    return 0