##// END OF EJS Templates
Added statistics to the 'authors' page
neko259 -
r1420:09378fcc default
parent child Browse files
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -503,3 +503,9 b' msgstr "\xd0\x9d\xd0\xbe\xd0\xb2\xd1\x8b\xd0\xb5 \xd1\x82\xd0\xb5\xd0\xbc\xd1\x8b"'
503 #, python-format
503 #, python-format
504 msgid "Max file size is %(size)s."
504 msgid "Max file size is %(size)s."
505 msgstr "Максимальный размер файла %(size)s."
505 msgstr "Максимальный размер файла %(size)s."
506
507 msgid "Size of media:"
508 msgstr "Размер медиа:"
509
510 msgid "Statistics"
511 msgstr "Статистика"
@@ -9,6 +9,9 b''
9 {% block content %}
9 {% block content %}
10 <div class="post">
10 <div class="post">
11 <p><img src="{{ STATIC_URL }}favicon.png" width="200" /></p>
11 <p><img src="{{ STATIC_URL }}favicon.png" width="200" /></p>
12 <h2>{% trans 'Statistics' %}</h2>
13 <p>{% trans 'Size of media:' %} {{ media_size|filesizeformat }}.
14 <p>{% blocktrans count count=post_count %}{{ count }} message{% plural %}messages{% endblocktrans %}.</p>
12 <h2>{% trans 'Authors' %}</h2>
15 <h2>{% trans 'Authors' %}</h2>
13 {% for nick, values in authors.items %}
16 {% for nick, values in authors.items %}
14 <p>
17 <p>
@@ -1,13 +1,32 b''
1 import os
2
1 from django.shortcuts import render
3 from django.shortcuts import render
2
4
5 import neboard
3 from boards.authors import authors
6 from boards.authors import authors
4 from boards.views.base import BaseBoardView
7 from boards.views.base import BaseBoardView
8 from boards.models import Post
9
10
11 PARAM_AUTHORS = 'authors'
12 PARAM_MEDIA_SIZE = 'media_size'
13 PARAM_POST_COUNT = 'post_count'
5
14
6
15
7 class AuthorsView(BaseBoardView):
16 class AuthorsView(BaseBoardView):
8
17
9 def get(self, request):
18 def get(self, request):
10 params = dict()
19 params = dict()
11 params['authors'] = authors
20 params[PARAM_AUTHORS] = authors
21 params[PARAM_MEDIA_SIZE] = self._get_directory_size(neboard.settings.MEDIA_ROOT)
22 params[PARAM_POST_COUNT] = Post.objects.count()
12
23
13 return render(request, 'boards/authors.html', params)
24 return render(request, 'boards/authors.html', params)
25
26 def _get_directory_size(self, directory):
27 total_size = 0
28 for dirpath, dirnames, filenames in os.walk(directory):
29 for f in filenames:
30 fp = os.path.join(dirpath, f)
31 total_size += os.path.getsize(fp)
32 return total_size
General Comments 0
You need to be logged in to leave comments. Login now