from django.contrib.syndication.views import Feed
from darkroom.models import Photo, Gallery
from django.conf import settings
from django.contrib.sites.models import Site


class LatestPhotosFeed(Feed):
    current_site = Site.objects.get(id=settings.SITE_ID)
    title = current_site.name + " multimedia"
    link = current_site.domain
    if current_site.name == "penobscotbaypress.com":
        description = "Photos from the Blue Hill Peninsula and Deer Isle in Maine."
    elif current_site.name == "castinepatriot.com":
        description = "Photos from around Castine and Penobscot, Maine."
    elif current_site.name == "islandadvantages.com":
        description = "Photos from around Deer Isle and Stonington, Maine."
    elif current_site.name == "weeklypacket.com":
        description = "Photos from around the towns of the Blue Hill Peninsula Maine."

    def items(self):
        return Photo.objects.published()[:30]

    def item_title(self, item):
        return item.title

    def item_link(self, item):
        return item.get_absolute_url()

    # def item_enclosure_url(self, item):
    #    return item.get_detail_url()

    def item_description(self, item):
        return item.description
