mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-06 15:24:01 +02:00
ListViews et templates
This commit is contained in:
@ -1,3 +1,63 @@
|
||||
from django.shortcuts import render
|
||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Create your views here.
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import DetailView, UpdateView
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_tables2 import SingleTableView
|
||||
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
||||
|
||||
from .models import Family, Challenge
|
||||
from .tables import FamilyTable, ChallengeTable
|
||||
|
||||
|
||||
class FamilyCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
"""
|
||||
Create family
|
||||
"""
|
||||
model = Family
|
||||
extra_context = {"title": _('Create family')}
|
||||
|
||||
def get_sample_object(self):
|
||||
return Family(
|
||||
name="",
|
||||
description="Sample family",
|
||||
score=0,
|
||||
rank=0,
|
||||
)
|
||||
|
||||
|
||||
class FamilyListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||
"""
|
||||
List existing Families
|
||||
"""
|
||||
model = Family
|
||||
table_class = FamilyTable
|
||||
extra_context = {"title": _('Families list')}
|
||||
|
||||
|
||||
class FamilyDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
"""
|
||||
Display details of a family
|
||||
"""
|
||||
model = Family
|
||||
context_object_name = "family"
|
||||
extra_context = {"title": _('Family detail')}
|
||||
|
||||
|
||||
class FamilyUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||
"""
|
||||
Update the information of a family.
|
||||
"""
|
||||
model = Family
|
||||
context_object_name = "family"
|
||||
extra_context = {"title": _('Update family')}
|
||||
|
||||
|
||||
class ChallengeListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||
"""
|
||||
List all challenges
|
||||
"""
|
||||
model = Challenge
|
||||
table_class = ChallengeTable
|
||||
extra_context = {"title": _('Challenges list')}
|
||||
|
Reference in New Issue
Block a user