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