TrafoKing/apps/participants/views.py
Pedro Jose Romero Gombau b3f0d2a966 Init
2025-05-12 22:27:34 +02:00

24 lines
779 B
Python

# apps/participants/views.py
from django.views.generic import ListView, CreateView, View, TemplateView
from django.urls import reverse_lazy
from django.shortcuts import redirect
from .models import Participant
from .forms import ParticipantForm
from .services import calculate_scores
class ParticipantCreateView(CreateView):
model = Participant
form_class = ParticipantForm
template_name = "participants/form.html"
success_url = reverse_lazy("participant_new") # vuelve a sí misma
class CalculateView(View):
def post(self, request, *args, **kwargs):
calculate_scores()
return redirect("results")
class ResultsView(ListView):
model = Participant
template_name = "participants/results.html"
context_object_name = "participants"