# 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 django.urls import reverse from .models import Family, Challenge, FamilyMembership class FamilyTable(tables.Table): """ List all families """ 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',) row_attrs = { 'class': 'table-row', 'data-href': lambda record: reverse('family:family_detail', args=[record.pk]), 'style': 'cursor:pointer', } 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', 'description', 'points',) row_attrs = { 'class': 'table-row', 'data-href': lambda record: reverse('family:challenge_detail', args=[record.pk]), 'style': 'cursor:pointer', } class FamilyMembershipTable(tables.Table): """ List all family memberships. """ class Meta: attrs = { 'class': 'table table-condensed table-striped', 'style': 'table-layout: fixed;' } template_name = 'django_tables2/bootstrap4.html' fields = ('user',) model = FamilyMembership