[Oi-commits] r1471 - in branches/stable: . forum media/hackergotchi

oi-commits at pardus.org.tr oi-commits at pardus.org.tr
Mon Jun 9 19:20:54 EEST 2008


Author: jnmbk
Date: Mon Jun  9 19:20:54 2008
New Revision: 1471

Modified:
   branches/stable/forum/views.py
   branches/stable/media/hackergotchi/akinomeroglu.png
   branches/stable/settings.py
Log:
merge last changes

Modified: branches/stable/forum/views.py
=================================================================
--- branches/stable/forum/views.py	(original)
+++ branches/stable/forum/views.py	Mon Jun  9 19:20:54 2008
@@ -46,13 +46,16 @@
 
             # read/unread stuff
             if request.user.is_authenticated():
-                if forum.id in request.session["read_forum_dict"] and\
-                        forum.forum_latest_post.edited < request.session["read_forum_dict"][forum.id]:
+                try:
+                    if forum.id in request.session["read_forum_dict"] and\
+                            forum.forum_latest_post.edited < request.session["read_forum_dict"][forum.id]:
+                        forum.is_read = True
+                    elif not forum.forum_latest_post or request.session["last_visit"] > forum.forum_latest_post.edited:
+                        forum.is_read = True
+                    else:
+                        forum.is_read = False
+                except AttributeError, ObjectDoesNotExist:
                     forum.is_read = True
-                elif not forum.forum_latest_post or request.session["last_visit"] > forum.forum_latest_post.edited:
-                    forum.is_read = True
-                else:
-                    forum.is_read = False
 
     usercount = User.objects.count()
     currentdate = datetime.now()
@@ -342,9 +345,9 @@
         if form.is_valid() and not flood:
             topic = Topic(forum=forum,
                           title=form.cleaned_data['title'])
-        #tags
             topic.save()
 
+            # add tags
             for tag in form.cleaned_data['tags']:
                 t=Tag.objects.get(name=tag)
                 topic.tags.add(t)
@@ -506,24 +509,27 @@
             forum.posts -= topic.posts
             forum2_object.topics += 1
             forum2_object.posts += topic.posts
-            #TODO: Check if target forum has some topics or not
-            # Change forum's latest post if necessary
+            # Change source forum's latest post if necessary
             if forum.forum_latest_post == topic.topic_latest_post:
-                # look for new latest (It shouldn't be hidden)
-                topics = forum.topic_set.all()
-                posts = []
-                for t in topics:
-                    lastpost = t.post_set.filter(hidden=False).order_by("-created")[0]
-                    posts.append((lastpost.created, lastpost.id))
-
-                newlatestpost = posts[0]
-                for post in posts:
-                    if post[0] > newlatestpost[0]:
-                        newlatestpost = post
-                newlatestpost = Post.objects.get(id=newlatestpost[1])
+                # if there's no message left in source forum, clear it
+                if forum.topics < 1:
+                    forum.forum_latest_post = None
+                else:
+                    # look for new latest (It shouldn't be hidden)
+                    topics = forum.topic_set.all()
+                    newlatestpost = topics[0].topic_latest_post
+                    for t in topics:
+                        latestpost = t.topic_latest_post
+                        if latestpost.edited > newlatestpost.edited:
+                            newlatestpost = latestpost
+                    forum.forum_latest_post = newlatestpost
+
                 # check if this is the latest in new forum
-                if forum2_object.forum_latest_post.created < newlatestpost.created:
-                    forum2_object.forum_latest_post = newlatestpost
+                if forum2_object.topics > 1:
+                    if forum2_object.forum_latest_post.edited < topic.topic_latest_post.edited:
+                        forum2_object.forum_latest_post =  topic.topic_latest_post
+                else:
+                    forum2_object.forum_latest_post = topic.topic_latest_post
             # save them
             topic.save()
             forum.save()
@@ -535,7 +541,6 @@
             error = "Forum geçerli değil!"
             return render_response(request, 'forum/move.html', locals())
     else:
-        #TODO: Leave link in old forum
         form = MoveForm(auto_id=True)
         return render_response(request, 'forum/move.html', locals())
 

Modified: branches/stable/media/hackergotchi/akinomeroglu.png
=================================================================
Binary files. No diff available.

Modified: branches/stable/settings.py
=================================================================
--- branches/stable/settings.py	(original)
+++ branches/stable/settings.py	Mon Jun  9 19:20:54 2008
@@ -17,6 +17,7 @@
 TEMPLATE_DEBUG = DEBUG
 WEB_URL = 'http://django'
 DOCUMENT_ROOT = '/home/ahmet/public_html/oi'
+
 DATABASE_ENGINE = 'mysql'
 DATABASE_NAME = 'oi'
 DATABASE_USER = 'root'


More information about the Oi-commits mailing list