##// END OF EJS Templates
If the first thread is created with not section existing yet, default tag will be added if it is the only one specified
If the first thread is created with not section existing yet, default tag will be added if it is the only one specified

File last commit:

r1419:b30b6ad2 default
r1658:b924e5d9 default
Show More
tag_gallery.py
30 lines | 1.1 KiB | text/x-python | PythonLexer
neko259
Added tag gallery
r1419 from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, render
from boards import settings
from boards.abstracts.paginator import get_paginator
from boards.models import Tag
from boards.views.base import BaseBoardView
from boards.views.mixins import PaginatedMixin
IMAGES_PER_PAGE = settings.get_int('View', 'ImagesPerPageGallery')
TEMPLATE = 'boards/tag_gallery.html'
class TagGalleryView(BaseBoardView, PaginatedMixin):
def get(self, request, tag_name):
page = int(request.GET.get('page', 1))
params = dict()
tag = get_object_or_404(Tag, name=tag_name)
params['tag'] = tag
paginator = get_paginator(tag.get_images(), IMAGES_PER_PAGE,
current_page=page)
params['paginator'] = paginator
params['images'] = paginator.page(page).object_list
paginator.set_url(reverse('tag_gallery', kwargs={'tag_name': tag_name}),
request.GET.dict())
self.set_page_urls(paginator, params)
return render(request, TEMPLATE, params)