2021-04-29 00:27:33 +02:00
|
|
|
from django.http import HttpResponseRedirect
|
2020-09-10 15:06:53 +02:00
|
|
|
from django.urls import reverse_lazy
|
2021-04-29 00:27:33 +02:00
|
|
|
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
|
|
|
|
|
2020-09-10 15:06:53 +02:00
|
|
|
from actu.models import Actu
|
2021-04-29 00:27:33 +02:00
|
|
|
from gestion.mixins import ChefRequiredMixin
|
2020-09-10 15:06:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ActuList(ChefRequiredMixin, ListView):
|
|
|
|
model = Actu
|
|
|
|
context_object_name = "actus"
|
|
|
|
template_name = "actu/actualité.html"
|
|
|
|
|
|
|
|
|
|
|
|
class ActuCreate(ChefRequiredMixin, CreateView):
|
|
|
|
model = Actu
|
2021-04-29 00:27:33 +02:00
|
|
|
fields = ["text", "order", "text_en"]
|
2020-09-10 15:06:53 +02:00
|
|
|
template_name = "actu/create_actu.html"
|
|
|
|
success_url = reverse_lazy("actu:liste")
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
|
|
|
actu = form.save(commit=False)
|
|
|
|
actu.save()
|
|
|
|
return HttpResponseRedirect(self.success_url)
|
|
|
|
|
|
|
|
|
|
|
|
class ActuUpdate(ChefRequiredMixin, UpdateView):
|
|
|
|
model = Actu
|
2021-04-29 00:27:33 +02:00
|
|
|
fields = ["text", "order", "text_en"]
|
2020-09-10 15:06:53 +02:00
|
|
|
template_name = "actu/update_actu.html"
|
|
|
|
success_url = reverse_lazy("actu:liste")
|
|
|
|
|
|
|
|
|
|
|
|
class ActuDelete(ChefRequiredMixin, DeleteView):
|
|
|
|
model = Actu
|
|
|
|
template_name = "actu/delete_actu.html"
|
|
|
|
success_url = reverse_lazy("actu:liste")
|