##// END OF EJS Templates
Updated urls list to be a plain list instead of 'patterns' method which is...
Updated urls list to be a plain list instead of 'patterns' method which is deprecated and will be removed in 1.10

File last commit:

r1377:4e034141 default
r1486:c55955ce default
Show More
tag_threads.py
118 lines | 3.6 KiB | text/x-python | PythonLexer
neko259
Redirect after sending POST to the tag page
r1095 from django.shortcuts import get_object_or_404, redirect
neko259
Set previous and next page links in the thread list view instead of template
r1129 from django.core.urlresolvers import reverse
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730
neko259
More 'proper' way to get status of the tag
r998 from boards.abstracts.settingsmanager import get_settings_manager, \
SETTING_FAVORITE_TAGS, SETTING_HIDDEN_TAGS
neko259
Added random images, associated with the tag, to the tag page
r1252 from boards.models import Tag, PostImage
neko259
Rewriting views to class-based
r542 from boards.views.all_threads import AllThreadsView, DEFAULT_PAGE
neko259
Added ability to hide a post
r1366 from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD
neko259
Fixed posting from the tag page
r597 from boards.forms import ThreadForm, PlainErrorList
neko259
Rewriting views to class-based
r542
neko259
Views refactoring
r900 PARAM_HIDDEN_TAGS = 'hidden_tags'
PARAM_TAG = 'tag'
neko259
More 'proper' way to get status of the tag
r998 PARAM_IS_FAVORITE = 'is_favorite'
PARAM_IS_HIDDEN = 'is_hidden'
neko259
Show link to posts in this tag for the tag image even if the image is used in...
r1263 PARAM_RANDOM_IMAGE_POST = 'random_image_post'
neko259
Show related tags in the tag page
r1269 PARAM_RELATED_TAGS = 'related_tags'
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730
neko259
Rewriting views to class-based
r542 __author__ = 'neko259'
neko259
Refactored views
r1090 class TagView(AllThreadsView, DispatcherMixin):
neko259
Rewriting views to class-based
r542
tag_name = None
def get_threads(self):
tag = get_object_or_404(Tag, name=self.tag_name)
neko259
If we are trying to open a hidden tag page, show its threads
r1064 hidden_tags = self.settings_manager.get_hidden_tags()
try:
hidden_tags.remove(tag)
except ValueError:
pass
neko259
Fixed notifications for multi-thread posts. Fixed hiding hidden tag threads when viewing tag page
r1062 return tag.get_threads().exclude(
neko259
If we are trying to open a hidden tag page, show its threads
r1064 tags__in=hidden_tags)
neko259
Rewriting views to class-based
r542
def get_context_data(self, **kwargs):
neko259
Fixed tag threads view
r919 params = super(TagView, self).get_context_data(**kwargs)
neko259
Rewriting views to class-based
r542
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(kwargs['request'])
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728
neko259
Rewriting views to class-based
r542 tag = get_object_or_404(Tag, name=self.tag_name)
neko259
Fixed tag threads view
r919 params[PARAM_TAG] = tag
neko259
Rewriting views to class-based
r542
neko259
More 'proper' way to get status of the tag
r998 fav_tag_names = settings_manager.get_setting(SETTING_FAVORITE_TAGS)
hidden_tag_names = settings_manager.get_setting(SETTING_HIDDEN_TAGS)
params[PARAM_IS_FAVORITE] = fav_tag_names is not None and tag.name in fav_tag_names
params[PARAM_IS_HIDDEN] = hidden_tag_names is not None and tag.name in hidden_tag_names
neko259
Show link to posts in this tag for the tag image even if the image is used in...
r1263
neko259
Speed up getting tag's random image
r1264 params[PARAM_RANDOM_IMAGE_POST] = tag.get_random_image_post()
neko259
Add up to 5 random related tags instead of all related list
r1270 params[PARAM_RELATED_TAGS] = tag.get_related_tags()
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728
neko259
Fixed tag threads view
r919 return params
neko259
Rewriting views to class-based
r542
neko259
Added ability to get page urls of paginators
r1377 def get_reverse_url(self):
return reverse('tag', kwargs={'tag_name': self.tag_name})
neko259
Set previous and next page links in the thread list view instead of template
r1129
neko259
Use GET parameter to specify a page instead of different url reversers
r1204 def get(self, request, tag_name, form=None):
neko259
Rewriting views to class-based
r542 self.tag_name = tag_name
neko259
Use GET parameter to specify a page instead of different url reversers
r1204 return super(TagView, self).get(request, form)
neko259
Made "subscribe" and "hide" in tags as buttons with forms.
r1037
neko259
Fixed posting from the tag page
r597
neko259
Use GET parameter to specify a page instead of different url reversers
r1204 def post(self, request, tag_name):
neko259
Made "subscribe" and "hide" in tags as buttons with forms.
r1037 self.tag_name = tag_name
neko259
Fixed posting from the tag page
r597
neko259
Added ability to hide a post
r1366 if PARAMETER_METHOD in request.POST:
neko259
Made "subscribe" and "hide" in tags as buttons with forms.
r1037 self.dispatch_method(request)
neko259
Do not redirect after posting a form to the tag page, do it only when running...
r1103
return redirect('tag', tag_name)
neko259
Made "subscribe" and "hide" in tags as buttons with forms.
r1037 else:
form = ThreadForm(request.POST, request.FILES,
error_class=PlainErrorList)
form.session = request.session
if form.is_valid():
return self.create_thread(request, form)
if form.need_to_ban:
# Ban user because he is suspected to be a bot
self._ban_current_user(request)
neko259
Fixed posting from the tag page
r597
neko259
Fixed creating new thread from a tag with non-default page
r1292 return self.get(request, tag_name, form)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563
def subscribe(self, request):
tag = get_object_or_404(Tag, name=self.tag_name)
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 settings_manager.add_fav_tag(tag)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563
def unsubscribe(self, request):
tag = get_object_or_404(Tag, name=self.tag_name)
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 settings_manager.del_fav_tag(tag)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563
neko259
Added hidden tags functionality
r635 def hide(self, request):
"""
Adds tag to user's hidden tags. Threads with this tag will not be
shown.
"""
tag = get_object_or_404(Tag, name=self.tag_name)
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 settings_manager.add_hidden_tag(tag)
neko259
Added hidden tags functionality
r635
def unhide(self, request):
"""
Removed tag from user's hidden tags.
"""
tag = get_object_or_404(Tag, name=self.tag_name)
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 settings_manager.del_hidden_tag(tag)