-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from ccnmtl/streamlogs-basic-views
Streamlogs basic views
- Loading branch information
Showing
4 changed files
with
106 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
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 |
---|---|---|
@@ -1,7 +1,24 @@ | ||
from django.conf.urls import url | ||
from django.contrib.auth.decorators import user_passes_test | ||
from django.views.generic.detail import DetailView | ||
from django.views.generic.list import ListView | ||
|
||
from wardenclyffe.main.views import is_staff | ||
|
||
from .models import StreamLog | ||
from .views import LogView | ||
|
||
staff_only = user_passes_test(lambda u: is_staff(u)) | ||
|
||
urlpatterns = [ | ||
url(r'^$', LogView.as_view(), name='streamlogs'), | ||
url(r'list/$', staff_only( | ||
ListView.as_view( | ||
model=StreamLog, | ||
paginate_by=50, | ||
)), name='streamlogs-list'), | ||
url(r'(?P<pk>\d+)/$', staff_only( | ||
DetailView.as_view( | ||
model=StreamLog, | ||
)), name='streamlogs-detail'), | ||
] |
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,32 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<p><a href="{% url 'streamlogs-list' %}">Back to List</a></p> | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<th>Timestamp</th><td>{{ object.request_at }}</td> | ||
</tr> | ||
<tr> | ||
<th>Filename</th><td><tt>{{object.filename}}</tt></td> | ||
</tr> | ||
<tr> | ||
<th>Remote Address</th><td><tt>{{object.remote_addr}}</tt></td> | ||
</tr> | ||
<tr> | ||
<th>Offset</th><td>{{object.offset}}</td> | ||
</tr> | ||
<tr> | ||
<th>Referer</th><td><tt>{{object.referer}}</tt></td> | ||
</tr> | ||
<tr> | ||
<th>User Agent</th><td>{{object.user_agent}}</td> | ||
</tr> | ||
<tr> | ||
<th>Access Mode</th><td>{{object.access}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
{% 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,54 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
|
||
{% if is_paginated %} | ||
<div class="pagination"> | ||
<span class="page-links"> | ||
{% if page_obj.has_previous %} | ||
<a href="?page={{ page_obj.previous_page_number }}">< previous</a> | ||
{% endif %} | ||
<span class="page-current"> | ||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. | ||
</span> | ||
{% if page_obj.has_next %} | ||
<a href="?page={{ page_obj.next_page_number }}">next ></a> | ||
{% endif %} | ||
</span> | ||
</div> | ||
{% endif %} | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>timestamp</th> | ||
<th>filename</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for object in object_list %} | ||
<tr> | ||
<td><a href="{% url 'streamlogs-detail' object.pk %}">{{object.request_at}}</a></td> | ||
<td><tt>{{object.filename}}</tt></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
{% if is_paginated %} | ||
<div class="pagination"> | ||
<span class="page-links"> | ||
{% if page_obj.has_previous %} | ||
<a href="?page={{ page_obj.previous_page_number }}">< previous</a> | ||
{% endif %} | ||
<span class="page-current"> | ||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. | ||
</span> | ||
{% if page_obj.has_next %} | ||
<a href="?page={{ page_obj.next_page_number }}">next ></a> | ||
{% endif %} | ||
</span> | ||
</div> | ||
{% endif %} | ||
|
||
{% endblock %} |