##// END OF EJS Templates
Switch to show only favorite tags (BB-94)
neko259 -
r1691:8a821ff8 default
parent child Browse files
Show More
@@ -21,6 +21,7 b" SETTING_LAST_NOTIFICATION_ID = 'last_not"
21 21 SETTING_IMAGE_VIEWER = 'image_viewer'
22 22 SETTING_TRIPCODE = 'tripcode'
23 23 SETTING_IMAGES = 'images_aliases'
24 SETTING_ONLY_FAVORITES = 'only_favorites'
24 25
25 26 DEFAULT_THEME = 'md'
26 27
@@ -1,5 +1,5 b''
1 1 from boards.abstracts.settingsmanager import get_settings_manager, \
2 SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER
2 SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER, SETTING_ONLY_FAVORITES
3 3 from boards.models.user import Notification
4 4 from boards.models import Banner
5 5
@@ -24,6 +24,7 b" CONTEXT_POW_DIFFICULTY = 'pow_difficulty"
24 24 CONTEXT_NEW_POST_COUNT = 'new_post_count'
25 25 CONTEXT_SEARCH_ENABLED = 'search_enabled'
26 26 CONTEXT_BANNERS = 'banners'
27 CONTEXT_ONLY_FAVORITES = 'only_favorites'
27 28
28 29
29 30 def get_notifications(context, settings_manager):
@@ -81,6 +82,8 b' def user_and_ui_processor(request):'
81 82
82 83 context[CONTEXT_SEARCH_ENABLED] = 'haystack' in neboard.settings.INSTALLED_APPS
83 84 context[CONTEXT_BANNERS] = Banner.objects.order_by('-id')
85 context[CONTEXT_ONLY_FAVORITES] = settings_manager.get_setting(
86 SETTING_ONLY_FAVORITES, False)
84 87
85 88 get_notifications(context, settings_manager)
86 89 get_new_post_count(context, settings_manager)
@@ -31,7 +31,13 b''
31 31 <header class="navigation_panel">
32 32 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
33 33 {% if tags_str %}
34 <a href="{% url 'index' %}?filter=fav_tags" title="{% trans "interesting" %}">β˜…</a>,
34 <form action="{% url 'index' %}" method="post" class="post-button-form">{% csrf_token %}
35 {% if only_favorites %}
36 <button name="method" value="toggle_fav" class="fav">β˜…</button>,
37 {% else %}
38 <button name="method" value="toggle_fav" class="not_fav">β˜…</button>,
39 {% endif %}
40 </form>
35 41 {{ tags_str|safe }},
36 42 {% else %}
37 43 {% trans 'Add tags' %} β†’
@@ -10,13 +10,15 b' from django.views.decorators.csrf import'
10 10
11 11 from boards import utils, settings
12 12 from boards.abstracts.paginator import get_paginator
13 from boards.abstracts.settingsmanager import get_settings_manager
13 from boards.abstracts.settingsmanager import get_settings_manager,\
14 SETTING_ONLY_FAVORITES
14 15 from boards.forms import ThreadForm, PlainErrorList
15 16 from boards.models import Post, Thread, Ban
16 17 from boards.views.banned import BannedView
17 18 from boards.views.base import BaseBoardView, CONTEXT_FORM
18 19 from boards.views.posting_mixin import PostMixin
19 from boards.views.mixins import FileUploadMixin, PaginatedMixin
20 from boards.views.mixins import FileUploadMixin, PaginatedMixin,\
21 DispatcherMixin, PARAMETER_METHOD
20 22
21 23 FORM_TAGS = 'tags'
22 24 FORM_TEXT = 'text'
@@ -37,7 +39,7 b" TEMPLATE = 'boards/all_threads.html'"
37 39 DEFAULT_PAGE = 1
38 40
39 41
40 class AllThreadsView(PostMixin, FileUploadMixin, BaseBoardView, PaginatedMixin):
42 class AllThreadsView(PostMixin, FileUploadMixin, BaseBoardView, PaginatedMixin, DispatcherMixin):
41 43
42 44 def __init__(self):
43 45 self.settings_manager = None
@@ -62,7 +64,7 b' class AllThreadsView(PostMixin, FileUplo'
62 64 else:
63 65 threads = threads.filter(multi_replies__opening=True).order_by('-multi_replies__pub_time')
64 66 filter = request.GET.get('filter')
65 if filter == 'fav_tags':
67 if self.settings_manager.get_setting(SETTING_ONLY_FAVORITES):
66 68 fav_tags = self.settings_manager.get_fav_tags()
67 69 if len(fav_tags) > 0:
68 70 threads = threads.filter(tags__in=fav_tags)
@@ -89,6 +91,11 b' class AllThreadsView(PostMixin, FileUplo'
89 91
90 92 @method_decorator(csrf_protect)
91 93 def post(self, request):
94 if PARAMETER_METHOD in request.POST:
95 self.dispatch_method(request)
96
97 return redirect('index') # FIXME Different for different modes
98
92 99 form = ThreadForm(request.POST, request.FILES,
93 100 error_class=PlainErrorList)
94 101 form.session = request.session
@@ -170,3 +177,8 b' class AllThreadsView(PostMixin, FileUplo'
170 177
171 178 def get_rss_url(self):
172 179 return self.get_reverse_url() + 'rss/'
180
181 def toggle_fav(self, request):
182 settings_manager = get_settings_manager(request)
183 settings_manager.set_setting(SETTING_ONLY_FAVORITES,
184 not settings_manager.get_setting(SETTING_ONLY_FAVORITES, False))
General Comments 0
You need to be logged in to leave comments. Login now