Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
2677317c
Commit
2677317c
authored
Apr 06, 2015
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some statistics
parent
7603eaa5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
2 deletions
+73
-2
nonstop/templates/nonstop/statistics.html
nonstop/templates/nonstop/statistics.html
+26
-0
nonstop/urls.py
nonstop/urls.py
+2
-1
nonstop/views.py
nonstop/views.py
+45
-1
No files found.
nonstop/templates/nonstop/statistics.html
0 → 100644
View file @
2677317c
{% extends "base.html" %}
{% load i18n %}
{% block appbar %}
<h2>
Nonstop - Statisticss
</h2>
{% endblock %}
{% block content %}
<div
class=
"nonstop-stats"
>
{% for zone in zones %}
<h3>
{{ zone.title }}
<span>
({{zone.start}} → {{zone.end}})
</span></h3>
<ul>
<li>
Number of tracks: {{zone.stats.count}}
<ul>
<li>
Instru: {{zone.stats.instru}} ({{zone.stats.instru_percentage}})
</li>
<li>
SABAM: {{zone.stats.sabam}} ({{zone.stats.sabam_percentage}})
</li>
<li>
CFWB: {{zone.stats.cfwb}} ({{zone.stats.cfwb_percentage}})
</li>
</ul></li>
</ul>
{% endfor %}
</div>
{% endblock %}
nonstop/urls.py
View file @
2677317c
from
django.conf.urls
import
url
from
.views
import
SomaDayArchiveView
,
SomaDayArchiveCsvView
,
RedirectTodayView
,
TrackDetailView
,
ArtistDetailView
,
ArtistListView
from
.views
import
SomaDayArchiveView
,
SomaDayArchiveCsvView
,
RedirectTodayView
,
TrackDetailView
,
ArtistDetailView
,
ArtistListView
,
StatisticsView
urlpatterns
=
[
# Example: /2012/nov/10/
url
(
r'^$'
,
RedirectTodayView
.
as_view
(),
name
=
'nonstop-today'
),
url
(
r'^stats/$'
,
StatisticsView
.
as_view
(),
name
=
'stats-view'
),
url
(
r'^tracks/(?P<pk>\d+)/$'
,
TrackDetailView
.
as_view
(),
name
=
'track-view'
),
url
(
r'^artists/$'
,
ArtistListView
.
as_view
(),
name
=
'artist-list'
),
url
(
r'^artists/(?P<pk>\d+)/$'
,
ArtistDetailView
.
as_view
(),
name
=
'artist-view'
),
...
...
nonstop/views.py
View file @
2677317c
...
...
@@ -4,12 +4,13 @@ from cStringIO import StringIO
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpResponse
from
django.views.generic.base
import
RedirectView
from
django.views.generic.base
import
RedirectView
,
TemplateView
from
django.views.generic.dates
import
DayArchiveView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.models
import
SomaLogLine
,
Track
,
Artist
from
emissions.models
import
Nonstop
class
SomaDayArchiveView
(
DayArchiveView
):
queryset
=
SomaLogLine
.
objects
.
all
()
...
...
@@ -57,3 +58,46 @@ class ArtistDetailView(DetailView):
class
ArtistListView
(
ListView
):
model
=
Artist
class
ZoneStats
(
object
):
def
__init__
(
self
,
zone
):
self
.
zone
=
zone
def
count
(
self
,
**
kwargs
):
return
Track
.
objects
.
filter
(
nonstop_zones
=
self
.
zone
,
**
kwargs
).
count
()
def
percentage
(
self
,
**
kwargs
):
total
=
self
.
count
()
if
total
==
0
:
return
'-'
return
str
(
100
*
self
.
count
(
**
kwargs
)
/
total
)
def
instru
(
self
):
return
self
.
count
(
instru
=
True
)
def
instru_percentage
(
self
):
return
self
.
percentage
(
instru
=
True
)
def
sabam
(
self
):
return
self
.
count
(
sabam
=
True
)
def
sabam_percentage
(
self
):
return
self
.
percentage
(
sabam
=
True
)
def
cfwb
(
self
):
return
self
.
count
(
cfwb
=
True
)
def
cfwb_percentage
(
self
):
return
self
.
percentage
(
cfwb
=
True
)
class
StatisticsView
(
TemplateView
):
template_name
=
'nonstop/statistics.html'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
StatisticsView
,
self
).
get_context_data
(
**
kwargs
)
context
[
'zones'
]
=
Nonstop
.
objects
.
all
().
order_by
(
'start'
)
for
zone
in
context
[
'zones'
]:
zone
.
stats
=
ZoneStats
(
zone
)
return
context
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment