##// END OF EJS Templates
Fixed issue with random images
Fixed issue with random images

File last commit:

r1424:78342ab8 default
r1592:f712e495 default
Show More
authors.py
34 lines | 950 B | text/x-python | PythonLexer
import os
from django.shortcuts import render
import neboard
from boards.authors import authors
from boards.utils import cached_result
from boards.views.base import BaseBoardView
from boards.models import Post
PARAM_AUTHORS = 'authors'
PARAM_MEDIA_SIZE = 'media_size'
PARAM_POST_COUNT = 'post_count'
class AuthorsView(BaseBoardView):
def get(self, request):
params = dict()
params[PARAM_AUTHORS] = authors
params[PARAM_MEDIA_SIZE] = self._get_directory_size(neboard.settings.MEDIA_ROOT)
params[PARAM_POST_COUNT] = Post.objects.count()
return render(request, 'boards/authors.html', params)
@cached_result()
def _get_directory_size(self, directory):
total_size = 0
for dirpath, dirnames, filenames in os.walk(directory):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size