##// END OF EJS Templates
Rendered post should be considered safe
Rendered post should be considered safe

File last commit:

r1693:807f3415 default
r1952:4c766e32 default
Show More
random.py
25 lines | 598 B | text/x-python | PythonLexer
neko259
Add random images list view
r1246 from django.shortcuts import render
from django.views.generic import View
neko259
Added CSRF protection to settings. Fixed favorite tags switch from different pages
r1693 from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_protect
neko259
Add random images list view
r1246
neko259
Store images as regular attachments instead of separate model
r1590 from boards.models import Attachment
neko259
Add random images list view
r1246
__author__ = 'neko259'
TEMPLATE = 'boards/random.html'
neko259
Don't return posts with the same image in random view
r1249 CONTEXT_IMAGES = 'images'
neko259
Add random images list view
r1246
neko259
Center random images
r1247 RANDOM_POST_COUNT = 9
neko259
Add random images list view
r1246
class RandomImageView(View):
neko259
Added CSRF protection to settings. Fixed favorite tags switch from different pages
r1693 @method_decorator(csrf_protect)
neko259
Add random images list view
r1246 def get(self, request):
params = dict()
neko259
Store images as regular attachments instead of separate model
r1590 params[CONTEXT_IMAGES] = Attachment.objects.get_random_images(
neko259
Don't return posts with the same image in random view
r1249 RANDOM_POST_COUNT)
neko259
Add random images list view
r1246
return render(request, TEMPLATE, params)