Browse Source

Active threads page

Ralfp 12 years ago
parent
commit
ad4d6d4129
5 changed files with 61 additions and 19 deletions
  1. 1 0
      misago/urls.py
  2. 9 0
      misago/views.py
  3. 48 0
      templates/sora/active_threads.html
  4. 2 2
      templates/sora/userbar.html
  5. 1 17
      templates/sora/watched.html

+ 1 - 0
misago/urls.py

@@ -21,6 +21,7 @@ urlpatterns = patterns('',
     url(r'^tos/$', 'misago.tos.views.forum_tos', name="tos"),
     url(r'^tos/$', 'misago.tos.views.forum_tos', name="tos"),
     url(r'^read/$', 'misago.views.read_all', name="read_all"),
     url(r'^read/$', 'misago.views.read_all', name="read_all"),
     url(r'^forum-map/$', 'misago.views.forum_map', name="forum_map"),
     url(r'^forum-map/$', 'misago.views.forum_map', name="forum_map"),
+    url(r'^active-threads/$', 'misago.views.active_threads', name="active_threads"),
 )
 )
 
 
 # Include admin patterns
 # Include admin patterns

+ 9 - 0
misago/views.py

@@ -125,6 +125,15 @@ def forum_map(request):
                                             context_instance=RequestContext(request));
                                             context_instance=RequestContext(request));
 
 
 
 
+def active_threads(request):
+    cutoff = timezone.now() - timedelta(days=2)
+    return request.theme.render_to_response('active_threads.html',
+                                            {
+                                             'threads': Thread.objects.filter(forum_id__in=request.acl.threads.get_readable_forums(request.acl)).filter(deleted=False).filter(moderated=False).filter(last__gte=cutoff).order_by('-score').prefetch_related('start_poster', 'last_poster', 'forum')[:50]
+                                             },
+                                            context_instance=RequestContext(request));
+
+
 def redirect_message(request, message, type='info', owner=None):
 def redirect_message(request, message, type='info', owner=None):
     request.messages.set_flash(message, type, owner)
     request.messages.set_flash(message, type, owner)
     return redirect(reverse('index'))
     return redirect(reverse('index'))

+ 48 - 0
templates/sora/active_threads.html

@@ -0,0 +1,48 @@
+{% extends "sora/layout.html" %}
+{% load i18n %}
+{% import "sora/macros.html" as macros with context %}
+
+{% block title %}{{ macros.page_title(title=_('Active Threads')) }}{% endblock %}
+
+{% block content %}
+<div class="page-header">
+  <h1>{% trans %}Active Threads{% endtrans %}</h1>
+</div>
+{% if threads %}
+<p class="lead">{% trans %}Following threads are currently experiencing most activity:{% endtrans %}</p>
+<ul class="unstyled shorts-list">
+{% for row in threads|batch(2, '') %}
+  <li>
+    <div class="row">
+      {% for thread in row %}{% if thread %}
+      <div class="span6">
+        <img src="{% if thread.start_post_id %}{{ thread.start_poster.get_avatar(36) }}{% else %}{{ macros.avatar_guest(24) }}{% endif %}" class="avatar tooltip-top" title="{% trans username=thread.start_poster_name %}Thread started by {{ username }}{% endtrans %}">
+        <p class="title">
+          <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="hover-opacity tooltip-top" title="{% trans %}Jump to thread start{% endtrans %}"><i class="icon-asterisk"></i></a>
+          <a href="{% url 'thread_last' thread=thread.pk, slug=thread.slug %}" class="jump jump-last tooltip-top" title="{% trans %}Jump to latest reply{% endtrans %}">{% if not thread.is_read %}<strong>{{ thread.name }}</strong>{% else %}{{ thread.name }}{% endif %}</a>
+        </p>
+        <p class="location">{% trans forum=forum(thread.forum), starter=username(thread.start_poster_id, thread.start_poster_name, thread.start_poster_slug), start=thread.start|reldate %}Thread started by {{ starter }} in {{ forum }} on {{ start }}.{% endtrans %}</p>
+      </div>
+      {% endif %}{% endfor %}
+    </div>
+  </li>
+{% endfor %}
+</ul>
+{% else %}
+<p class="lead">{% trans %}Looks like there are no active threads.{% endtrans %}</p>
+{% endif %}
+{%- endblock %}
+
+
+{% macro forum(forum) -%}
+<a href="{% url 'forum' forum=forum.pk, slug=forum.slug %}">{{ forum.name }}</a>
+{%- endmacro %}
+
+
+{% macro username(id, username, slug) -%}
+{%- if id -%}
+<a href="{% url 'user' user=id, username=slug %}">{{ username }}</a>
+{%- else -%}
+{{ username }}
+{%- endif -%}
+{%- endmacro %}

+ 2 - 2
templates/sora/userbar.html

@@ -3,11 +3,11 @@
     <div class="container">
     <div class="container">
       <ul class="nav">{% if user.is_authenticated() %}
       <ul class="nav">{% if user.is_authenticated() %}
         {#<li><a href="#" title="{% trans %}Active Reports{% endtrans %}" class="tooltip-bottom"><i class="icon-warning-sign"></i><span class="stat">5</span></a></li>#}
         {#<li><a href="#" title="{% trans %}Active Reports{% endtrans %}" class="tooltip-bottom"><i class="icon-warning-sign"></i><span class="stat">5</span></a></li>#}
-        <li><a href="{% url 'alerts' %}" title="{% if user.alerts %}{% trans %}You have new notifications!{% endtrans %}{% else %}{% trans %}Your Notifications{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-fire"></i>{% if user.alerts %}<span class="stat">{{ user.alerts }}</span>{% endif %}</a></li>
+        <li><a href="{% url 'alerts' %}" title="{% if user.alerts %}{% trans %}You have new notifications!{% endtrans %}{% else %}{% trans %}Your Notifications{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-asterisk"></i>{% if user.alerts %}<span class="stat">{{ user.alerts }}</span>{% endif %}</a></li>
         {#<li><a href="#" title="{% trans %}Private messages{% endtrans %}" class="tooltip-bottom"><i class="icon-inbox"></i><span class="stat">2</span></a></li>#}
         {#<li><a href="#" title="{% trans %}Private messages{% endtrans %}" class="tooltip-bottom"><i class="icon-inbox"></i><span class="stat">2</span></a></li>#}
         <li><a href="{% url 'newsfeed' %}" title="{% trans %}Your News Feed{% endtrans %}" class="tooltip-bottom"><i class="icon-signal"></i></a></li>
         <li><a href="{% url 'newsfeed' %}" title="{% trans %}Your News Feed{% endtrans %}" class="tooltip-bottom"><i class="icon-signal"></i></a></li>
         <li><a href="{% url 'watched_threads' %}" title="{% trans %}Threads you are watching{% endtrans %}" class="tooltip-bottom"><i class="icon-bookmark"></i></a></li>{% endif %}
         <li><a href="{% url 'watched_threads' %}" title="{% trans %}Threads you are watching{% endtrans %}" class="tooltip-bottom"><i class="icon-bookmark"></i></a></li>{% endif %}
-        <li><a href="#" title="{% trans %}Today Posts{% endtrans %}" class="tooltip-bottom"><i class="icon-star"></i></a></li>
+        <li><a href="{% url 'active_threads' %}" title="{% trans %}Active Threads{% endtrans %}" class="tooltip-bottom"><i class="icon-fire"></i></a></li>
       </ul>
       </ul>
       <ul class="nav pull-right">{% if user.is_authenticated() %}
       <ul class="nav pull-right">{% if user.is_authenticated() %}
         <li class="user-profile"><a href="{% url 'user' user=user.id, username=user.username_slug %}" title="{% trans %}Go to your profile{% endtrans %}" class="tooltip-bottom"><div><img src="{{ user.get_avatar(28) }}" class="avatar-small" alt=""> {{ user.username }}</div></a></li>
         <li class="user-profile"><a href="{% url 'user' user=user.id, username=user.username_slug %}" title="{% trans %}Go to your profile{% endtrans %}" class="tooltip-bottom"><div><img src="{{ user.get_avatar(28) }}" class="avatar-small" alt=""> {{ user.username }}</div></a></li>

+ 1 - 17
templates/sora/watched.html

@@ -67,23 +67,6 @@
 {% endblock %}
 {% endblock %}
 
 
 
 
-{% block javascripts -%}
-{{ super() }}
-{%- if user.is_authenticated() and list_form %}
-  <script type="text/javascript">
-    $(function () {
-      $('#threads_form').submit(function() {
-        if ($('.check-cell[]:checked').length == 0) {
-          alert("{% trans %}You have to select at least one thread.{% endtrans %}");
-          return false;
-        }
-        return true;
-      });
-    });
-  </script>{% endif %}
-{%- endblock %}
-
-
 {% macro pager() -%}
 {% macro pager() -%}
   <ul class="pager pull-left">
   <ul class="pager pull-left">
     {% if new %}
     {% if new %}
@@ -108,6 +91,7 @@
 <a href="{% url 'forum' forum=forum.pk, slug=forum.slug %}">{{ forum.name }}</a>
 <a href="{% url 'forum' forum=forum.pk, slug=forum.slug %}">{{ forum.name }}</a>
 {%- endmacro %}
 {%- endmacro %}
 
 
+
 {% macro username(id, username, slug) -%}
 {% macro username(id, username, slug) -%}
 {%- if id -%}
 {%- if id -%}
 <a href="{% url 'user' user=id, username=slug %}">{{ username }}</a>
 <a href="{% url 'user' user=id, username=slug %}">{{ username }}</a>