summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-13 17:30:06 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-13 17:30:06 (GMT)
commit1ea3eeb4c99a365a38bf3b64605f91ac0dfea788 (patch)
treecff33d272fb12e2f23ca0ae2529e62e50e51a1c7
parent9a02c4960f14cbb7ee9f0df7d6b8708907d5af94 (diff)
simplified recommendations view, fixed template for recommendations, added template for recommendations box.
-rw-r--r--program/urls.py12
-rw-r--r--program/views.py18
-rw-r--r--templates/program/recommendations.html9
-rw-r--r--templates/program/recommendations_box.html20
4 files changed, 39 insertions, 20 deletions
diff --git a/program/urls.py b/program/urls.py
index 0a9fd5b..128f95f 100644
--- a/program/urls.py
+++ b/program/urls.py
@@ -3,14 +3,14 @@ from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from models import Host, Show, TimeSlot
-from views import RecommendationsView, RecommendationsBoxView, ShowListView
+from views import RecommendationsView, ShowListView
urlpatterns = patterns('',
- url('^hosts/$', ListView.as_view(model=Host,context_object_name='host_list')),
+ ('^hosts/$', ListView.as_view(model=Host, context_object_name='host_list')),
url('^host/(?P<pk>\d+)/$', DetailView.as_view(model=Host), name='host-detail'),
- url('^recommendations/$', RecommendationsView.as_view()),
- url('^recommendations_box/$', RecommendationsBoxView.as_view()),
- url('^shows/$', ShowListView.as_view()),
+ ('^recommendations/$', RecommendationsView.as_view()),
+ ('^recommendations_box/$', RecommendationsView.as_view(template_name='program/recommendations_box.html')),
+ ('^shows/$', ShowListView.as_view()),
url('^show/(?P<slug>[\w-]+)/$', DetailView.as_view(model=Show), name='show-detail'),
- url('^timeslot/(?P<pk>\d+)/$', DetailView.as_view(model=TimeSlot, context_object_name='timeslot'), name='timeslot-detail'),
+ url('^timeslot/(?P<pk>\d+)/$', DetailView.as_view(model=TimeSlot), name='timeslot-detail'),
) \ No newline at end of file
diff --git a/program/views.py b/program/views.py
index a3d1807..b9f476b 100644
--- a/program/views.py
+++ b/program/views.py
@@ -1,4 +1,4 @@
-from django.views.generic import ListView
+from django.views.generic.list import ListView
from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic
@@ -17,15 +17,13 @@ class ShowListView(ListView):
context['showtopic_list'] = ShowTopic.objects.all()
return context
-
+
class RecommendationsView(ListView):
- now = datetime.now()
- in_one_week = now + timedelta(weeks=1)
- context_object_name = 'recommendation_list'
+ context_object_name = 'recommendations'
template_name = 'program/recommendations.html'
- queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10]
-class RecommendationsBoxView(RecommendationsView):
- now = datetime.now()
- in_one_week = now + timedelta(weeks=1)
- queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:3]
+ def get_queryset(self):
+ now = datetime.now()
+ in_one_week = now + timedelta(weeks=1)
+
+ return Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] \ No newline at end of file
diff --git a/templates/program/recommendations.html b/templates/program/recommendations.html
index 499fe4e..aa5866a 100644
--- a/templates/program/recommendations.html
+++ b/templates/program/recommendations.html
@@ -5,13 +5,14 @@
<body>
<div id="recommendations">
-{% for note in recommendation_list %}
+{% for note in recommendations %}
<div class="show">
- <div class="broadcast-format">{{ note.show.broadcastformat }}</div>
- <div class="time-slot">{{ note.timeslot.start }}</div>
+ <div class="broadcastformat">{{ note.show.broadcastformat }}</div>
+ <div class="timeslot">{{ note.timeslot.start }}</div>
<div class="show-name"><a href="{% url show-detail note.show.slug %}">{{ note.show.name }}</a></div>
<div class="show-short-description">{{ note.show.short_description }}</div>
- <div class="note-title"><a href="{% url timeslot-detail note.timeslot.id %}">{{ note.title }}</a></div>
+ <div class="note-title">{{ note.title }}</div>
+ <div class="note-content">{{ note.content }}</div>
</div>
{% endfor %}
</div>
diff --git a/templates/program/recommendations_box.html b/templates/program/recommendations_box.html
new file mode 100644
index 0000000..d0ced36
--- /dev/null
+++ b/templates/program/recommendations_box.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+ <title>Recomendations Box</title>
+</head>
+<body>
+
+<div id="recommendations">
+{% for note in recommendations %}
+ <div class="show">
+ <div class="broadcastformat">{{ note.show.broadcastformat }}</div>
+ <div class="timeslot">{{ note.timeslot.start }}</div>
+ <div class="show-name"><a href="{% url show-detail note.show.slug %}">{{ note.show.name }}</a></div>
+ <div class="show-short-description">{{ note.show.short_description }}</div>
+ <div class="note-title"><a href="{% url timeslot-detail note.timeslot.id %}">{{ note.title }}</a></div>
+ </div>
+{% endfor %}
+</div>
+
+</body>
+</html> \ No newline at end of file