##// END OF EJS Templates
Show new and active threads for today (-24 hrs from now) at the landing page
neko259 -
r1740:69b1bc87 default
parent child Browse files
Show More
@@ -32,6 +32,7 b' ThreadsPerPage = 3'
32 PostsPerPage = 10
32 PostsPerPage = 10
33 ImagesPerPageGallery = 20
33 ImagesPerPageGallery = 20
34 MaxFavoriteThreads = 20
34 MaxFavoriteThreads = 20
35 MaxLandingThreads = 20
35
36
36 [Storage]
37 [Storage]
37 # Enable archiving threads instead of deletion when the thread limit is reached
38 # Enable archiving threads instead of deletion when the thread limit is reached
@@ -26,7 +26,7 b''
26 <br />
26 <br />
27 <div class="landing-threads">
27 <div class="landing-threads">
28 {% for op in latest_threads %}
28 {% for op in latest_threads %}
29 {{ op.get_link_view|safe }} {{ op.get_title_or_text }} ({{ op.thread.get_sections_str|safe }})<br />
29 {{ op.get_link_view|safe }} {{ op.get_title_or_text }} ({{ op.thread.get_sections_str|safe }}) +{{ op.today_post_count }}<br />
30 {% endfor %}
30 {% endfor %}
31 </div>
31 </div>
32 </div>
32 </div>
@@ -1,10 +1,15 b''
1 from datetime import datetime
2 from datetime import timedelta
3
4 from django.db.models import Count
1 from django.shortcuts import render
5 from django.shortcuts import render
2 from django.utils.decorators import method_decorator
6 from django.utils.decorators import method_decorator
3 from django.views.decorators.csrf import csrf_protect
7 from django.views.decorators.csrf import csrf_protect
4
8
9 from boards import settings
10 from boards.models import Post
11 from boards.models import Tag, Attachment
5 from boards.views.base import BaseBoardView
12 from boards.views.base import BaseBoardView
6 from boards.models import Tag, Post, Attachment
7
8
13
9 PARAM_SECTION_STR = 'section_str'
14 PARAM_SECTION_STR = 'section_str'
10 PARAM_LATEST_THREADS = 'latest_threads'
15 PARAM_LATEST_THREADS = 'latest_threads'
@@ -12,7 +17,6 b" PARAM_IMAGES = 'images'"
12
17
13 TEMPLATE = 'boards/landing.html'
18 TEMPLATE = 'boards/landing.html'
14
19
15 MAX_NEW_THREADS = 10
16 RANDOM_IMAGE_COUNT = 3
20 RANDOM_IMAGE_COUNT = 3
17
21
18
22
@@ -23,8 +27,14 b' class LandingView(BaseBoardView):'
23
27
24 params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list(
28 params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list(
25 Tag.objects.filter(required=True))
29 Tag.objects.filter(required=True))
26 params[PARAM_LATEST_THREADS] = Post.objects.filter(opening=True)\
30
27 .order_by('-pub_time')[:MAX_NEW_THREADS]
31 today = datetime.now() - timedelta(1)
32 max_landing_threads = settings.get_int('View', 'MaxFavoriteThreads')
33 ops = Post.objects.filter(thread__replies__pub_time__gt=today, opening=True)\
34 .annotate(today_post_count=Count('thread__replies'))\
35 .order_by('-pub_time')[:max_landing_threads]
36 params[PARAM_LATEST_THREADS] = ops
37
28 params[PARAM_IMAGES] = Attachment.objects.get_random_images(
38 params[PARAM_IMAGES] = Attachment.objects.get_random_images(
29 RANDOM_IMAGE_COUNT)
39 RANDOM_IMAGE_COUNT)
30
40
General Comments 0
You need to be logged in to leave comments. Login now