From 1fd37bb1ce874739e77de276a558471658297357 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 25 Aug 2020 16:44:01 +0200 Subject: [PATCH] Smaller membership renew btn --- apps/member/tables.py | 42 ++++++++++--------- .../templates/member/profile_detail.html | 3 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/apps/member/tables.py b/apps/member/tables.py index 86fc386a..4e09d72e 100644 --- a/apps/member/tables.py +++ b/apps/member/tables.py @@ -96,26 +96,30 @@ class MembershipTable(tables.Table): t = pretty_money(value) # If it is required and if the user has the right, the renew button is displayed. - if record.club.membership_start is not None: - if record.date_start < record.club.membership_start: # If the renew is available - if not Membership.objects.filter( - club=record.club, - user=record.user, - date_start__gte=record.club.membership_start, - date_end__lte=record.club.membership_end, - ).exists(): # If the renew is not yet performed - empty_membership = Membership( - club=record.club, - user=record.user, - date_start=date.today(), - date_end=date.today(), - fee=0, + if record.club.membership_start is not None \ + and record.date_start < record.club.membership_start: + if not Membership.objects.filter( + club=record.club, + user=record.user, + date_start__gte=record.club.membership_start, + date_end__lte=record.club.membership_end, + ).exists(): # If the renew is not yet performed + empty_membership = Membership( + club=record.club, + user=record.user, + date_start=date.today(), + date_end=date.today(), + fee=0, + ) + if PermissionBackend.check_perm(get_current_authenticated_user(), + "member:add_membership", empty_membership): # If the user has right + renew_url = reverse_lazy('member:club_renew_membership', + kwargs={"pk": record.pk}) + t = format_html( + t + ' ', + renew_url=renew_url, text=_("Renew") ) - if PermissionBackend.check_perm(get_current_authenticated_user(), - "member:add_membership", empty_membership): # If the user has right - t = format_html(t + ' {text}', - url=reverse_lazy('member:club_renew_membership', - kwargs={"pk": record.pk}), text=_("Renew")) return t def render_roles(self, record): diff --git a/apps/member/templates/member/profile_detail.html b/apps/member/templates/member/profile_detail.html index b8cae4a0..598b291d 100644 --- a/apps/member/templates/member/profile_detail.html +++ b/apps/member/templates/member/profile_detail.html @@ -26,7 +26,8 @@ SPDX-License-Identifier: GPL-3.0-or-later