from datetime import datetime

from django.template.context import RequestContext
from django.views.generic import list_detail
from django.shortcuts import render_to_response, get_object_or_404

from remember.models import *
from newsroom.models import WebEdition


def index(request):
    return render_to_response(
        "remember/index.html", locals(), context_instance=RequestContext(request)
    )


def remembrance_index(request):
    edition = WebEdition.objects.published().latest()
    remembrances = edition.remembrances.all()
    return render_to_response(
        "remember/remembrance_index.html",
        locals(),
        context_instance=RequestContext(request),
    )


def inmemoriam_index(request):
    edition = WebEdition.objects.published().latest()
    inmemoriams = edition.inmemoriams.all()
    return render_to_response(
        "remember/inmemoriam_index.html",
        locals(),
        context_instance=RequestContext(request),
    )


def announcement_index(request):
    edition = WebEdition.objects.published().latest()
    announcements = edition.death_announcements.all()
    return render_to_response(
        "remember/announcement_index.html",
        locals(),
        context_instance=RequestContext(request),
    )


def services_index(request):
    edition = WebEdition.objects.published().latest()
    services = edition.memorial_services.all()
    return render_to_response(
        "remember/service_index.html",
        locals(),
        context_instance=RequestContext(request),
    )


"""    
def remembrance_detail(request, slug):
    remembrance=get_object_or_404(Remembrance, slug=slug)
    return render_to_response('remember/remembrance_detail.html', locals(),
                              context_instance=RequestContext(request))

def inmemoriam_detail(request, slug):
    inmemoriam=get_object_or_404(Inmemoriam, slug=slug)
    return render_to_response('remember/inmemoriam_detail.html', locals(),
                              context_instance=RequestContext(request))
"""
