def test_no_score(self): """ Run the engagement calculation for a user in a course who has no score """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) with patch('social_engagement.engagement._get_user_social_stats' ) as mock_func: mock_func.return_value = { 'num_threads': 0, 'num_comments': 0, 'num_replies': 0, 'num_upvotes': 0, 'num_thread_followers': 0, 'num_comments_generated': 0, } update_user_engagement_score(self.course.id, self.user.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id) self.assertEqual(leaderboard_position['score'], 0) self.assertEqual(leaderboard_position['position'], 0) self.assertEqual(get_notifications_count_for_user(self.user.id), 0)
def test_management_command_course(self): """ Verify that we get None back """ self.assertIsNone(StudentSocialEngagementScore.get_user_engagement_score(self.course.id, self.user.id)) self.assertIsNone(StudentSocialEngagementScore.get_user_engagement_score(self.course.id, self.user2.id)) self.assertEqual(get_notifications_count_for_user(self.user.id), 0) self.assertEqual(get_notifications_count_for_user(self.user2.id), 0) with patch('social_engagement.engagement._get_user_social_stats') as mock_func: mock_func.return_value = { 'num_threads': 1, 'num_comments': 1, 'num_replies': 1, 'num_upvotes': 1, 'num_thread_followers': 1, 'num_comments_generated': 1, } Command().handle(course_ids=[self.course.id]) # shouldn't be anything in there because course is closed leaderboard = StudentSocialEngagementScore.generate_leaderboard(self.course.id) self.assertEqual(len(leaderboard), 2) leaderboard = StudentSocialEngagementScore.generate_leaderboard(self.course2.id) self.assertEqual(len(leaderboard), 0) self.assertEqual(get_notifications_count_for_user(self.user.id), 0) self.assertEqual(get_notifications_count_for_user(self.user2.id), 0)
def test_mark_all_as_read(self): """ Verify proper behavior when marking user notifications as read/unread """ for __ in range(10): msg = NotificationMessage(namespace="test-runner", msg_type=self.msg_type, payload={"foo": "bar"}) publish_notification_to_user(self.test_user_id, msg) # make sure we have 10 unreads before we do anything else self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": False, "unread": True}), 10 ) # now mark msg as read by this user mark_all_user_notification_as_read(self.test_user_id) # shouldn't be counted in unread counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": False, "unread": True}), 0 ) # Should be counted in read counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": True, "unread": False}), 10 )
def test_marking_read_state(self): """ Verify proper behavior when marking notfications as read/unread """ msg = NotificationMessage(namespace="test-runner", msg_type=self.msg_type, payload={"foo": "bar"}) # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # now mark msg as read by this user mark_notification_read(self.test_user_id, sent_user_msg.msg.id) # shouldn't be counted in unread counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": False, "unread": True}), 0 ) # Should be counted in read counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": True, "unread": False}), 1 ) # now mark msg as unread by this user mark_notification_read(self.test_user_id, sent_user_msg.msg.id, read=False) # Should be counted in unread counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": False, "unread": True}), 1 ) # Shouldn't be counted in read counts self.assertEquals( get_notifications_count_for_user(self.test_user_id, filters={"read": True, "unread": False}), 0 )
def test_check_notifications(self): """ Save a CourseModuleCompletion and fetch it again """ module = self.get_module_for_user(self.user, self.course, self.problem4) module.system.publish(module, 'progress', {}) completion_fetch = CourseModuleCompletion.objects.get( user=self.user.id, course_id=self.course.id, content_id=self.problem4.location) self.assertIsNotNone(completion_fetch) # since we are alone, then we should be listed as first self.assertEqual(get_notifications_count_for_user(self.user.id), 1) # progressing on a 2nd item, shouldn't change our positions, because # we're the only one in this course module = self.get_module_for_user(self.user, self.course, self.problem5) module.system.publish(module, 'progress', {}) # since we are alone, then we should be listed as first self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_course_bulk_notification_tests(self): # create new users and enroll them in the course. startup.startup_notification_subsystem() test_user_1 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id) test_user_2 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id) notification_type = get_notification_type(u'open-edx.studio.announcements.new-announcement') course = modulestore().get_course(self.course.id, depth=0) notification_msg = NotificationMessage( msg_type=notification_type, namespace=unicode(self.course.id), payload={ '_schema_version': '1', 'course_name': course.display_name, } ) # Send the notification_msg to the Celery task publish_course_notifications_task.delay(self.course.id, notification_msg) # now the enrolled users should get notification about the # course update where they are enrolled as student. self.assertTrue(get_notifications_count_for_user(test_user_1.id), 1) self.assertTrue(get_notifications_count_for_user(test_user_2.id), 1)
def test_no_score(self): """ Run the engagement calculation for a user in a course who has no score """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) with patch('social_engagement.engagement._get_user_social_stats') as mock_func: mock_func.return_value = { 'num_threads': 0, 'num_comments': 0, 'num_replies': 0, 'num_upvotes': 0, 'num_thread_followers': 0, 'num_comments_generated': 0, } update_user_engagement_score(self.course.id, self.user.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id ) self.assertEqual( leaderboard_position['score'], 0 ) self.assertEqual( leaderboard_position['position'], 0 ) self.assertEqual(get_notifications_count_for_user(self.user.id), 0)
def test_marking_read_state(self): """ Verify proper behavior when marking notfications as read/unread """ msg = NotificationMessage(namespace='test-runner', msg_type=self.msg_type, payload={'foo': 'bar'}) # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # now mark msg as read by this user mark_notification_read(self.test_user_id, sent_user_msg.msg.id) # shouldn't be counted in unread counts self.assertEquals( get_notifications_count_for_user( self.test_user_id, filters={ 'read': False, 'unread': True, }, ), 0) # Should be counted in read counts self.assertEquals( get_notifications_count_for_user( self.test_user_id, filters={ 'read': True, 'unread': False, }, ), 1) # now mark msg as unread by this user mark_notification_read(self.test_user_id, sent_user_msg.msg.id, read=False) # Should be counted in unread counts self.assertEquals( get_notifications_count_for_user( self.test_user_id, filters={ 'read': False, 'unread': True, }, ), 1) # Shouldn't be counted in read counts self.assertEquals( get_notifications_count_for_user( self.test_user_id, filters={ 'read': True, 'unread': False, }, ), 0)
def test_multiple_users(self): """ See if it works with more than one enrollee """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) self.assertEqual(get_notifications_count_for_user(self.user2.id), 0) with patch('social_engagement.engagement._get_user_social_stats' ) as mock_func: mock_func.return_value = { 'num_threads': 1, 'num_comments': 1, 'num_replies': 1, 'num_upvotes': 1, 'num_thread_followers': 1, 'num_comments_generated': 1, } update_user_engagement_score(self.course.id, self.user.id) with patch('social_engagement.engagement._get_user_social_stats' ) as mock_func: mock_func.return_value = { 'num_threads': 2, 'num_comments': 2, 'num_replies': 2, 'num_upvotes': 2, 'num_thread_followers': 2, 'num_comments_generated': 2, } update_user_engagement_score(self.course.id, self.user2.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id) self.assertEqual(leaderboard_position['score'], 85) # user should be in place #2 self.assertEqual(leaderboard_position['position'], 2) self.assertEqual(get_notifications_count_for_user(self.user.id), 1) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user2.id) self.assertEqual(leaderboard_position['score'], 170) # user2 should be in place #1 self.assertEqual(leaderboard_position['position'], 1) self.assertEqual(get_notifications_count_for_user(self.user2.id), 1)
def test_multiple_users(self): """ See if it works with more than one enrollee """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) self.assertEqual(get_notifications_count_for_user(self.user2.id), 0) stats = ( self.DEFAULT_STATS, { 'num_threads': 2, 'num_comments': 2, 'num_replies': 2, 'num_upvotes': 2, 'num_thread_followers': 2, 'num_comments_generated': 2, } ) with patch('social_engagement.engagement._get_course_social_stats') as mock_func: mock_func.return_value = zip(self.user_ids, stats) update_course_engagement(self.course.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id ) self.assertEqual(leaderboard_position['score'], 85) # user should be in place #2 self.assertEqual(leaderboard_position['position'], 2) self.assertEqual(get_notifications_count_for_user(self.user.id), 1) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user2.id ) self.assertEqual( leaderboard_position['score'], 170 ) # user2 should be in place #1 self.assertEqual( leaderboard_position['position'], 1 ) self.assertEqual(get_notifications_count_for_user(self.user2.id), 1)
def test_mark_all_as_read(self): """ Verify proper behavior when marking user notifications as read/unread """ for __ in range(10): msg = NotificationMessage( namespace='test-runner', msg_type=self.msg_type, payload={ 'foo': 'bar' } ) publish_notification_to_user(self.test_user_id, msg) # make sure we have 10 unreads before we do anything else self.assertEqual( get_notifications_count_for_user( self.test_user_id, filters={ 'read': False, 'unread': True, }, ), 10 ) # now mark msg as read by this user mark_all_user_notification_as_read(self.test_user_id) # shouldn't be counted in unread counts self.assertEqual( get_notifications_count_for_user( self.test_user_id, filters={ 'read': False, 'unread': True, }, ), 0 ) # Should be counted in read counts self.assertEqual( get_notifications_count_for_user( self.test_user_id, filters={ 'read': True, 'unread': False, }, ), 10 )
def test_update_engagement_score(self): """ Basic update operation """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) StudentSocialEngagementScore.save_user_engagement_score(self.course.id, self.user.id, 10) # then update StudentSocialEngagementScore.save_user_engagement_score(self.course.id, self.user.id, 20) # read it back self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id )['score'], 20 ) # confirm there are two entries in the History table self.assertEqual( StudentSocialEngagementScoreHistory.objects.filter( course_id=self.course.id, user__id=self.user.id ).count(), 2 ) self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id )['position'], 1 ) # look at the leaderboard data = StudentSocialEngagementScore.generate_leaderboard(self.course.id) self.assertIsNotNone(data['queryset']) self.assertEqual(len(data['queryset']), 1) self.assertEqual(data['total_user_count'], 2) self.assertEqual(data['course_avg'], 10) self.assertEqual(data['queryset'][0].user.id, self.user.id) self.assertEqual(data['queryset'][0].score, 20) # confirm there is a just a single notification was generated self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_notifications_publishing(self): initialize_notifications() # assert user has no notifications self.assertEqual(get_notifications_count_for_user(self.user.id), 0) course = self.setup_course_with_grading() module = self.get_module_for_user(self.user, course, course.homework_assignment) grade_dict = {'value': 0.5, 'max_value': 1, 'user_id': self.user.id} module.system.publish(module, 'grade', grade_dict) # user should have had a notification published as he/her is now in the # leaderboard self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_publish_notification(self): """ Go through and set up a notification and publish it """ msg = NotificationMessage( namespace='test-runner', msg_type=self.msg_type, payload={ 'foo': 'bar' } ) # make sure it asserts that user_id is an integer with self.assertRaises(ContractNotRespected): publish_notification_to_user('bad-id', msg) # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # make sure type checking is happening with self.assertRaises(ContractNotRespected): get_notifications_count_for_user('bad-type') # now query back the notification to make sure it got stored # and we can retrieve it self.assertEqual( get_notifications_count_for_user(self.test_user_id), 1 ) # make sure it asserts that user_id is an integer with self.assertRaises(ContractNotRespected): get_notifications_for_user('bad-id') notifications = get_notifications_for_user(self.test_user_id) self.assertTrue(isinstance(notifications, list)) self.assertEqual(len(notifications), 1) self.assertTrue(isinstance(notifications[0], UserNotification)) read_user_msg = notifications[0] self.assertEqual(read_user_msg.user_id, self.test_user_id) self.assertIsNone(read_user_msg.read_at) # should be unread self.assertEqual(read_user_msg, sent_user_msg) self.assertEqual(read_user_msg.msg, sent_user_msg.msg)
def test_multipayload(self): """ Test that a channel will use the right payload """ msg = NotificationMessage(namespace="test-runner", msg_type=self.msg_type, payload={"foo": "bar"}) msg.add_payload({"one": "two"}, channel_name="durable") # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # now query back the notification to make sure it got stored # and we can retrieve it self.assertEquals(get_notifications_count_for_user(self.test_user_id), 1) notifications = get_notifications_for_user(self.test_user_id) self.assertTrue(isinstance(notifications, list)) self.assertEqual(len(notifications), 1) self.assertTrue(isinstance(notifications[0], UserNotification)) read_user_msg = notifications[0] self.assertEqual(read_user_msg.user_id, self.test_user_id) self.assertIsNone(read_user_msg.read_at) # should be unread self.assertEqual(read_user_msg, sent_user_msg) # make sure the message that got persisted contains only # the default payload self.assertEqual(read_user_msg.msg.payload, msg.get_payload(channel_name="durable"))
def test_multipayload(self): """ Test that a channel will use the right payload """ msg = NotificationMessage(namespace='test-runner', msg_type=self.msg_type, payload={'foo': 'bar'}) msg.add_payload({'one': 'two'}, channel_name='durable') # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # now query back the notification to make sure it got stored # and we can retrieve it self.assertEquals(get_notifications_count_for_user(self.test_user_id), 1) notifications = get_notifications_for_user(self.test_user_id) self.assertTrue(isinstance(notifications, list)) self.assertEqual(len(notifications), 1) self.assertTrue(isinstance(notifications[0], UserNotification)) read_user_msg = notifications[0] self.assertEqual(read_user_msg.user_id, self.test_user_id) self.assertIsNone(read_user_msg.read_at) # should be unread self.assertEqual(read_user_msg, sent_user_msg) # make sure the message that got persisted contains only # the default payload self.assertEqual(read_user_msg.msg.payload, msg.get_payload(channel_name='durable'))
def test_save_first_engagement_score(self): """ Basic write operation """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) StudentSocialEngagementScore.save_user_engagement_score(self.course.id, self.user.id, 10) # read it back self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id )['score'], 10 ) # confirm there is an entry in the History table self.assertEqual( StudentSocialEngagementScoreHistory.objects.filter( course_id=self.course.id, user__id=self.user.id ).count(), 1 ) self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id )['position'], 1 ) # look at the leaderboard leaderboard = StudentSocialEngagementScore.generate_leaderboard(self.course.id) self.assertIsNotNone(leaderboard) self.assertEqual(len(leaderboard), 1) self.assertEqual(leaderboard[0]['user__id'], self.user.id) self.assertEqual(leaderboard[0]['score'], 10) # confirm there is a notification was generated self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_update_user_engagement_score(self): """ Run the engagement calculation for a user in a course """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) with patch('social_engagement.engagement._get_course_social_stats' ) as mock_func: mock_func.return_value = ((self.user.id, self.DEFAULT_STATS), ) update_course_engagement(self.course.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id) self.assertEqual(leaderboard_position['score'], 85) self.assertEqual(leaderboard_position['position'], 1) self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_update_user_engagement_score(self): """ Run the engagement calculation for a user in a course """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) with patch('social_engagement.engagement._get_course_social_stats') as mock_func: mock_func.return_value = ((self.user.id, self.DEFAULT_STATS),) update_course_engagement(self.course.id) leaderboard_position = StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id ) self.assertEqual(leaderboard_position['score'], 85) self.assertEqual(leaderboard_position['position'], 1) self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_notifications_enabled_when_new_updates_in_course(self): # create new users and enroll them in the course. test_user_1 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id) test_user_2 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id) content = 'Test update' payload = {'content': content, 'date': 'Feb 19, 2015'} url = self.create_update_url() resp = self.client.ajax_post(url, payload, REQUEST_METHOD="POST") self.assertEqual(resp.status_code, 200) self.assertHTMLEqual(content, json.loads(resp.content)['content']) # now the enrolled users should get notification about the # course update where they are enrolled as student. self.assertTrue(get_notifications_count_for_user(test_user_1.id), 1) self.assertTrue(get_notifications_count_for_user(test_user_2.id), 1)
def test_update_engagement_score(self): """ Basic update operation """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) StudentSocialEngagementScore.save_user_engagement_score( self.course.id, self.user.id, 10) # then update StudentSocialEngagementScore.save_user_engagement_score( self.course.id, self.user.id, 20) # read it back self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id)['score'], 20) # confirm there are two entries in the History table self.assertEqual( StudentSocialEngagementScoreHistory.objects.filter( course_id=self.course.id, user__id=self.user.id).count(), 2) self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, self.user.id)['position'], 1) # look at the leaderboard course_avg, enrollment_count, leaderboard = StudentSocialEngagementScore.generate_leaderboard( self.course.id) self.assertIsNotNone(leaderboard) self.assertEqual(len(leaderboard), 1) self.assertEqual(enrollment_count, 2) self.assertEqual(course_avg, 10) self.assertEqual(leaderboard[0]['user__id'], self.user.id) self.assertEqual(leaderboard[0]['score'], 20) # confirm there is a just a single notification was generated self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_notifications_enabled_when_new_updates_in_course(self): # create new users and enroll them in the course. test_user_1 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id) test_user_2 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id) content = 'Test update' payload = {'content': content, 'date': 'Feb 19, 2015'} url = self.create_update_url() resp = self.client.ajax_post( url, payload, REQUEST_METHOD="POST" ) self.assertEqual(resp.status_code, 200) self.assertHTMLEqual(content, json.loads(resp.content)['content']) # now the enrolled users should get notification about the # course update where they are enrolled as student. self.assertTrue(get_notifications_count_for_user(test_user_1.id), 1) self.assertTrue(get_notifications_count_for_user(test_user_2.id), 1)
def test_publish_notification(self): """ Go through and set up a notification and publish it """ msg = NotificationMessage(namespace="test-runner", msg_type=self.msg_type, payload={"foo": "bar"}) # make sure it asserts that user_id is an integer with self.assertRaises(ContractNotRespected): publish_notification_to_user("bad-id", msg) # now do happy path sent_user_msg = publish_notification_to_user(self.test_user_id, msg) # make sure type checking is happening with self.assertRaises(ContractNotRespected): get_notifications_count_for_user("bad-type") # now query back the notification to make sure it got stored # and we can retrieve it self.assertEquals(get_notifications_count_for_user(self.test_user_id), 1) # make sure it asserts that user_id is an integer with self.assertRaises(ContractNotRespected): get_notifications_for_user("bad-id") notifications = get_notifications_for_user(self.test_user_id) self.assertTrue(isinstance(notifications, list)) self.assertEqual(len(notifications), 1) self.assertTrue(isinstance(notifications[0], UserNotification)) read_user_msg = notifications[0] self.assertEqual(read_user_msg.user_id, self.test_user_id) self.assertIsNone(read_user_msg.read_at) # should be unread self.assertEqual(read_user_msg, sent_user_msg) self.assertEqual(read_user_msg.msg, sent_user_msg.msg)
def test_save_first_engagement_score(self): """ Basic write operation """ self.assertEqual(get_notifications_count_for_user(self.user.id), 0) StudentSocialEngagementScore.save_user_engagement_score( self.course.id, self.user.id, 10) # read it back self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id)['score'], 10) # confirm there is an entry in the History table self.assertEqual( StudentSocialEngagementScoreHistory.objects.filter( course_id=self.course.id, user__id=self.user.id).count(), 1) self.assertEqual( StudentSocialEngagementScore.get_user_leaderboard_position( self.course.id, user_id=self.user.id)['position'], 1) # look at the leaderboard data = StudentSocialEngagementScore.generate_leaderboard( self.course.id) self.assertIsNotNone(data['queryset']) self.assertEqual(len(data['queryset']), 1) self.assertEqual(data['total_user_count'], 2) self.assertEqual(data['course_avg'], 5) self.assertEqual(data['queryset'][0].user.id, self.user.id) self.assertEqual(data['queryset'][0].score, 10) # confirm there is a notification was generated self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def test_check_notifications(self): """ Save a CourseModuleCompletion and fetch it again """ module = self.get_module_for_user(self.user, self.course, self.problem4) module.system.publish(module, 'progress', {}) completion_fetch = CourseModuleCompletion.objects.get( user=self.user.id, course_id=self.course.id, content_id=self.problem4.location ) self.assertIsNotNone(completion_fetch) # since we are alone, then we should be listed as first self.assertEqual(get_notifications_count_for_user(self.user.id), 1) # progressing on a 2nd item, shouldn't change our positions, because # we're the only one in this course module = self.get_module_for_user(self.user, self.course, self.problem5) module.system.publish(module, 'progress', {}) # since we are alone, then we should be listed as first self.assertEqual(get_notifications_count_for_user(self.user.id), 1)
def get(self, request): """ HTTP GET Handler """ try: filters, __ = _get_filter_and_options(request) except ValueError: return Response({}, status.HTTP_400_BAD_REQUEST) cnt = get_notifications_count_for_user(int(request.user.id), filters=filters) return Response({ 'count': cnt, }, status=status.HTTP_200_OK)
def get(self, request): """ HTTP GET Handler """ try: filters, __ = _get_filter_and_options(request) except ValueError: return Response({}, status.HTTP_400_BAD_REQUEST) cnt = get_notifications_count_for_user( int(request.user.id), filters=filters ) return Response( { 'count': cnt, }, status=status.HTTP_200_OK )