##// END OF EJS Templates
Version bump
Version bump

File last commit:

r1721:dbf70afe default
r1730:757b4ada 3.5.0 default
Show More
authors.py
52 lines | 1.7 KiB | text/x-python | PythonLexer
neko259
Added statistics to the 'authors' page
r1420 import os
neko259
Show platform on the statistics page
r1720 import platform
neko259
Added python version to stats page
r1721 import sys
neko259
Added statistics to the 'authors' page
r1420
neko259
Added missing all_tags module. Moved authors view to class-based
r551 from django.shortcuts import render
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
Added missing all_tags module. Moved authors view to class-based
r551
neko259
Added statistics to the 'authors' page
r1420 import neboard
neko259
Added missing all_tags module. Moved authors view to class-based
r551 from boards.authors import authors
neko259
Added media directory cache size
r1424 from boards.utils import cached_result
neko259
Added missing all_tags module. Moved authors view to class-based
r551 from boards.views.base import BaseBoardView
neko259
Added statistics to the 'authors' page
r1420 from boards.models import Post
PARAM_AUTHORS = 'authors'
PARAM_MEDIA_SIZE = 'media_size'
PARAM_POST_COUNT = 'post_count'
neko259
Messages statistics for day/week/month
r1618 PARAM_POST_PER_DAY = 'post_per_day'
PARAM_POST_PER_WEEK = 'post_per_week'
PARAM_POST_PER_MONTH = 'post_per_month'
neko259
Show platform on the statistics page
r1720 PARAM_PLATFORM = 'platform'
neko259
Added python version to stats page
r1721 PARAM_PYTHON = 'python'
neko259
Added missing all_tags module. Moved authors view to class-based
r551
neko259
Minor style fixes to view classes. Fixed ban view
r561
neko259
Added missing all_tags module. Moved authors view to class-based
r551 class AuthorsView(BaseBoardView):
neko259
Added CSRF protection to settings. Fixed favorite tags switch from different pages
r1693 @method_decorator(csrf_protect)
neko259
Added missing all_tags module. Moved authors view to class-based
r551 def get(self, request):
neko259
Fixed calls to render shortcut to use dict instead of context instance
r918 params = dict()
neko259
Added statistics to the 'authors' page
r1420 params[PARAM_AUTHORS] = authors
params[PARAM_MEDIA_SIZE] = self._get_directory_size(neboard.settings.MEDIA_ROOT)
params[PARAM_POST_COUNT] = Post.objects.count()
neko259
Added missing all_tags module. Moved authors view to class-based
r551
neko259
Show platform on the statistics page
r1720 params[PARAM_PLATFORM] = platform.platform()
neko259
Added python version to stats page
r1721 python_version = sys.version_info
params[PARAM_PYTHON] = '{}.{}.{}'.format(python_version.major,
python_version.minor, python_version.micro)
neko259
Show platform on the statistics page
r1720
neko259
Messages statistics for day/week/month
r1618 params[PARAM_POST_PER_DAY] = Post.objects.get_post_per_days(1)
params[PARAM_POST_PER_WEEK] = Post.objects.get_post_per_days(7)
params[PARAM_POST_PER_MONTH] = Post.objects.get_post_per_days(30)
neko259
Fixed calls to render shortcut to use dict instead of context instance
r918 return render(request, 'boards/authors.html', params)
neko259
Added statistics to the 'authors' page
r1420
neko259
Added media directory cache size
r1424 @cached_result()
neko259
Added statistics to the 'authors' page
r1420 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