[Oi-commits] r1119 - in trunk: forum templates/forum

oi-commits at pardus.org.tr oi-commits at pardus.org.tr
Sun Mar 9 10:06:12 EET 2008


Author: jnmbk
Date: Sun Mar  9 10:06:12 2008
New Revision: 1119

Modified:
   trunk/forum/views.py
   trunk/templates/forum/forum_detail.html
   trunk/templates/forum/forum_list.html
Log:
Still doesn't work but let's put read messages somewhere... (I think paginator does something there and doesn't return our modified objects to template)

Modified: trunk/forum/views.py
=================================================================
--- trunk/forum/views.py	(original)
+++ trunk/forum/views.py	Sun Mar  9 10:06:12 2008
@@ -32,10 +32,12 @@
             forums += 1
             topics += forum.topics
             posts += forum.posts
-            if forum.forum_latest_post and forum.forum_latest_post.edited > request.session['last_visit']:
-                forum.is_unread = True
+            if forum.forum_latest_post and \
+                    forum.forum_latest_post.edited > request.session['last_visit']\
+                    and not forum_latest_post.topic.id in request.session['read_topics_set']:
+                forum.is_read = False
             else:
-                forum.is_unread = False
+                forum.is_read = True
 
     usercount = User.objects.count()
     currentdate = datetime.now()
@@ -50,10 +52,11 @@
     topics = forum.topic_set.all().order_by('-sticky', '-topic_latest_post')
 
     for topic in topics:
-        if topic.topic_latest_post.edited > request.session['last_visit']:
-            topic.is_unread = True
+        if topic.topic_latest_post.edited > request.session['last_visit'] and \
+                not topic.id in request.session["read_topics_set"]:
+            topic.is_read = False
         else:
-            topic.is_unread = False
+            topic.is_read = True
 
     return object_list(request, topics,
                        template_name = 'forum/forum_detail.html',
@@ -70,10 +73,11 @@
     posts = topic.post_set.all().order_by('created')
     news_list = News.objects.filter(status=1).order_by('-update')[:3]
 
-    session_key = 'visited_'+topic_id
-
-    if request.user.is_authenticated() and not session_key in request.session:
-        request.session[session_key] = True
+    try:
+        request.session["read_topics_set"].add(topic.id)
+    except:
+        request.session["read_topics_set"] = set()
+        request.session["read_topics_set"].add(topic.id)
 
     topic.views += 1
     topic.save()
@@ -344,8 +348,9 @@
     return flood,timeout
 
 def lastvisit_control(request):
-    if not 'last_visit' in request.session:
-        request.session['last_visit'] = datetime.now()
+    if not "last_visit" in request.session:
+        request.session["last_visit"] = datetime.now()
+        request.session["read_topics_set"] = set()
 
 def delete_post(request,forum_slug,topic_id, post_id):
     """ The delete part should be controlled better !"""

Modified: trunk/templates/forum/forum_detail.html
=================================================================
--- trunk/templates/forum/forum_detail.html	(original)
+++ trunk/templates/forum/forum_detail.html	Sun Mar  9 10:06:12 2008
@@ -27,7 +27,7 @@
 
     <div id="topics_item" {% if topic.hidden %}style="opacity: 0.5;"{% endif %}>
         <div id="topics_item_icon"><a href="{{ topic.get_absolute_url }}">{% if topic.locked and not topic.sticky %}<img src="/media/dijital/img/forum/topic_locked.png" border="0" alt="Kilitli Konu" title="Kilitli Konu" />{% endif %}{% if topic.sticky and not topic.locked %}<img src="/media/dijital/img/forum/topic_sticky.png" border="0" alt="Sabit Konu" title="Sabit Konu" />{% endif %}{% if not topic.locked and not topic.sticky %}<img src="/media/dijital/img/forum/eski_konu.gif" border="0" />{% endif %}{% if topic.locked and topic.sticky %}<img src="/media/dijital/img/forum/topic_sticky_locked.png" border="0" alt="Sabit ve Kilitli Konu" title="Sabit ve Kilitli Konu" />{% endif %}</a></div>
-        <div id="topics_item_title">{% if topic.is_unread %}unread{% else %}read{% endif %}<a href="{{ topic.get_absolute_url }}">{{ topic.title|escape }}</a></div>
+        <div id="topics_item_title">{% if not topic.is_read %}un{% endif %}read<a href="{{ topic.get_absolute_url }}">{{ topic.title|escape }}</a></div>
         <div id="topics_item_posts">{{ topic.posts }}</div>
         <div id="topics_item_views">{{ topic.views }}</div>
         <div id="topics_item_lastpost">{{ topic.topic_latest_post.edited|date:"d F Y H:i" }}<br />{{ topic.topic_latest_post.author }} <a href="{{ topic.get_latest_post_url }}"><img src="/media/dijital/img/forum/msg_sim.gif" border="0"/></a></div>

Modified: trunk/templates/forum/forum_list.html
=================================================================
--- trunk/templates/forum/forum_list.html	(original)
+++ trunk/templates/forum/forum_list.html	Sun Mar  9 10:06:12 2008
@@ -27,7 +27,7 @@
             {% else %}
             <div id="category_forums_item" {% if forum.hidden %}style="opacity: 0.5;"{% endif %}>
             <div id="category_forums_item_icon"><img src="/media/dijital/img/forum/eski_konu.gif" /></div>
-            <div id="category_forums_item_title"><a href="{{ forum.get_absolute_url }}">{% if forum.is_unread %}un{% endif %}read{{ forum.name|escape }}</a><br />{{ forum.description }}</div>
+            <div id="category_forums_item_title"><a href="{{ forum.get_absolute_url }}">{% if not forum.is_read %}un{% endif %}read{{ forum.name|escape }}</a><br />{{ forum.description }}</div>
             <div id="category_forums_item_topics">{{ forum.topics }}</div>
             <div id="category_forums_item_posts">{{ forum.posts }}</div>
             <div id="category_forums_item_lastpost">{% if forum.forum_latest_post %}{{ forum.forum_latest_post.edited|date:"d F Y H:i" }}<br />{{ forum.forum_latest_post.author }} <a href="{{ forum.get_latest_post_url }}"><img src="/media/dijital/img/forum/msg_sim.gif" border="0"/></a>{% else %}Henüz ileti yok{% endif %}


More information about the Oi-commits mailing list