##// END OF EJS Templates
Use proper settings for max landing threads. Show thread last update time instead of number of posts
Use proper settings for max landing threads. Show thread last update time instead of number of posts

File last commit:

r2001:6d66389f default
r2001:6d66389f default
Show More
landing.py
41 lines | 1.4 KiB | text/x-python | PythonLexer
neko259
Show new and active threads for today (-24 hrs from now) at the landing page
r1740 from datetime import datetime
from datetime import timedelta
neko259
Fixed tag order on the landing page
r1905 from django.db.models import Count, Q
neko259
Added landing page which will be the default on /
r1732 from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_protect
neko259
Show new and active threads for today (-24 hrs from now) at the landing page
r1740 from boards import settings
neko259
Fixed tag order on the landing page
r1905 from boards.models import Post, Tag, Attachment, STATUS_ACTIVE, TagAlias
neko259
Tag name is now stored in the alias with default locale
r1874 from boards.models.tag import DEFAULT_LOCALE
neko259
Added landing page which will be the default on /
r1732 from boards.views.base import BaseBoardView
PARAM_SECTION_STR = 'section_str'
PARAM_LATEST_THREADS = 'latest_threads'
TEMPLATE = 'boards/landing.html'
class LandingView(BaseBoardView):
@method_decorator(csrf_protect)
def get(self, request):
params = dict()
params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list(
neko259
Fixed tag order on the landing page
r1905 Tag.objects.filter(Q(aliases__in=TagAlias.objects.filter_localized()) & Q(required=True))
.order_by('aliases__name'))
neko259
Show new and active threads for today (-24 hrs from now) at the landing page
r1740
today = datetime.now() - timedelta(1)
neko259
Show only active (by status) threads on the landing page
r1745 ops = Post.objects.filter(thread__replies__pub_time__gt=today, opening=True, thread__status=STATUS_ACTIVE)\
neko259
Show new and active threads for today (-24 hrs from now) at the landing page
r1740 .annotate(today_post_count=Count('thread__replies'))\
neko259
Allow showing all active threads on the landing threads if the max count is set to 0
r1843 .order_by('-pub_time')
neko259
Use proper settings for max landing threads. Show thread last update time instead of number of posts
r2001 max_landing_threads = settings.get_int('View', 'MaxLandingThreads')
neko259
Allow showing all active threads on the landing threads if the max count is set to 0
r1843 if max_landing_threads > 0:
ops = ops[:max_landing_threads]
neko259
Show new and active threads for today (-24 hrs from now) at the landing page
r1740 params[PARAM_LATEST_THREADS] = ops
neko259
Added landing page which will be the default on /
r1732 return render(request, TEMPLATE, params)