Commits

Ruslan Keba committed 7f0453f

single event view added

  • Participants
  • Parent commits 779b2e9

Comments (0)

Files changed (1)

 
 from datetime import datetime, timedelta
 
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404, redirect
 from django.template.context import RequestContext
 from django.views.decorators.cache import cache_page, cache_control
 
         events = Event.objects.filter(club=club).order_by('-date_begin')[:10]
 
     return events
+
+@cache_control(public=True)
+@cache_page(3*60*60)
+def event(request, year, event_id, club=None, template=None):
+    event = get_object_or_404(Event, id=event_id, club=club or Club.get_default())
+    if event.date_begin.year != int(year):
+        return redirect(event.get_absolute_url())
+    return render_to_response(template or'djclub/event.html', RequestContext(request, {'event': event}))