2020-12-27 10:49:54 +00:00
|
|
|
# Copyright (C) 2020 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 Registration
|
|
|
|
|
|
|
|
|
|
|
|
class RegistrationTable(tables.Table):
|
|
|
|
"""
|
|
|
|
Table of all registrations.
|
|
|
|
"""
|
|
|
|
last_name = tables.LinkColumn(
|
|
|
|
'registration:user_detail',
|
|
|
|
args=[tables.A("user_id")],
|
|
|
|
verbose_name=lambda: _("last name").capitalize(),
|
|
|
|
accessor="user__last_name",
|
|
|
|
)
|
|
|
|
|
2021-01-14 20:07:09 +00:00
|
|
|
def order_type(self, queryset, desc):
|
|
|
|
types = ["volunteerregistration__adminregistration", "volunteerregistration", "participantregistration"]
|
|
|
|
return queryset.order_by(*(("" if desc else "-") + t for t in types)), True
|
|
|
|
|
2020-12-27 10:49:54 +00:00
|
|
|
class Meta:
|
|
|
|
attrs = {
|
2021-01-14 17:43:53 +00:00
|
|
|
'class': 'table table-condensed table-striped',
|
2020-12-27 10:49:54 +00:00
|
|
|
}
|
|
|
|
model = Registration
|
|
|
|
fields = ('last_name', 'user__first_name', 'user__email', 'type',)
|
2021-01-14 20:07:09 +00:00
|
|
|
order_by = ('volunteerregistration__adminregistration', 'volunteerregistration', 'last_name', 'first_name',)
|
2020-12-27 10:49:54 +00:00
|
|
|
template_name = 'django_tables2/bootstrap4.html'
|