24 lines
765 B
Python
24 lines
765 B
Python
from django.contrib.messages.views import SuccessMessageMixin
|
|
from django.urls import reverse_lazy
|
|
from django.views.generic.edit import CreateView
|
|
|
|
from .models import Presence
|
|
|
|
|
|
class HomeView(SuccessMessageMixin, CreateView):
|
|
"""Home page"""
|
|
|
|
template_name = "phd/home.html"
|
|
model = Presence
|
|
fields = ["name"]
|
|
success_url = reverse_lazy("home")
|
|
success_message = "Super, merci d'avoir prévenu !"
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context["has_replied"] = self.request.session.get("presence_has_replied", False)
|
|
return context
|
|
|
|
def form_valid(self, form):
|
|
self.request.session["presence_has_replied"] = True
|
|
return super().form_valid(form)
|