nk20/apps/activity/views.py

40 lines
1019 B
Python
Raw Normal View History

2020-03-01 16:16:38 +00:00
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.mixins import LoginRequiredMixin
2020-03-26 23:40:35 +00:00
from django.views.generic import CreateView, DetailView, UpdateView, TemplateView
2020-03-27 00:31:54 +00:00
from django.utils.translation import gettext_lazy as _
2020-03-01 16:16:38 +00:00
from django_tables2.views import SingleTableView
2020-03-27 00:31:54 +00:00
from .forms import ActivityForm
2020-03-26 23:40:35 +00:00
from .models import Activity
2020-03-01 16:16:38 +00:00
class ActivityCreateView(LoginRequiredMixin, CreateView):
2020-03-01 16:16:38 +00:00
model = Activity
2020-03-27 00:31:54 +00:00
form_class = ActivityForm
2020-03-26 23:40:35 +00:00
class ActivityListView(LoginRequiredMixin, SingleTableView):
2020-03-01 16:16:38 +00:00
model = Activity
2020-03-27 00:31:54 +00:00
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['title'] = _("Upcoming activities")
return ctx
2020-03-01 16:16:38 +00:00
2020-03-26 23:40:35 +00:00
class ActivityDetailView(LoginRequiredMixin, DetailView):
2020-03-01 16:16:38 +00:00
model = Activity
2020-03-26 23:40:35 +00:00
class ActivityUpdateView(LoginRequiredMixin, UpdateView):
2020-03-01 16:16:38 +00:00
model = Activity
2020-03-27 00:31:54 +00:00
form_class = ActivityForm
2020-03-26 23:40:35 +00:00
class ActivityEntryView(LoginRequiredMixin, TemplateView):
2020-03-01 16:16:38 +00:00
pass