mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Display guests list
This commit is contained in:
@ -2,19 +2,17 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_tables2 import tables, A
|
||||
import django_tables2 as tables
|
||||
from django_tables2 import A
|
||||
|
||||
from .models import Activity, Guest
|
||||
|
||||
|
||||
class ActivityTable(tables.Table):
|
||||
name = tables.columns.LinkColumn('activity:activity_detail',
|
||||
args=[A('pk'), ],)
|
||||
|
||||
invite = tables.columns.LinkColumn('activity:activity_invite',
|
||||
args=[A('pk'), ],
|
||||
verbose_name=_("Invite"),
|
||||
text=_("Invite"),)
|
||||
name = tables.LinkColumn(
|
||||
'activity:activity_detail',
|
||||
args=[A('pk'), ],
|
||||
)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
@ -22,19 +20,34 @@ class ActivityTable(tables.Table):
|
||||
}
|
||||
model = Activity
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('name', 'activity_type', 'organizer', 'attendees_club', 'date_start', 'date_end', 'invite', )
|
||||
fields = ('name', 'activity_type', 'organizer', 'attendees_club', 'date_start', 'date_end', )
|
||||
|
||||
|
||||
class GuestTable(tables.Table):
|
||||
inviter = tables.LinkColumn(
|
||||
'member:user_detail',
|
||||
args=[A('inviter.user.pk'), ],
|
||||
)
|
||||
|
||||
entry = tables.Column(
|
||||
empty_values=(),
|
||||
attrs={
|
||||
"td": {
|
||||
"class": lambda record: "" if record.entry else "validate btn btn-danger",
|
||||
"onclick": lambda record: "" if record.entry else "remove_guest(" + str(record.pk) + ")"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
model = Guest
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('name', 'inviter', )
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
'data-href': lambda record: record.pk
|
||||
}
|
||||
fields = ("last_name", "first_name", "inviter", )
|
||||
|
||||
def render_entry(self, record):
|
||||
if record.entry:
|
||||
return str(record.date)
|
||||
return _("remove").capitalize()
|
||||
|
Reference in New Issue
Block a user