forked from DataSparkRI/Datahub-Indicators
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter L
committed
Jan 10, 2011
1 parent
a72eb3f
commit 84a4b33
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
|
||
from django.shortcuts import render_to_response, get_object_or_404 | ||
from django.template import RequestContext | ||
from django.contrib.admin.views.decorators import staff_member_required | ||
|
||
def _collect_batch_info(uuid): | ||
path = './media/batches/%s/' % uuid | ||
return { | ||
'uuid': uuid, | ||
'finished': os.path.exists(os.path.join(path,'batch.tar.gz')), | ||
'num_indicators': len([entry for entry in os.listdir(path) if entry.endswith('.csv')]) / 2 | ||
} | ||
|
||
@staff_member_required | ||
def indicator_batch_list(request): | ||
""" Displays the status of an indicator debug batch. | ||
The directory with the name specified by the uuid parameter is searched for | ||
output, debug and log files. Return 404 if not found. If log.txt exists, but | ||
the "end batch" marker isn't found, output the log file contents, but do not | ||
offer a download link. | ||
If the batch is complete, provide a tar/gzip of the files. | ||
""" | ||
return render_to_response('admin/indicator_batch_list.html', | ||
{'batches': map(lambda b: _collect_batch_info(b), os.listdir('./media/batches/'))}, | ||
context_instance=RequestContext(request)) | ||
|
||
@staff_member_required | ||
def indicator_batch(request, uuid): | ||
""" Displays the status of an indicator debug batch. | ||
The directory with the name specified by the uuid parameter is searched for | ||
output, debug and log files. Return 404 if not found. If log.txt exists, but | ||
the "end batch" marker isn't found, output the log file contents, but do not | ||
offer a download link. | ||
If the batch is complete, provide a tar/gzip of the files. | ||
""" | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends "admin/change_list.html" %} | ||
|
||
{% block title %}List of debug batches{% endblock %} | ||
|
||
{% block content %} | ||
<div id="content-main"> | ||
<h1>List of debug batches completed or in progress:</h1> | ||
{% if batches %} | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>uuid</th> | ||
<th># indicators</th> | ||
<th>Finished?</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for batch in batches %} | ||
<tr class="{% cycle "row1" "row2" %}"> | ||
<td><a href="#">{{ batch.uuid }}</a></td> | ||
<td>{{ batch.num_indicators }}</td> | ||
<td>{{ batch.finished }}</td> | ||
</tr> | ||
|
||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endif %} | ||
{% endblock content %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends "admin/app_index.html" %} | ||
|
||
{% block content %} | ||
{{ block.super }} | ||
<div id="content-main"> | ||
<div class="module"> | ||
<table> | ||
<tr> | ||
<th scope="row"><a href="{% url indicators_admin_batch_list %}">Debug Batches</a></th> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('', | ||
url(r'^indicator_batches/$', 'indicators.admin_views.indicator_batch_list', name="indicators_admin_batch_list"), | ||
url(r'^indicator_batches/([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})$', 'indicators.admin_views.indicator_batch', name="indicators_admin_batch"), | ||
) | ||
|