mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-21 13:18:22 +02:00
Add calendar view
This commit is contained in:
@ -1,7 +1,23 @@
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
import django_tables2 as tables
|
||||
|
||||
from .models import Team
|
||||
from .models import Phase, Team
|
||||
|
||||
|
||||
class CalendarTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table condensed table-striped',
|
||||
}
|
||||
row_attrs = {
|
||||
'class': lambda record: 'bg-success' if timezone.now() > record.end else
|
||||
'bg-waring' if timezone.now() > record.start else
|
||||
'bg-danger'
|
||||
}
|
||||
model = Phase
|
||||
fields = ('phase_number', 'description', 'start', 'end',)
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
|
||||
|
||||
# noinspection PyTypeChecker
|
||||
|
11
apps/participation/templates/participation/phase_list.html
Normal file
11
apps/participation/templates/participation/phase_list.html
Normal file
@ -0,0 +1,11 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load django_tables2 i18n %}
|
||||
|
||||
{% block contenttitle %}
|
||||
<h2>{% trans "Calendar" %}</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% render_table table %}
|
||||
{% endblock %}
|
@ -1,7 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView,\
|
||||
TeamAuthorizationsView, TeamDetailView, TeamUpdateView, UploadVideoView
|
||||
from .views import CalendarView, CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, \
|
||||
ParticipationDetailView,TeamAuthorizationsView, TeamDetailView, TeamUpdateView, UploadVideoView
|
||||
|
||||
|
||||
app_name = "participation"
|
||||
@ -16,4 +16,5 @@ urlpatterns = [
|
||||
path("detail/", MyParticipationDetailView.as_view(), name="my_participation_detail"),
|
||||
path("detail/<int:pk>/", ParticipationDetailView.as_view(), name="participation_detail"),
|
||||
path("detail/upload-video/<int:pk>/", UploadVideoView.as_view(), name="upload_video"),
|
||||
path("calendar/", CalendarView.as_view(), name="calendar"),
|
||||
]
|
||||
|
@ -13,12 +13,14 @@ from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, DetailView, FormView, RedirectView, UpdateView
|
||||
from django.views.generic.edit import FormMixin, ProcessFormView
|
||||
from django_tables2 import SingleTableView
|
||||
from magic import Magic
|
||||
from registration.models import AdminRegistration
|
||||
|
||||
from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, TeamForm, UploadVideoForm,\
|
||||
ValidateParticipationForm
|
||||
from .models import Participation, Team, Video
|
||||
from .models import Participation, Phase, Team, Video
|
||||
from .tables import CalendarTable
|
||||
|
||||
|
||||
class CreateTeamView(LoginRequiredMixin, CreateView):
|
||||
@ -274,3 +276,8 @@ class UploadVideoView(LoginRequiredMixin, UpdateView):
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,))
|
||||
|
||||
|
||||
class CalendarView(SingleTableView):
|
||||
table_class = CalendarTable
|
||||
model = Phase
|
||||
|
Reference in New Issue
Block a user