Skip to content
Snippets Groups Projects
tables.py 941 B
Newer Older
ynerant's avatar
ynerant committed
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
ynerant's avatar
ynerant committed
# SPDX-License-Identifier: GPL-3.0-or-later

import django_tables2 as tables
from django.contrib.auth.models import User
from treasury.models import SogeCredit

ynerant's avatar
ynerant committed

class FutureUserTable(tables.Table):
ynerant's avatar
ynerant committed
    """
    Display the list of pre-registered users
    """
    phone_number = tables.Column(accessor='profile__phone_number')
ynerant's avatar
ynerant committed

    section = tables.Column(accessor='profile__section')
ynerant's avatar
ynerant committed

    class Meta:
        attrs = {
            'class': 'table table-condensed table-striped table-hover'
        }
        template_name = 'django_tables2/bootstrap4.html'
        fields = ('last_name', 'first_name', 'username', 'email', )
        model = User
        row_attrs = {
            'class': lambda record: 'table-row'
                                    + (' bg-warning' if SogeCredit.objects.filter(user=record).exists() else ''),
ynerant's avatar
ynerant committed
            'data-href': lambda record: record.pk
        }