DjangoBB

Django based forum engine

  • You are not logged in.
  • Root
  • » Bugs
  • » show_new search fails if user has never used forum before [RSS Feed]

#1 Aug. 17, 2011 04:05:19

BrianHV
Registered: 2011-07-28
Posts: 4
Reputation: +  0  -
Profile   Send e-mail  

show_new search fails if user has never used forum before

I added the forum to my existing site, so I have a lot of users who have never used the forum before. I now have a prominent link to the show_new search so users can see a list of all the new forum posts. If a user hasn't read any posts, the show_new search throws an exception. Here's a patch to fix that:

diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py
index 30d26c3..839961f 100644
--- a/djangobb_forum/views.py
+++ b/djangobb_forum/views.py
@@ -133,12 +133,15 @@ def search(request):
date = datetime.today() - timedelta(1)
topics = topics.filter(created__gte=date)
elif action == 'show_new':
- last_read = PostTracking.objects.get(user=request.user).last_read
- if last_read:
- topics = topics.filter(last_post__updated__gte=last_read).all()
- else:
- #searching more than forum_settings.SEARCH_PAGE_SIZE in this way - not good idea :]
- topics = [topic for topic in topics[:forum_settings.SEARCH_PAGE_SIZE] if forum_extras.has_unreads(topic,
+ try:
+ last_read = PostTracking.objects.get(user=request.user).last_read
+ if last_read:
+ topics = topics.filter(last_post__updated__gte=last_read).all()
+ else:
+ #searching more than forum_settings.SEARCH_PAGE_SIZE in this way - not good idea :]
+ topics = [topic for topic in topics[:forum_settings.SEARCH_PAGE_SIZE] if forum_extras.has_unreads(top
+ except PostTracking.DoesNotExist:
+ pass
elif action == 'show_unanswered':
topics = topics.filter(post_count=1)
elif action == 'show_subscriptions':

Offline

  • Root
  • » Bugs
  • » show_new search fails if user has never used forum before[RSS Feed]

Board footer

Moderator control

Powered by DjangoBB

Lo-Fi Version