Show More
@@ -1,37 +1,38 | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load static %} |
|
5 | 5 | |
|
6 | 6 | {% block head %} |
|
7 | 7 | <title>{% trans "Authors" %}</title> |
|
8 | 8 | {% endblock %} |
|
9 | 9 | |
|
10 | 10 | {% block content %} |
|
11 | 11 | <div class="post"> |
|
12 | 12 | <p><img src="{% static 'favicon.png' %}" width="200" /></p> |
|
13 | 13 | <h2>{% trans 'Statistics' %}</h2> |
|
14 | 14 | <p>{% trans 'Size of media:' %} {{ media_size|filesizeformat }}. |
|
15 | 15 | <p>{% blocktrans count count=post_count %}{{ count }} message{% plural %}messages{% endblocktrans %}.</p> |
|
16 | 16 | <p>{% trans 'Messages per day/week/month:' %} {{ post_per_day }}/{{ post_per_week }}/{{ post_per_month }}</p> |
|
17 | 17 | <p>{{ platform }}</p> |
|
18 | <p>Python {{ python }}</p> | |
|
18 | 19 | <h2>{% trans 'Authors' %}</h2> |
|
19 | 20 | {% for nick, values in authors.items %} |
|
20 | 21 | <p> |
|
21 | 22 | <b>{{ nick }}</b> ({{ values.name }}): |
|
22 | 23 | {% for value in values.contacts %} |
|
23 | 24 | <a href="mailto:{{ value }}">{{ value }}</a> |
|
24 | 25 | {% endfor %} - |
|
25 | 26 | {{ values.roles|join:', ' }} |
|
26 | 27 | </p> |
|
27 | 28 | {% endfor %} |
|
28 | 29 | <br /> |
|
29 | 30 | <p>{% trans "Distributed under the" %} |
|
30 | 31 | <a href="http://www.gnu.org/licenses/gpl.html" >GNU GPLv3</a> |
|
31 | 32 | {% trans "license" %}</p> |
|
32 | 33 | <p><a href="https://bitbucket.org/neko259/neboard"> |
|
33 | 34 | {% trans "Repository" %}</a></p> |
|
34 | 35 | |
|
35 | 36 | <p>Bitcoin: <b>1A4dePg6CGfYcJ7SH1tbaVdjjj1VLv8X1H</b></p> |
|
36 | 37 | </div> |
|
37 | 38 | {% endblock %} |
@@ -1,47 +1,52 | |||
|
1 | 1 | import os |
|
2 | 2 | import platform |
|
3 | import sys | |
|
3 | 4 | |
|
4 | 5 | from django.shortcuts import render |
|
5 | 6 | from django.utils.decorators import method_decorator |
|
6 | 7 | from django.views.decorators.csrf import csrf_protect |
|
7 | 8 | |
|
8 | 9 | import neboard |
|
9 | 10 | from boards.authors import authors |
|
10 | 11 | from boards.utils import cached_result |
|
11 | 12 | from boards.views.base import BaseBoardView |
|
12 | 13 | from boards.models import Post |
|
13 | 14 | |
|
14 | 15 | |
|
15 | 16 | PARAM_AUTHORS = 'authors' |
|
16 | 17 | PARAM_MEDIA_SIZE = 'media_size' |
|
17 | 18 | PARAM_POST_COUNT = 'post_count' |
|
18 | 19 | PARAM_POST_PER_DAY = 'post_per_day' |
|
19 | 20 | PARAM_POST_PER_WEEK = 'post_per_week' |
|
20 | 21 | PARAM_POST_PER_MONTH = 'post_per_month' |
|
21 | 22 | PARAM_PLATFORM = 'platform' |
|
23 | PARAM_PYTHON = 'python' | |
|
22 | 24 | |
|
23 | 25 | |
|
24 | 26 | class AuthorsView(BaseBoardView): |
|
25 | 27 | @method_decorator(csrf_protect) |
|
26 | 28 | def get(self, request): |
|
27 | 29 | params = dict() |
|
28 | 30 | params[PARAM_AUTHORS] = authors |
|
29 | 31 | params[PARAM_MEDIA_SIZE] = self._get_directory_size(neboard.settings.MEDIA_ROOT) |
|
30 | 32 | params[PARAM_POST_COUNT] = Post.objects.count() |
|
31 | 33 | |
|
32 | 34 | params[PARAM_PLATFORM] = platform.platform() |
|
35 | python_version = sys.version_info | |
|
36 | params[PARAM_PYTHON] = '{}.{}.{}'.format(python_version.major, | |
|
37 | python_version.minor, python_version.micro) | |
|
33 | 38 | |
|
34 | 39 | params[PARAM_POST_PER_DAY] = Post.objects.get_post_per_days(1) |
|
35 | 40 | params[PARAM_POST_PER_WEEK] = Post.objects.get_post_per_days(7) |
|
36 | 41 | params[PARAM_POST_PER_MONTH] = Post.objects.get_post_per_days(30) |
|
37 | 42 | |
|
38 | 43 | return render(request, 'boards/authors.html', params) |
|
39 | 44 | |
|
40 | 45 | @cached_result() |
|
41 | 46 | def _get_directory_size(self, directory): |
|
42 | 47 | total_size = 0 |
|
43 | 48 | for dirpath, dirnames, filenames in os.walk(directory): |
|
44 | 49 | for f in filenames: |
|
45 | 50 | fp = os.path.join(dirpath, f) |
|
46 | 51 | total_size += os.path.getsize(fp) |
|
47 | 52 | return total_size |
General Comments 0
You need to be logged in to leave comments.
Login now