mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-06 23:44:01 +02:00
ListViews et templates
This commit is contained in:
40
apps/family/tables.py
Normal file
40
apps/family/tables.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import django_tables2 as tables
|
||||
from django_tables2 import A
|
||||
|
||||
from .models import Family, Challenge
|
||||
|
||||
|
||||
class FamilyTable(tables.Table):
|
||||
"""
|
||||
List all families
|
||||
"""
|
||||
name = tables.LinkColumn(
|
||||
"family:family_detail",
|
||||
args=[A("pk")],
|
||||
)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
model = Family
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('name', 'score', 'rank',)
|
||||
order_by = ('rank',)
|
||||
|
||||
|
||||
class ChallengeTable(tables.Table):
|
||||
"""
|
||||
List all challenges
|
||||
"""
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
order_by = ('id',)
|
||||
model = Challenge
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('name', 'points', 'category',)
|
Reference in New Issue
Block a user