Add more feedback messages
This commit is contained in:
parent
0b574227fb
commit
7959c56c2b
@ -1,6 +1,7 @@
|
|||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.shortcuts import get_object_or_404, reverse
|
from django.shortcuts import get_object_or_404, reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
@ -64,22 +65,24 @@ class ServiceView(
|
|||||||
|
|
||||||
|
|
||||||
class ServiceUpdateView(
|
class ServiceUpdateView(
|
||||||
LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, UpdateView
|
||||||
):
|
):
|
||||||
model = Service
|
model = Service
|
||||||
form_class = ServiceForm
|
form_class = ServiceForm
|
||||||
template_name = "dashboard/pages/service_update.html"
|
template_name = "dashboard/pages/service_update.html"
|
||||||
permission_required = "core.change_service"
|
permission_required = "core.change_service"
|
||||||
|
success_message = "Your changes were saved successfully."
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("dashboard:service", kwargs={"pk": self.object.uuid})
|
return reverse("dashboard:service", kwargs={"pk": self.object.uuid})
|
||||||
|
|
||||||
|
|
||||||
class ServiceDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteView):
|
class ServiceDeleteView(LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, DeleteView):
|
||||||
model = Service
|
model = Service
|
||||||
form_class = ServiceForm
|
form_class = ServiceForm
|
||||||
template_name = "dashboard/pages/service_delete.html"
|
template_name = "dashboard/pages/service_delete.html"
|
||||||
permission_required = "core.delete_service"
|
permission_required = "core.delete_service"
|
||||||
|
success_message = "The service was deleted successfully."
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("dashboard:dashboard")
|
return reverse("dashboard:dashboard")
|
||||||
|
Loading…
Reference in New Issue
Block a user