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