blob: 00796523283455c550c1fb9800432545274e0625 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
from django.views.generic import ListView
from django.views.generic.detail import DetailView
from django.contrib.syndication.views import Feed
from django.apps import apps
from django.conf import settings
from utils.views import PaginatedListView, LuxDetailView
from ..models import Post, Trip
class TripListView(PaginatedListView):
"""
Return a list of Entries in reverse chronological order
"""
model = Trip
template_name = "posts/trips_list.html"
class TripDetailView(LuxDetailView):
model = Post
slug_field = "slug"
def get_queryset(self):
queryset = super(PostDetailView, self).get_queryset()
return queryset.select_related('location').prefetch_related('field_notes')
def get_context_data(self, **kwargs):
context = super(PostDetailView, self).get_context_data(**kwargs)
related = []
for obj in self.object.related.all():
model = apps.get_model(obj.model_name.app_label, obj.model_name.model)
related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date))
context['related'] = related
return context
def get_template_names(self):
obj = self.get_object()
return ["posts/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html']
|