From 361ea8cad3c3c9092319ea0dd1fb4e929ce66fe7 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 1 Sep 2020 17:58:58 +0200 Subject: [PATCH] Update Django Tables 2, change accessor from dot to __ --- apps/activity/tables.py | 2 +- apps/member/tables.py | 4 ++-- apps/permission/tables.py | 2 +- apps/registration/tables.py | 4 ++-- apps/treasury/tables.py | 4 ++-- apps/wei/tables.py | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/activity/tables.py b/apps/activity/tables.py index b6a24250..e1c4817c 100644 --- a/apps/activity/tables.py +++ b/apps/activity/tables.py @@ -33,7 +33,7 @@ class ActivityTable(tables.Table): class GuestTable(tables.Table): inviter = tables.LinkColumn( 'member:user_detail', - args=[A('inviter.user.pk'), ], + args=[A('inviter__user__pk'), ], ) entry = tables.Column( diff --git a/apps/member/tables.py b/apps/member/tables.py index 4e09d72e..3e4261ef 100644 --- a/apps/member/tables.py +++ b/apps/member/tables.py @@ -41,9 +41,9 @@ class UserTable(tables.Table): """ alias = tables.Column() - section = tables.Column(accessor='profile.section') + section = tables.Column(accessor='profile__section') - balance = tables.Column(accessor='note.balance', verbose_name=_("Balance")) + balance = tables.Column(accessor='note__balance', verbose_name=_("Balance")) def render_balance(self, record, value): return pretty_money(value)\ diff --git a/apps/permission/tables.py b/apps/permission/tables.py index 6d972b0f..a2f6db78 100644 --- a/apps/permission/tables.py +++ b/apps/permission/tables.py @@ -53,7 +53,7 @@ class RightsTable(tables.Table): 'style': 'table-layout: fixed;' } template_name = 'django_tables2/bootstrap4.html' - fields = ('user.last_name', 'user.first_name', 'user', 'club', 'roles', ) + fields = ('user__last_name', 'user.first_name', 'user', 'club', 'roles', ) model = Membership diff --git a/apps/registration/tables.py b/apps/registration/tables.py index 7068f6ca..274369fe 100644 --- a/apps/registration/tables.py +++ b/apps/registration/tables.py @@ -9,9 +9,9 @@ class FutureUserTable(tables.Table): """ Display the list of pre-registered users """ - phone_number = tables.Column(accessor='profile.phone_number') + phone_number = tables.Column(accessor='profile__phone_number') - section = tables.Column(accessor='profile.section') + section = tables.Column(accessor='profile__section') class Meta: attrs = { diff --git a/apps/treasury/tables.py b/apps/treasury/tables.py index b8843d0d..14044f1c 100644 --- a/apps/treasury/tables.py +++ b/apps/treasury/tables.py @@ -95,7 +95,7 @@ class SpecialTransactionTable(tables.Table): # Display add and remove buttons. Use the `exclude` field to select what is needed. remittance_add = tables.LinkColumn("treasury:link_transaction", verbose_name=_("Remittance"), - args=[A("specialtransactionproxy.pk")], + args=[A("specialtransactionproxy__pk")], text=_("Add"), attrs={ 'a': {'class': 'btn btn-primary'} @@ -103,7 +103,7 @@ class SpecialTransactionTable(tables.Table): remittance_remove = tables.LinkColumn("treasury:unlink_transaction", verbose_name=_("Remittance"), - args=[A("specialtransactionproxy.pk")], + args=[A("specialtransactionproxy__pk")], text=_("Remove"), attrs={ 'a': {'class': 'btn btn-primary btn-danger'} diff --git a/apps/wei/tables.py b/apps/wei/tables.py index 4d576b00..f0a7868e 100644 --- a/apps/wei/tables.py +++ b/apps/wei/tables.py @@ -38,7 +38,7 @@ class WEIRegistrationTable(tables.Table): """ user = tables.LinkColumn( 'member:user_detail', - args=[A('user.pk')], + args=[A('user__pk')], ) edit = tables.LinkColumn( @@ -108,7 +108,7 @@ class WEIRegistrationTable(tables.Table): } model = WEIRegistration template_name = 'django_tables2/bootstrap4.html' - fields = ('user', 'user.first_name', 'user.last_name', 'first_year',) + fields = ('user', 'user__first_name', 'user__last_name', 'first_year',) row_attrs = { 'class': 'table-row', 'id': lambda record: "row-" + str(record.pk), @@ -119,7 +119,7 @@ class WEIRegistrationTable(tables.Table): class WEIMembershipTable(tables.Table): user = tables.LinkColumn( 'wei:wei_update_registration', - args=[A('registration.pk')], + args=[A('registration__pk')], ) year = tables.Column( @@ -129,12 +129,12 @@ class WEIMembershipTable(tables.Table): bus = tables.LinkColumn( 'wei:manage_bus', - args=[A('bus.pk')], + args=[A('bus__pk')], ) team = tables.LinkColumn( 'wei:manage_bus_team', - args=[A('team.pk')], + args=[A('team__pk')], ) def render_year(self, record): @@ -146,7 +146,7 @@ class WEIMembershipTable(tables.Table): } model = WEIMembership template_name = 'django_tables2/bootstrap4.html' - fields = ('user', 'user.last_name', 'user.first_name', 'registration.gender', 'user.profile.department', + fields = ('user', 'user__last_name', 'user__first_name', 'registration__gender', 'user__profile__department', 'year', 'bus', 'team', ) row_attrs = { 'class': 'table-row',