diff --git a/apps/member/tables.py b/apps/member/tables.py index bc40368c..a9676928 100644 --- a/apps/member/tables.py +++ b/apps/member/tables.py @@ -43,8 +43,24 @@ class UserTable(tables.Table): section = tables.Column(accessor='profile__section') + # Override the column to let replace the URL + email = tables.EmailColumn(linkify=lambda record: "mailto:{}".format(record.email)) + balance = tables.Column(accessor='note__balance', verbose_name=_("Balance")) + def render_email(self, record, value): + # Replace the email by a dash if the user can't see the profile detail + # Replace also the URL + if not PermissionBackend.check_perm(get_current_authenticated_user(), "member.view_profile", record.profile): + value = "—" + record.email = value + return value + + def render_section(self, record, value): + return value \ + if PermissionBackend.check_perm(get_current_authenticated_user(), "member.view_profile", record.profile) \ + else "—" + def render_balance(self, record, value): return pretty_money(value)\ if PermissionBackend.check_perm(get_current_authenticated_user(), "note.view_note", record.note) else "—" diff --git a/apps/member/templates/member/includes/profile_info.html b/apps/member/templates/member/includes/profile_info.html index b7f2fe70..e008ec6a 100644 --- a/apps/member/templates/member/includes/profile_info.html +++ b/apps/member/templates/member/includes/profile_info.html @@ -25,25 +25,27 @@ -