From 055aa6f5f88a587ff8414fbbc30cb3db2eb94189 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Fri, 9 May 2014 14:42:02 +0200 Subject: [PATCH] agenda: raising Http404 if event is canceled Closes #4718 --- calebasse/agenda/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/calebasse/agenda/views.py b/calebasse/agenda/views.py index ab2a89e..afe7ce2 100644 --- a/calebasse/agenda/views.py +++ b/calebasse/agenda/views.py @@ -7,7 +7,7 @@ from itertools import chain from django.contrib import messages from django.db.models import Q from django.shortcuts import redirect, get_object_or_404 -from django.http import HttpResponseRedirect, HttpResponse +from django.http import HttpResponseRedirect, HttpResponse, Http404 from django.conf import settings from calebasse.cbv import TemplateView, CreateView, UpdateView @@ -166,7 +166,10 @@ class NewAppointmentView(cbv.ReturnToObjectMixin, cbv.ServiceFormMixin, CreateVi class TodayOccurrenceMixin(object): def get_object(self, queryset=None): o = super(TodayOccurrenceMixin, self).get_object(queryset) - return o.today_occurrence(self.date) + obj = o.today_occurrence(self.date) + if obj: + return obj + raise Http404 class BaseAppointmentView(UpdateView): @@ -204,7 +207,6 @@ class UpdateAppointmentView(TodayOccurrenceMixin, BaseAppointmentView): else: return self.form_class - class UpdatePeriodicAppointmentView(BaseAppointmentView): form_class = UpdatePeriodicAppointmentForm template_name = 'agenda/new-appointment.html' -- 2.0.0.rc2