Update Django Tables 2, change accessor from dot to __

This commit is contained in:
Yohann D'ANELLO 2020-09-01 17:58:58 +02:00
parent 819795c1f9
commit 361ea8cad3
6 changed files with 14 additions and 14 deletions

View File

@ -33,7 +33,7 @@ class ActivityTable(tables.Table):
class GuestTable(tables.Table): class GuestTable(tables.Table):
inviter = tables.LinkColumn( inviter = tables.LinkColumn(
'member:user_detail', 'member:user_detail',
args=[A('inviter.user.pk'), ], args=[A('inviter__user__pk'), ],
) )
entry = tables.Column( entry = tables.Column(

View File

@ -41,9 +41,9 @@ class UserTable(tables.Table):
""" """
alias = tables.Column() 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): def render_balance(self, record, value):
return pretty_money(value)\ return pretty_money(value)\

View File

@ -53,7 +53,7 @@ class RightsTable(tables.Table):
'style': 'table-layout: fixed;' 'style': 'table-layout: fixed;'
} }
template_name = 'django_tables2/bootstrap4.html' 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 model = Membership

View File

@ -9,9 +9,9 @@ class FutureUserTable(tables.Table):
""" """
Display the list of pre-registered users 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: class Meta:
attrs = { attrs = {

View File

@ -95,7 +95,7 @@ class SpecialTransactionTable(tables.Table):
# Display add and remove buttons. Use the `exclude` field to select what is needed. # Display add and remove buttons. Use the `exclude` field to select what is needed.
remittance_add = tables.LinkColumn("treasury:link_transaction", remittance_add = tables.LinkColumn("treasury:link_transaction",
verbose_name=_("Remittance"), verbose_name=_("Remittance"),
args=[A("specialtransactionproxy.pk")], args=[A("specialtransactionproxy__pk")],
text=_("Add"), text=_("Add"),
attrs={ attrs={
'a': {'class': 'btn btn-primary'} 'a': {'class': 'btn btn-primary'}
@ -103,7 +103,7 @@ class SpecialTransactionTable(tables.Table):
remittance_remove = tables.LinkColumn("treasury:unlink_transaction", remittance_remove = tables.LinkColumn("treasury:unlink_transaction",
verbose_name=_("Remittance"), verbose_name=_("Remittance"),
args=[A("specialtransactionproxy.pk")], args=[A("specialtransactionproxy__pk")],
text=_("Remove"), text=_("Remove"),
attrs={ attrs={
'a': {'class': 'btn btn-primary btn-danger'} 'a': {'class': 'btn btn-primary btn-danger'}

View File

@ -38,7 +38,7 @@ class WEIRegistrationTable(tables.Table):
""" """
user = tables.LinkColumn( user = tables.LinkColumn(
'member:user_detail', 'member:user_detail',
args=[A('user.pk')], args=[A('user__pk')],
) )
edit = tables.LinkColumn( edit = tables.LinkColumn(
@ -108,7 +108,7 @@ class WEIRegistrationTable(tables.Table):
} }
model = WEIRegistration model = WEIRegistration
template_name = 'django_tables2/bootstrap4.html' 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 = { row_attrs = {
'class': 'table-row', 'class': 'table-row',
'id': lambda record: "row-" + str(record.pk), 'id': lambda record: "row-" + str(record.pk),
@ -119,7 +119,7 @@ class WEIRegistrationTable(tables.Table):
class WEIMembershipTable(tables.Table): class WEIMembershipTable(tables.Table):
user = tables.LinkColumn( user = tables.LinkColumn(
'wei:wei_update_registration', 'wei:wei_update_registration',
args=[A('registration.pk')], args=[A('registration__pk')],
) )
year = tables.Column( year = tables.Column(
@ -129,12 +129,12 @@ class WEIMembershipTable(tables.Table):
bus = tables.LinkColumn( bus = tables.LinkColumn(
'wei:manage_bus', 'wei:manage_bus',
args=[A('bus.pk')], args=[A('bus__pk')],
) )
team = tables.LinkColumn( team = tables.LinkColumn(
'wei:manage_bus_team', 'wei:manage_bus_team',
args=[A('team.pk')], args=[A('team__pk')],
) )
def render_year(self, record): def render_year(self, record):
@ -146,7 +146,7 @@ class WEIMembershipTable(tables.Table):
} }
model = WEIMembership model = WEIMembership
template_name = 'django_tables2/bootstrap4.html' 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', ) 'year', 'bus', 'team', )
row_attrs = { row_attrs = {
'class': 'table-row', 'class': 'table-row',