Browse Source

Code tweaks

Rafał Pitoń 10 years ago
parent
commit
3c7d5d4e31

+ 2 - 2
misago/notifications/views.py

@@ -115,8 +115,8 @@ def read_all(request):
 @deny_guests
 def event_sender(request, resolver_match):
     if request.user.new_notifications:
-        message = ungettext("You have %(notifications)s new notification",
-                            "You have %(notifications)s new notifications",
+        message = ungettext("%(notifications)s new notification",
+                            "%(notifications)s new notifications",
                             request.user.new_notifications)
         message = message % {'notifications': request.user.new_notifications}
     else:

+ 3 - 2
misago/threads/views/generic/forum/threads.py

@@ -30,8 +30,9 @@ class ForumThreads(Threads):
         self._paginator = self._page.paginator
 
         threads = []
-        for thread in pinned_qs:
-            threads.append(thread)
+        if self.fetch_pinned_threads:
+            for thread in pinned_qs:
+                threads.append(thread)
             self.pinned_count += 1
         for thread in self._page.object_list:
             threads.append(thread)

+ 6 - 3
misago/threads/views/generic/threads/threads.py

@@ -9,6 +9,8 @@ __all__ = ['Threads']
 
 
 class Threads(object):
+    fetch_pinned_threads = True
+
     def __init__(self, user):
         self.pinned_count = 0
 
@@ -34,9 +36,10 @@ class Threads(object):
         self._paginator = self._page.paginator
 
         threads = []
-        for thread in pinned_qs:
-            threads.append(thread)
-            self.pinned_count += 1
+        if self.fetch_pinned_threads:
+            for thread in pinned_qs:
+                threads.append(thread)
+                self.pinned_count += 1
         for thread in self._page.object_list:
             threads.append(thread)
 

+ 14 - 2
misago/threads/views/moderatedcontent.py

@@ -1,5 +1,5 @@
 from django.core.exceptions import PermissionDenied
-from django.utils.translation import ugettext as _
+from django.utils.translation import ugettext as _, ungettext
 
 from misago.core.uiviews import uiview
 from misago.users.decorators import deny_guests
@@ -48,6 +48,18 @@ class ModeratedContentView(ThreadsView):
 @deny_guests
 def event_sender(request, resolver_match):
     if request.user.acl['moderated_forums']:
-        return int(request.user.moderated_content)
+        moderated_count = int(request.user.moderated_content)
+        if moderated_count:
+            message = ungettext("%(moderated)s item in moderation",
+                                "%(moderated)s items in moderation",
+                                moderated_count)
+            message = message % {'moderated': moderated_count}
+        else:
+            message = _("Moderated content")
+
+        return {
+            'count': moderated_count,
+            'message': message,
+        }
     else:
         return 0

+ 22 - 0
misago/threads/views/privatethreads.py

@@ -8,7 +8,9 @@ from django.utils.translation import ugettext as _, ungettext
 
 from misago.acl import add_acl
 from misago.core.exceptions import AjaxError
+from misago.core.uiviews import uiview
 from misago.forums.models import Forum
+from misago.users.decorators import deny_guests
 
 from misago.threads import participants
 from misago.threads.events import record_event
@@ -89,6 +91,8 @@ class PrivateThreadsMixin(object):
 
 
 class PrivateThreads(generic.Threads):
+    fetch_pinned_threads = False
+
     def get_queryset(self):
         threads_qs = Forum.objects.private_threads().thread_set
         return exclude_invisible_private_threads(threads_qs, self.user)
@@ -211,6 +215,24 @@ class PrivateThreadActions(generic.ThreadActions):
             thread.save(update_fields=['has_events'])
 
 
+@uiview("private_threads")
+@deny_guests
+def event_sender(request, resolver_match):
+    if request.user.unread_private_threads:
+        message = ungettext("%(threads)s unread private thread",
+                            "%(threads)s unread private threads",
+                            request.user.unread_private_threads)
+        message = message % {'threads': request.user.unread_private_threads}
+    else:
+        message = _("Private threads")
+
+    return {
+        'count': request.user.unread_private_threads,
+        'message': message,
+    }
+    return request.user.unread_private_threads
+
+
 @private_threads_view
 class ThreadView(PrivateThreadsMixin, generic.ThreadView):
     template = 'misago/privatethreads/thread.html'