diff --git a/discussion/models.py b/discussion/models.py index 0d35eaa..07f612c 100644 --- a/discussion/models.py +++ b/discussion/models.py @@ -302,19 +302,3 @@ def create_or_update_revision(self, instance): self.comment = instance self.text = instance.text super(CommentHistory, self).create_or_update_revision(instance) - - -class UnreadNotification(models.Model): - - user = models.OneToOneField(settings.AUTH_USER_MODEL, verbose_name='user', on_delete=models.CASCADE) - counter = models.IntegerField(null=True, blank=True) - - def save(self, *args, **kwargs): - if not self.pk: - # This is a new unread counter - # All AnswerNotification and TopicNotification will be used to create the first unread counter for this user - # However, counting only the unread TopicNotification instances is enough, since every AnswerNotification also has a row in the TopicNotification table - self.counter = TopicNotification.objects.filter( - user=self.user, - is_read=False).count() - super(UnreadNotification, self).save(*args, **kwargs) diff --git a/discussion/signals.py b/discussion/signals.py index 065f88e..3d33a26 100644 --- a/discussion/signals.py +++ b/discussion/signals.py @@ -1,6 +1,7 @@ from django.db.models.signals import post_save from django.dispatch import receiver -from discussion.models import Comment, CommentHistory, TopicNotification, TopicLike, TopicUse, CommentLike, UnreadNotification +from discussion.models import Comment, CommentHistory, TopicNotification, TopicLike, TopicUse, CommentLike +from courses_notifications.models import unread_notification_increment @receiver(post_save, sender=Comment) @@ -194,17 +195,6 @@ def comment_reaction_created_or_updated(instance, **kwargs): # unread_notification_increment(one_user) -def unread_notification_increment(user): - # Only increment the counter if the user already has a UnreadNotification instance - try: - unread = UnreadNotification.objects.get(user=user) - unread.counter += 1 - unread.save() - except UnreadNotification.DoesNotExist: - pass - - - def topic_viewed(request, topic): # Todo test detail views user = request.user diff --git a/discussion/static/js/discussion-app.js b/discussion/static/js/discussion-app.js index 8712e31..d1e279f 100644 --- a/discussion/static/js/discussion-app.js +++ b/discussion/static/js/discussion-app.js @@ -15,7 +15,8 @@ 'ngAnimate', 'duScroll', 'LocalStorageModule', - 'shared' + 'shared', + 'djangular' ]); // Set new default values for 'duScroll' @@ -55,14 +56,4 @@ otherwise('/'); } ]); - - app.run(function($http, localStorageService) { - $http.defaults.headers.common.Authorization = 'Token ' + localStorageService.get('ujs-ocupa|token'); - }); - - app.service('CurrentUser', ['localStorageService', function (localStorageService) { - console.log(localStorageService.get('ujs-ocupa|currentProfile')); - return localStorageService.get('ujs-ocupa|currentProfile'); - }]); - })(angular);