Show More
@@ -1,45 +1,34 b'' | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load static %} |
|
5 | 5 | {% load board %} |
|
6 | 6 | |
|
7 | 7 | {% block head %} |
|
8 | 8 | <title>{{ site_name }}</title> |
|
9 | 9 | {% endblock %} |
|
10 | 10 | |
|
11 | 11 | {% block content %} |
|
12 | 12 | <div id="posts-table"> |
|
13 | <div class="landing-images"> | |
|
14 | {% for image in images %} | |
|
15 | <div class="gallery_image"> | |
|
16 | {{ image.get_view|safe }} | |
|
17 | {% with image.get_random_associated_post as post %} | |
|
18 | {{ post.get_link_view|safe }} | |
|
19 | {% endwith %} | |
|
20 | </div> | |
|
21 | {% endfor %} | |
|
22 | </div> | |
|
23 | <br /> | |
|
24 | 13 | <div class="landing-tags"> |
|
25 | 14 | {{ section_str|safe }} |
|
26 | 15 | </div> |
|
27 | 16 | <br /> |
|
28 | 17 | {% if latest_threads %} |
|
29 | 18 | <div class="landing-threads"> |
|
30 | 19 | {% for op in latest_threads %} |
|
31 | 20 | <div class="thread-short gallery_image"> |
|
32 | 21 | {{ op.attachments.first.get_view|safe }} |
|
33 | 22 | {% with title=op.get_title_or_text %} |
|
34 | 23 | {% if title %} |
|
35 | 24 | <div>{{ title }}</div> |
|
36 | 25 | {% endif %} |
|
37 | 26 | {% endwith %} |
|
38 | 27 | <div>{{ op.thread.get_sections_str|safe }}</div> |
|
39 | 28 | <div>{{ op.get_link_view|safe }} +{{ op.today_post_count }}</div> |
|
40 | 29 | </div> |
|
41 | 30 | {% endfor %} |
|
42 | 31 | </div> |
|
43 | 32 | {% endif %} |
|
44 | 33 | </div> |
|
45 | 34 | {% endblock %} |
@@ -1,46 +1,40 b'' | |||
|
1 | 1 | from datetime import datetime |
|
2 | 2 | from datetime import timedelta |
|
3 | 3 | |
|
4 | 4 | from django.db.models import Count |
|
5 | 5 | from django.shortcuts import render |
|
6 | 6 | from django.utils.decorators import method_decorator |
|
7 | 7 | from django.views.decorators.csrf import csrf_protect |
|
8 | 8 | |
|
9 | 9 | from boards import settings |
|
10 | 10 | from boards.models import Post |
|
11 | 11 | from boards.models import Tag, Attachment, STATUS_ACTIVE |
|
12 | 12 | from boards.views.base import BaseBoardView |
|
13 | 13 | |
|
14 | 14 | PARAM_SECTION_STR = 'section_str' |
|
15 | 15 | PARAM_LATEST_THREADS = 'latest_threads' |
|
16 | PARAM_IMAGES = 'images' | |
|
17 | 16 | |
|
18 | 17 | TEMPLATE = 'boards/landing.html' |
|
19 | 18 | |
|
20 | RANDOM_IMAGE_COUNT = 3 | |
|
21 | ||
|
22 | 19 | |
|
23 | 20 | class LandingView(BaseBoardView): |
|
24 | 21 | @method_decorator(csrf_protect) |
|
25 | 22 | def get(self, request): |
|
26 | 23 | params = dict() |
|
27 | 24 | |
|
28 | 25 | params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list( |
|
29 | 26 | Tag.objects.filter(required=True)) |
|
30 | 27 | |
|
31 | 28 | today = datetime.now() - timedelta(1) |
|
32 | 29 | ops = Post.objects.filter(thread__replies__pub_time__gt=today, opening=True, thread__status=STATUS_ACTIVE)\ |
|
33 | 30 | .annotate(today_post_count=Count('thread__replies'))\ |
|
34 | 31 | .order_by('-pub_time') |
|
35 | 32 | |
|
36 | 33 | max_landing_threads = settings.get_int('View', 'MaxFavoriteThreads') |
|
37 | 34 | if max_landing_threads > 0: |
|
38 | 35 | ops = ops[:max_landing_threads] |
|
39 | 36 | |
|
40 | 37 | params[PARAM_LATEST_THREADS] = ops |
|
41 | 38 | |
|
42 | params[PARAM_IMAGES] = Attachment.objects.get_random_images( | |
|
43 | RANDOM_IMAGE_COUNT) | |
|
44 | ||
|
45 | 39 | return render(request, TEMPLATE, params) |
|
46 | 40 |
General Comments 0
You need to be logged in to leave comments.
Login now