mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-30 15:21:17 +02:00
Add survey feature
This commit is contained in:
31
survey/tables.py
Normal file
31
survey/tables.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (C) 2025 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
import django_tables2 as tables
|
||||
|
||||
from .models import Survey
|
||||
|
||||
|
||||
class SurveyTable(tables.Table):
|
||||
survey_id = tables.LinkColumn(
|
||||
'survey:survey_detail',
|
||||
args=[tables.A('survey_id')],
|
||||
verbose_name=lambda: _("survey identifier").capitalize(),
|
||||
)
|
||||
|
||||
nb_completed = tables.Column(
|
||||
verbose_name=_("completed").capitalize,
|
||||
accessor='survey_id'
|
||||
)
|
||||
|
||||
def render_nb_completed(self, record):
|
||||
return f"{record.completed.count()}/{record.participants.count()}"
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped',
|
||||
}
|
||||
model = Survey
|
||||
fields = ('survey_id', 'name', 'invite_team', 'invite_coaches', 'tournament', 'nb_completed',)
|
||||
order_by = ('survey_id',)
|
Reference in New Issue
Block a user