Commit 7446a45e authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

index speed

parent d38a524d
{% extends "base_generic.html" %}
{% load humanize %}
{% block dash-title %}
<b>{{form.text.value|default:"Fuentes de Información en Audio"|capfirst}}</b>
{% endblock %}
{% block dash %}
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Fuentes de Información
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Nombre</th>
<th>ID</th>
<th>url</th>
<th>Desde</th>
<th>Horas</th>
<th>Tipo</th>
</tr>
</thead>
<tbody>
{% for p in publishers %}
<tr class="odd gradeX">
<td>{{p.name}}</td>
<td>{{p.shortName}}</td>
<td><a href="{{p.url}}" target="blank">{{p.url}}</a></td>
<td>{{p.date}}</td>
<td><a href="{% url 'news-list'%}?publishers={{p.id}}&{{queryurl}}">{{p.news|intcomma}}</a></td>
<td>{{p.type}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
{% endblock %}
{% block scripts %}
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true,
"language": {"url": "/static/languages/Spanish.json" }
});
});
</script>
{% endblock %}
......@@ -140,7 +140,7 @@
</div>
</div>
</div>
<a href="{% url 'publishers-list'%}?{{ request.GET.urlencode }}">
<a href="{% url 'audio-list'%}?{{ request.GET.urlencode }}">
<div class="panel-footer">
<span class="pull-left">Ver lista</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
......
......@@ -12,6 +12,7 @@ urlpatterns = [
url(r'^ws/news/$', views.wsNewsList, name='ws-news-list'),
url(r'^ws/graphs/$', views.wsGraphs, name='ws-graphs'),
url(r'^ws/download/$', views.wsDownloadNews, name='ws-download-news'),
url(r'^audio/$', views.audioList, name='audio-list'),
]
No preview for this file type
......@@ -69,7 +69,7 @@ def index(request):
news = getNewsByRequest(request)
form = SearchForm(request.GET.copy())
if len(news)>0:
if news.count()>0:
if 'startDate' not in form or ('startDate' in form and form['startDate'].value == ""):
form.data.update({'startDate':news.earliest('date').date.strftime("%Y-%m-%d")})
......@@ -79,6 +79,7 @@ def index(request):
info = dict()
info['nPublishers'] = news.values('publisher').distinct().count()
info['nNews'] = news.count()
info['nAudio'] = Publisher.objects.all().filter(type="audio").count()
queryset = news.values("publisher").order_by("publisher").annotate(count = Count('publisher') )
......@@ -91,7 +92,7 @@ def index(request):
donutChart = [{"label": Publisher.objects.get(id=q['publisher']).name, "value":q["count"], "url":urlDict[q['publisher']]} for q in queryset]
publishers = Publisher.objects.all().filter( Q(id__in = news.values('publisher').distinct()))
publishers = Publisher.objects.all().filter( Q(id__in = news.values('publisher').distinct()))
queryset = news.values("publisher").annotate(day=TruncMonth('date') )
......@@ -103,6 +104,7 @@ def index(request):
histogramsData = [ { "date":d, "data":{ k:(dateDicts[k][d] if d in dateDicts[k] else 0) for k in dateDicts.keys()} } for d in dateList]
histogramsLabels = [p.shortName for p in publishers]
# return render(request,'index.html',{"form":form, "info":info, "donutChart":{}, "histogram": {}, "histogramsLabels":{}})
return render(request,'index.html',{"form":form, "info":info, "donutChart":donutChart, "histogram": histogramsData, "histogramsLabels":histogramsLabels})
#-------------------------------------------------------------------------------
def publisherList(request, type="all"):
......@@ -229,3 +231,12 @@ def wsDownloadNews(request):
response['Content-Disposition'] = 'attachment; filename="news_'+ str(int(time.time()))+'.zip"'
return response
#-------------------------------------------------------------------------------
def audioList(request):
form = SearchForm(request.GET)
publishers = Publisher.objects.all().filter( type="audio")
return render(request,'audioList.html',{"form":form, "publishers":publishers})
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment