Races: really basic races site with a detail page
getting this out there so that i maybe feel motivated to make it not suck in the future
This commit is contained in:
parent
db1f77e102
commit
54b6da689d
|
@ -6,6 +6,8 @@ admin.autodiscover()
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', 'dr_botzo.views.home', name='home'),
|
url(r'^$', 'dr_botzo.views.home', name='home'),
|
||||||
|
|
||||||
|
url(r'^races/', include('races.urls')),
|
||||||
|
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
from django.conf.urls import patterns, url
|
||||||
|
|
||||||
|
urlpatterns = patterns('races.views',
|
||||||
|
url(r'^$', 'index', name='races_index'),
|
||||||
|
url(r'^race/(?P<race_id>[A-Za-z0-9]+)/$', 'race_detail', name='race_detail'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# vi:tabstop=4:expandtab:autoindent
|
|
@ -0,0 +1,21 @@
|
||||||
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
|
||||||
|
from races.models import Race, Racer, RaceUpdate
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
"""Display a list of races."""
|
||||||
|
|
||||||
|
races = Race.objects.all()
|
||||||
|
|
||||||
|
return render(request, 'races/index.html', {'races': races})
|
||||||
|
|
||||||
|
|
||||||
|
def race_detail(request, race_id):
|
||||||
|
"""Display a race detail."""
|
||||||
|
|
||||||
|
race = get_object_or_404(Race, pk=race_id)
|
||||||
|
|
||||||
|
return render(request, 'races/race_detail.html', {'race': race})
|
||||||
|
|
||||||
|
# vi:tabstop=4:expandtab:autoindent
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}races{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<ul>
|
||||||
|
{% for race in races %}
|
||||||
|
<li><a href="{% url 'race_detail' race.key %}">{{ race.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
<!--
|
||||||
|
vi:tabstop=4:expandtab:autoindent
|
||||||
|
-->
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}race: {{ race.name }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<ul>
|
||||||
|
{% for update in race.raceupdate_set.all %}
|
||||||
|
<li>{{ update.racer.nick }} — {{ update.update }} — {{ update.event_time }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
<!--
|
||||||
|
vi:tabstop=4:expandtab:autoindent
|
||||||
|
-->
|
Loading…
Reference in New Issue