2015-03-03 18:40:18 +00:00
|
|
|
# from django.views.generic.list_detail import object_list
|
2017-11-03 15:58:24 +00:00
|
|
|
from django.shortcuts import render
|
2010-09-26 21:32:53 +00:00
|
|
|
from django.http import Http404, HttpResponse
|
|
|
|
from django.template import loader
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2015-03-09 00:54:05 +00:00
|
|
|
from conservancy.apps.events.models import Event
|
2015-03-03 18:40:18 +00:00
|
|
|
# for debugging...
|
|
|
|
from django.http import HttpResponse
|
2010-09-26 21:32:53 +00:00
|
|
|
|
|
|
|
def event_detail(request, year, slug, queryset, **kwargs):
|
|
|
|
"""This view shows event detail.
|
|
|
|
|
|
|
|
Nothing special, but it is necessary because
|
|
|
|
django.views.generic.date_based.object_detail only works with
|
|
|
|
slugs that are unique and specified by day, but we make slugs
|
|
|
|
unique by year.
|
|
|
|
"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
event = queryset.get(date__year=year, slug__exact=slug)
|
|
|
|
except ObjectDoesNotExist:
|
2021-11-26 02:00:20 +00:00
|
|
|
raise Http404("Event does not exist")
|
2017-11-03 15:58:24 +00:00
|
|
|
return render(request, 'events/event_detail.html', {'event': event})
|
2010-09-26 21:32:53 +00:00
|
|
|
|
|
|
|
def custom_index(request, queryset, *args, **kwargs):
|
|
|
|
"""Scrollable index of future and past events, with date index.
|
|
|
|
"""
|
|
|
|
|
|
|
|
future_events = None
|
2021-11-26 02:00:20 +00:00
|
|
|
if "page" not in request.GET:
|
2010-09-26 21:32:53 +00:00
|
|
|
future_events = Event.future.all().order_by("date")
|
|
|
|
|
|
|
|
date_list = queryset.dates(kwargs['date_field'], 'year')
|
|
|
|
|
|
|
|
kwargs = dict(kwargs, extra_context={'date_list': date_list,
|
|
|
|
'future_events': future_events})
|
|
|
|
del kwargs['date_field']
|
|
|
|
del kwargs['allow_future']
|
|
|
|
|
2015-03-03 18:40:18 +00:00
|
|
|
# return object_list(request, queryset, *args, **kwargs)
|
|
|
|
return HttpResponse("FIXME: events must be updated like blog and news.")
|
2010-09-26 21:32:53 +00:00
|
|
|
|
|
|
|
def future_event_ics(request, queryset, *args, **kwargs):
|
|
|
|
"""ICS calendar view of future events
|
|
|
|
|
|
|
|
This view just renders information into a template that looks like
|
|
|
|
an ics file. If in the future we want a 'real' implementation of
|
|
|
|
this function, there is a python 'vobject' library that can be
|
|
|
|
used. Search google for details, or see
|
|
|
|
http://www.technobabble.dk/2008/mar/06/exposing-calendar-events-using-icalendar-django/
|
|
|
|
Hopefully at some point this functionality is integrated into
|
|
|
|
django.contrib.
|
|
|
|
"""
|
|
|
|
|
|
|
|
future_events = Event.future.all().order_by("date")
|
|
|
|
|
|
|
|
return HttpResponse(loader.render_to_string('events/calendar.ics',
|
|
|
|
{'events': future_events}),
|
|
|
|
mimetype='text/calendar')
|