work on admin interface, fix bugs
This commit is contained in:
parent
28597e470c
commit
45268cd699
|
@ -208,6 +208,8 @@ class Station(Nameable):
|
||||||
logs.filter(date__gt = diff.end, date__lt = diff_.start) \
|
logs.filter(date__gt = diff.end, date__lt = diff_.start) \
|
||||||
if diff_ else \
|
if diff_ else \
|
||||||
logs.filter(date__gt = diff.end)
|
logs.filter(date__gt = diff.end)
|
||||||
|
print(diff.end, *[str(log.date > diff.end) + " " + str(log.date) for log in logs])
|
||||||
|
|
||||||
diff_ = diff
|
diff_ = diff
|
||||||
items.extend(logs_)
|
items.extend(logs_)
|
||||||
items.append(diff)
|
items.append(diff)
|
||||||
|
@ -217,7 +219,7 @@ class Station(Nameable):
|
||||||
if diff_:
|
if diff_:
|
||||||
if count and len(items) >= count:
|
if count and len(items) >= count:
|
||||||
return items[:count]
|
return items[:count]
|
||||||
logs_ = logs.filter(date__lt = diff_.end)
|
logs_ = logs.filter(date__lt = diff_.start)
|
||||||
else:
|
else:
|
||||||
logs_ = logs.all()
|
logs_ = logs.all()
|
||||||
|
|
||||||
|
|
58
aircox/static/aircox/css/layout.css
Normal file
58
aircox/static/aircox/css/layout.css
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #373737;
|
||||||
|
background-color: #F2F2F2;
|
||||||
|
font-family: 'Myriad Pro', Calibri, Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
input {
|
||||||
|
padding: 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
border: 1px black solid;
|
||||||
|
width: 80%;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:not(.header):hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.header {
|
||||||
|
background-color: #212121;
|
||||||
|
color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.bottom > td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.subdata {
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
27
aircox/templates/aircox/controllers/base_site.html
Normal file
27
aircox/templates/aircox/controllers/base_site.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Aircox</title>
|
||||||
|
<link rel="stylesheet" href="{% static 'aircox/css/layout.css' %}" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<sidebar class="sidebar main-sidebar">
|
||||||
|
</sidebar>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
{% block title %}
|
||||||
|
<h1>{{ title|default:"Aircox" }}</h1>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,77 @@
|
||||||
|
{% extends "aircox/controllers/base_site.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
<h1>Statistics of the stations</h1>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
<div id='stats'>
|
<div id='stats'>
|
||||||
|
|
||||||
|
{# TODO here #}
|
||||||
|
<form action="?" method="GET">
|
||||||
|
Go to this date:
|
||||||
|
<input name="day" type="number" placeholder="{% trans "day" %}"
|
||||||
|
value="{{ statistics.0.date.day }}"></input>
|
||||||
|
<input name="month" type="number" placeholder="{% trans "month" %}"
|
||||||
|
value="{{ statistics.0.date.month }}"></input>
|
||||||
|
<input name="year" type="number" placeholder="{% trans "year" %}"
|
||||||
|
value="{{ statistics.0.date.year }}"></input>
|
||||||
|
<button type="submit">Show</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
{% for stats in statistics %}
|
{% for stats in statistics %}
|
||||||
<section class="station">
|
<section class="station">
|
||||||
<header>
|
<header>
|
||||||
<h1>{{ stats.station.name }}</h1>
|
<h2>{{ stats.station.name }},
|
||||||
<h2>- {{ stats.date|date:'l d F Y' }}</h2>
|
{{ stats.date|date:'l d F Y' }}</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<table border=1>
|
<table cellspacing="0" cellpading="0" class="object">
|
||||||
<tr>
|
<tr class="header">
|
||||||
<th>{% trans "Date" %}</th>
|
<th>{% trans "Date" %}</th>
|
||||||
|
<th width="10%">{% trans "Type" %}
|
||||||
{# Translators "Header for statistics view" #}
|
{# Translators "Header for statistics view" #}
|
||||||
<th>{% trans "Diffusion or sound played" %}
|
<th width="50%">{% trans "Diffusion or sound played" %}
|
||||||
<th></th>
|
<th width="30%">{% trans "Tags" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for item in stats.items %}
|
{% for item in stats.items %}
|
||||||
<tr class="log">
|
<tr>
|
||||||
<th>{{ item.date|date:"H:i" }}</th>
|
<th>{{ item.date|time:"H:i" }}</th>
|
||||||
|
<th>{{ item.type }}</th>
|
||||||
<th>{{ item.name }}</th>
|
<th>{{ item.name }}</th>
|
||||||
<th>{% for tag,count in item.tags.items %}
|
<th>{% for tag,count in item.tags.items %}
|
||||||
{{ tag }}: {{ count }};
|
{{ tag }}: {{ count }};
|
||||||
{% endfor %}</th>
|
{% endfor %}</th>
|
||||||
<th>{{ item.type }}</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for track in item.tracks %}
|
{% for track in item.tracks %}
|
||||||
<tr class="track">
|
<tr class="subdata">
|
||||||
<td>{{ track.date|date:"H:i" }}</td>
|
<td>{{ track.date|time:"H:i" }}</td>
|
||||||
|
<td>{% trans "Track" %}</td>
|
||||||
<td>{{ track.artist }} -- <emph>{{ track.title }}</emph> {{ track.version }}</td>
|
<td>{{ track.artist }} -- <emph>{{ track.title }}</emph> {{ track.version }}</td>
|
||||||
<td>{{ track.tags.all|join:', ' }}</td>
|
<td>{{ track.tags.all|join:', ' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<tr>
|
<tr class="bottom">
|
||||||
<td>{{ stats.date|date:'d/m/Y' }}</td>
|
<td>{{ stats.date|date:'d/m/Y' }}</td>
|
||||||
|
<td>{% trans "Total" %}</td>
|
||||||
{# TODO: translation block #}
|
{# TODO: translation block #}
|
||||||
<td>{% trans "Total and average" %} ({{ stats.count }} tracks)</td>
|
<td>
|
||||||
|
{% with stats.items|length as items_count %}
|
||||||
|
{% with stats.count as tracks_count %}
|
||||||
|
{% blocktrans %}
|
||||||
|
{{ items_count }} items, with a total of {{ tracks_count }} tracks
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endwith %}
|
||||||
|
</td>
|
||||||
<td>{% for tag, count, average in stats.tags %}
|
<td>{% for tag, count, average in stats.tags %}
|
||||||
{{ tag }}: <b>{{ count }} / {{ average|floatformat }}%</b>;
|
<span>{{ tag }}: <b>{{ average|floatformat }}%</b> ({{ count }})<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -48,9 +79,6 @@
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
import aircox.views as views
|
import aircox.views as views
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ class StatisticsView(View,TemplateResponseMixin,LoginRequiredMixin):
|
||||||
items = [], tags = {})
|
items = [], tags = {})
|
||||||
|
|
||||||
last_item = None
|
last_item = None
|
||||||
for elm in station.on_air(date):
|
for elm in reversed(station.on_air(date)):
|
||||||
qs = None
|
qs = None
|
||||||
item = None
|
item = None
|
||||||
if type(elm) == models.Diffusion:
|
if type(elm) == models.Diffusion:
|
||||||
|
@ -215,7 +215,7 @@ class StatisticsView(View,TemplateResponseMixin,LoginRequiredMixin):
|
||||||
stats.items.append(item)
|
stats.items.append(item)
|
||||||
|
|
||||||
elm.related.date = elm.date
|
elm.related.date = elm.date
|
||||||
item.tracks.insert(0, elm.related)
|
item.tracks.append(elm.related)
|
||||||
item.date = min(elm.date, item.date)
|
item.date = min(elm.date, item.date)
|
||||||
item.add_tags(qs)
|
item.add_tags(qs)
|
||||||
stats.count += 1
|
stats.count += 1
|
||||||
|
@ -223,7 +223,6 @@ class StatisticsView(View,TemplateResponseMixin,LoginRequiredMixin):
|
||||||
last_item = item
|
last_item = item
|
||||||
stats.add_tags(qs)
|
stats.add_tags(qs)
|
||||||
|
|
||||||
print(stats.tags)
|
|
||||||
stats.tags = [
|
stats.tags = [
|
||||||
(name, count, count / stats.count * 100)
|
(name, count, count / stats.count * 100)
|
||||||
for name, count in stats.tags.items()
|
for name, count in stats.tags.items()
|
||||||
|
|
|
@ -17,7 +17,7 @@ USE_L10N = True
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
LANGUAGE_CODE = os.environ.get('LANG') or 'en_US'
|
LANGUAGE_CODE = os.environ.get('LANG') or 'en_US'
|
||||||
TIME_ZONE = os.environ.get('TZ') or 'Europe/Brussels'
|
TIME_ZONE = 'UTC' # os.environ.get('TZ') or 'Europe/Brussels'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import locale
|
import locale
|
||||||
|
|
|
@ -45,3 +45,4 @@ if settings.DEBUG:
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns.append(url(r'', include(wagtail_urls)))
|
urlpatterns.append(url(r'', include(wagtail_urls)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user