from django.views.generic.create_update import get_model_and_form_class, apply_extra_context, redirect, update_object, lookup_object, delete_object
from django.views.generic import UpdateView, DeleteView, CreateView, DetailView
from django.utils.decorators import method_decorator
+from django.contrib import messages
from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet
from extra_views.generic import GenericInlineFormSet
class DetailInvoice(DetailView):
model = Invoice
+ def get(self, request, *args, **kwargs):
+ i = get_object_or_404(Invoice, pk=kwargs["pk"])
+ if i.due_days < 0:
+ messages.error(request, "This invoice is overdue")
+ elif i.due_days < 3:
+ messages.warning(request, "This invoice is soon due")
+ return super(DetailInvoice, self).get(request, *args, **kwargs)
+
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(DetailInvoice, self).dispatch(*args, **kwargs)