Skip to content

Commit

Permalink
Basic session views
Browse files Browse the repository at this point in the history
  • Loading branch information
themichaellai committed Aug 14, 2013
1 parent 9ce7682 commit 6de00f3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
11 changes: 2 additions & 9 deletions log_parser/urls.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'log_parser.views.home', name='home'),
# url(r'^log_parser/', include('log_parser.foo.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^view/', include('parse.urls')),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
23 changes: 23 additions & 0 deletions parse/templates/sessions/show.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<html>
<head>
<title>Sessions</title>
</head>
<body>
<table>
<tr>
<th>UID</th>
<th>Start Time</th>
<th>End Time</th>
<th>Active?</th>
</tr>
{% for session in sessions %}
<tr>
<td>{{ session.uid }}</td>
<td>{{ session.start_time }}</td>
<td>{{ session.end_time }}</td>
<td>{{ session.active }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
4 changes: 4 additions & 0 deletions parse/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.conf.urls import patterns, url
urlpatterns = patterns('parse.views',
url(r'^sessions/$', 'show_sessions', name='show-sessions'),
)
11 changes: 10 additions & 1 deletion parse/views.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Create your views here.
from parse.models import RelaySession, RelayEntry
from django.shortcuts import get_object_or_404, render


def show_sessions(request):
active = True if request.GET.get('active') else False
sessions = RelaySession.objects.filter(active=active)
return render(request, 'sessions/show.html', {
'sessions': sessions
})

0 comments on commit 6de00f3

Please sign in to comment.