Implement Duck listing
This commit is contained in:
parent
56d19e07d9
commit
8c9475d076
23
booking/templates/booking/duck_list.html
Normal file
23
booking/templates/booking/duck_list.html
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends 'front_template.html' %}
|
||||
{% load booking_tags %}
|
||||
|
||||
{% block body %}
|
||||
{% if duck_list %}
|
||||
{% for duck in duck_list %}
|
||||
<div class="duck" id="duck-icon-{{ duck.id }}" style="background-color: #{{ duck.color }};">
|
||||
{{ duck }}<br>
|
||||
{{ duck.species }}
|
||||
</div>
|
||||
<div class="profile" id="duck-profile-{{ duck.id }}">
|
||||
Employee for {{ duck.age|age_format:1 }}<br>
|
||||
Location: {{ duck.location }}<br>
|
||||
DPX: {{ duck.dpx }}<br>
|
||||
<div class="button" id="duck-book-{{ duck.id }}">book-button</div>
|
||||
<div class="button" id="duck-complist-{{ duck.id }}">complist-button</div>
|
||||
<div class="button" id="duck-namesugg-{{ duck.id }}">namesugg-button</div>
|
||||
<div class="button" id="duck-adopt-{{ duck.id }}">adopt-button</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<br class="clear">
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -5,7 +5,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rubber Duck Booking Tool</h1>
|
||||
<a href="{% url 'index' %}">Home</a>
|
||||
<a href="{% url 'booking:list' %}">Home</a>
|
||||
<a href="{% url 'booking:terms' %}">Terms and Conditions</a>
|
||||
<a href="{% url 'booking:vocabulary' %}">Vocabulary</a>
|
||||
<a href="{% url 'booking:disclaimer' %}">Disclaimer</a>
|
||||
|
@ -192,3 +192,25 @@ class BookingTimeTest(TestCase):
|
||||
def test_dpx(self):
|
||||
self.assertEqual(self.duck1.dpx(), 1/3)
|
||||
self.assertEqual(self.duck2.dpx(), 2/3)
|
||||
|
||||
class TestListing(TestCase):
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
species = Species()
|
||||
species.save()
|
||||
|
||||
loc = Location()
|
||||
loc.save()
|
||||
|
||||
user = User()
|
||||
user.save()
|
||||
|
||||
self.duck = Duck(species = species, location = loc, donated_by = user)
|
||||
self.duck.save()
|
||||
|
||||
def test_front_page(self):
|
||||
response = self.client.get('/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
self.assertEqual(len(response.context['duck_list']), 1)
|
||||
|
@ -1,8 +1,11 @@
|
||||
from django.conf.urls import patterns, url
|
||||
from django.views.generic.base import TemplateView
|
||||
|
||||
from .views import DuckListView
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', DuckListView.as_view(), name = 'list'),
|
||||
url(
|
||||
r'^vocabulary.html$',
|
||||
TemplateView.as_view(template_name = 'booking/vocabulary.html'),
|
||||
|
11
booking/views.py
Normal file
11
booking/views.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.shortcuts import render
|
||||
from django.views import generic
|
||||
|
||||
from .models import Duck
|
||||
|
||||
class DuckListView(generic.ListView):
|
||||
template_name = 'booking/duck_list.html'
|
||||
context_object_name = 'duck_list'
|
||||
|
||||
def get_queryset(self):
|
||||
return Duck.objects.all()
|
@ -1,10 +0,0 @@
|
||||
from django.test import TestCase, Client
|
||||
|
||||
class TestFront(TestCase):
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def test_front_page(self):
|
||||
response = self.client.get('/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -3,6 +3,5 @@ from django.views.generic import TemplateView
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url('^$', TemplateView.as_view(template_name = 'front_template.html'), name = 'index'),
|
||||
url('', include('booking.urls', namespace = 'booking')),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user