##// END OF EJS Templates
Fixed license text
Fixed license text

File last commit:

r730:447bb8d7 2.0-dev
r739:809d6f1e default
Show More
tag_threads.py
87 lines | 2.5 KiB | text/x-python | PythonLexer
neko259
Rewriting views to class-based
r542 from django.shortcuts import get_object_or_404
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 from boards import utils
neko259
Rewriting views to class-based
r542 from boards.models import Tag, Post
from boards.views.all_threads import AllThreadsView, DEFAULT_PAGE
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563 from boards.views.mixins import DispatcherMixin, RedirectNextMixin
neko259
Fixed posting from the tag page
r597 from boards.forms import ThreadForm, PlainErrorList
neko259
Rewriting views to class-based
r542
__author__ = 'neko259'
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563 class TagView(AllThreadsView, DispatcherMixin, RedirectNextMixin):
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
Removed archive as a separate entity. Archived threads are saved in the same...
r652 return tag.threads.all().order_by('-bump_time')
neko259
Rewriting views to class-based
r542
def get_context_data(self, **kwargs):
context = super(TagView, self).get_context_data(**kwargs)
tag = get_object_or_404(Tag, name=self.tag_name)
context['tag'] = tag
return context
neko259
Fixed posting from the tag page
r597 def get(self, request, tag_name, page=DEFAULT_PAGE, form=None):
neko259
Rewriting views to class-based
r542 self.tag_name = tag_name
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563 dispatch_result = self.dispatch_method(request)
if dispatch_result:
return dispatch_result
else:
neko259
Fixed posting from the tag page
r597 return super(TagView, self).get(request, page, form)
def post(self, request, tag_name, page=DEFAULT_PAGE):
form = ThreadForm(request.POST, request.FILES,
error_class=PlainErrorList)
form.session = request.session
if form.is_valid():
neko259
Refactoring in all threads view
r634 return self.create_thread(request, form)
neko259
Fixed posting from the tag page
r597 if form.need_to_ban:
# Ban user because he is suspected to be a bot
self._ban_current_user(request)
return self.get(request, tag_name, page, form)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563
def subscribe(self, request):
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 user = utils.get_user(request)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563 tag = get_object_or_404(Tag, name=self.tag_name)
if not tag in user.fav_tags.all():
user.add_tag(tag)
return self.redirect_to_next(request)
def unsubscribe(self, request):
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 user = utils.get_user(request)
neko259
Moved tag subscribe and unsubscribe methods to the tag view. Added a...
r563 tag = get_object_or_404(Tag, name=self.tag_name)
if tag in user.fav_tags.all():
user.remove_tag(tag)
return self.redirect_to_next(request)
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.
"""
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 user = utils.get_user(request)
neko259
Added hidden tags functionality
r635 tag = get_object_or_404(Tag, name=self.tag_name)
user.hide_tag(tag)
def unhide(self, request):
"""
Removed tag from user's hidden tags.
"""
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 user = utils.get_user(request)
neko259
Added hidden tags functionality
r635 tag = get_object_or_404(Tag, name=self.tag_name)
user.unhide_tag(tag)