Show More
@@ -1,36 +1,37 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|safe }}</title> |
|
8 | <title>{{ site_name|safe }}</title> | |
9 | {% endblock %} |
|
9 | {% endblock %} | |
10 |
|
10 | |||
11 | {% block content %} |
|
11 | {% block content %} | |
12 | {% autoescape off %} |
|
12 | {% autoescape off %} | |
13 | <div id="posts-table"> |
|
13 | <div id="posts-table"> | |
14 | <div class="landing-tags"> |
|
14 | <div class="landing-tags"> | |
15 | {{ section_str }} |
|
15 | {{ section_str }} | |
16 | </div> |
|
16 | </div> | |
17 | <br /> |
|
17 | <br /> | |
18 | {% if latest_threads %} |
|
18 | {% if latest_threads %} | |
19 | <div class="landing-threads"> |
|
19 | <div class="landing-threads"> | |
20 | {% for op in latest_threads %} |
|
20 | {% for op in latest_threads %} | |
21 | <div class="thread-short gallery_image"> |
|
21 | <div class="thread-short gallery_image"> | |
22 | {{ op.attachments.first.get_view|safe }} |
|
22 | {{ op.attachments.first.get_view|safe }} | |
23 | {% with title=op.get_title_or_text %} |
|
23 | {% with title=op.get_title_or_text %} | |
24 | {% if title %} |
|
24 | {% if title %} | |
25 | <div class="title">{{ title }}</div> |
|
25 | <div class="title">{{ title }}</div> | |
26 | {% endif %} |
|
26 | {% endif %} | |
27 | {% endwith %} |
|
27 | {% endwith %} | |
28 | <div>{{ op.thread.get_sections_str }}</div> |
|
28 | <div>{{ op.thread.get_sections_str }}</div> | |
29 |
<div>{{ op.get_link_view }} |
|
29 | <div>{{ op.get_link_view }}</div> | |
|
30 | <div>{{ op.thread.last_edit_time }}</div> | |||
30 | </div> |
|
31 | </div> | |
31 | {% endfor %} |
|
32 | {% endfor %} | |
32 | </div> |
|
33 | </div> | |
33 | {% endif %} |
|
34 | {% endif %} | |
34 | </div> |
|
35 | </div> | |
35 | {% endautoescape %} |
|
36 | {% endautoescape %} | |
36 | {% endblock %} |
|
37 | {% endblock %} |
@@ -1,41 +1,41 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, Q |
|
4 | from django.db.models import Count, Q | |
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, Tag, Attachment, STATUS_ACTIVE, TagAlias |
|
10 | from boards.models import Post, Tag, Attachment, STATUS_ACTIVE, TagAlias | |
11 | from boards.models.tag import DEFAULT_LOCALE |
|
11 | from boards.models.tag import DEFAULT_LOCALE | |
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 |
|
16 | |||
17 | TEMPLATE = 'boards/landing.html' |
|
17 | TEMPLATE = 'boards/landing.html' | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | class LandingView(BaseBoardView): |
|
20 | class LandingView(BaseBoardView): | |
21 | @method_decorator(csrf_protect) |
|
21 | @method_decorator(csrf_protect) | |
22 | def get(self, request): |
|
22 | def get(self, request): | |
23 | params = dict() |
|
23 | params = dict() | |
24 |
|
24 | |||
25 | params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list( |
|
25 | params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list( | |
26 | Tag.objects.filter(Q(aliases__in=TagAlias.objects.filter_localized()) & Q(required=True)) |
|
26 | Tag.objects.filter(Q(aliases__in=TagAlias.objects.filter_localized()) & Q(required=True)) | |
27 | .order_by('aliases__name')) |
|
27 | .order_by('aliases__name')) | |
28 |
|
28 | |||
29 | today = datetime.now() - timedelta(1) |
|
29 | today = datetime.now() - timedelta(1) | |
30 | ops = Post.objects.filter(thread__replies__pub_time__gt=today, opening=True, thread__status=STATUS_ACTIVE)\ |
|
30 | ops = Post.objects.filter(thread__replies__pub_time__gt=today, opening=True, thread__status=STATUS_ACTIVE)\ | |
31 | .annotate(today_post_count=Count('thread__replies'))\ |
|
31 | .annotate(today_post_count=Count('thread__replies'))\ | |
32 | .order_by('-pub_time') |
|
32 | .order_by('-pub_time') | |
33 |
|
33 | |||
34 |
max_landing_threads = settings.get_int('View', 'Max |
|
34 | max_landing_threads = settings.get_int('View', 'MaxLandingThreads') | |
35 | if max_landing_threads > 0: |
|
35 | if max_landing_threads > 0: | |
36 | ops = ops[:max_landing_threads] |
|
36 | ops = ops[:max_landing_threads] | |
37 |
|
37 | |||
38 | params[PARAM_LATEST_THREADS] = ops |
|
38 | params[PARAM_LATEST_THREADS] = ops | |
39 |
|
39 | |||
40 | return render(request, TEMPLATE, params) |
|
40 | return render(request, TEMPLATE, params) | |
41 |
|
41 |
General Comments 0
You need to be logged in to leave comments.
Login now