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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
from django.views.generic import ListView
from django.views.generic.detail import DetailView
from django.views.generic.dates import DateDetailView
from django.urls import reverse
from django.views.generic.dates import YearArchiveView, MonthArchiveView
from django.contrib.syndication.views import Feed
from django.apps import apps
from django.shortcuts import get_object_or_404
from django.conf import settings
from django.db.models import Q
from utils.views import PaginatedListView, LuxDetailView
#from ..models import Entry, HomepageCurrator, Home
from ..models import Post, PostType
from lttr.models import NewsletterMailing
from locations.models import LuxCheckIn, Country, Region, Location
from sightings.models import Sighting
class RangeDetailView(LuxDetailView):
model = Post
slug_field = "slug"
template_name = "posts/range_detail.html"
def get_context_data(self, **kwargs):
context = super(RangeDetailView, 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
context['mailing'] = NewsletterMailing.objects.get(post__id=self.object.id)
return context
class RangeListView(PaginatedListView):
"""
Return a list of Newsletter posts in reverse chronological order
"""
model = Post
template_name = "posts/range_list.html"
queryset = Post.objects.filter(post_type=PostType.RANGE,status=1).order_by('-pub_date')
def get_context_data(self, **kwargs):
context = super(RangeListView, self).get_context_data(**kwargs)
context['breadcrumbs'] = ['range',]
return context
class RangeRSSFeedView(Feed):
title = "Range: A weekly photo, developed"
link = "/range/"
description = "Range: A weekly photo, developed"
description_template = 'feeds/blog_description.html'
def items(self):
return Post.objects.filter(status__exact=1).filter(post_type=PostType.RANGE).order_by('-pub_date')[:10]
def item_pubdate(self, item):
"""
Takes an item, as returned by items(), and returns the item's
pubdate.
"""
return item.pub_date
|