You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.3 KiB
88 lines
2.3 KiB
# -*- coding: utf-8 -*-
|
|
from django.contrib.syndication.views import Feed
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from exposition.models import Exposition
|
|
from theme.models import Theme
|
|
from country.models import Country
|
|
from city.models import City
|
|
|
|
EXPO_ON_PAGE = 10
|
|
|
|
# nearest expositions at all
|
|
|
|
class LatestExpositions(Feed):
|
|
title = u"Ближайшие выставки на expomap.ru"
|
|
link = '/rss/latest/'
|
|
description = u'Подписывайтесь на наш RSS-канал'
|
|
|
|
def items(self):
|
|
return Exposition.enable.upcoming()[:EXPO_ON_PAGE]
|
|
|
|
def item_title(self, item):
|
|
return item.name
|
|
|
|
def item_description(self, item):
|
|
return item.main_title
|
|
|
|
def item_link(self, item):
|
|
return '/expo/%s/'%item.url
|
|
|
|
NUM_ITEMS_ON_PAGE = 20
|
|
|
|
|
|
class CountryFeeds(Feed):
|
|
description_template = '/rss/country_feeds/'
|
|
|
|
def get_object(self, request, slug):
|
|
return get_object_or_404(Country, url=slug)
|
|
|
|
def title(self, obj):
|
|
return u"Ближайшие выставки %s:" % obj.inflect
|
|
|
|
def link(self,obj):
|
|
return obj.get_permanent_url()
|
|
|
|
def item_description(self, obj):
|
|
return obj.main_title
|
|
|
|
def items(self, obj):
|
|
return Exposition.enable.upcoming().filter(country=obj)[:NUM_ITEMS_ON_PAGE]
|
|
|
|
|
|
class CityFeeds(Feed):
|
|
description_template = '/rss/city_feeds/'
|
|
|
|
def get_object(self, request, slug):
|
|
return get_object_or_404(City, url=slug)
|
|
|
|
def title(self, obj):
|
|
return u"Ближайшие выставки в %s: " % obj.inflect
|
|
|
|
def link(self,obj):
|
|
return obj.get_permanent_url()
|
|
|
|
def item_description(self, obj):
|
|
return obj.main_title
|
|
|
|
def items(self, obj):
|
|
return Exposition.enable.upcoming().filter(city = obj)[:NUM_ITEMS_ON_PAGE]
|
|
|
|
|
|
class ThemeFeeds(Feed):
|
|
description_template = '/rss/theme_feeds/'
|
|
|
|
def get_object(self, request, slug):
|
|
return get_object_or_404(Theme, url=slug)
|
|
|
|
def title(self, obj):
|
|
return u"Ближайшие выставки %s: " % obj.inflect
|
|
|
|
def link(self,obj):
|
|
return obj.url
|
|
|
|
def item_description(self, obj):
|
|
return obj.main_title
|
|
|
|
def items(self, obj):
|
|
return Exposition.enable.upcoming().filter(theme = obj)[:NUM_ITEMS_ON_PAGE] |