diff --git a/apps/member/tables.py b/apps/member/tables.py index bc40368ccd875409a936bd009b89b8a3cf0f16b4..a9676928cd9985619345c08992fc6baf4854df08 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 b7f2fe701b7c36dbe4eafebc9d5a19c8e90df51a..e008ec6a378b0485beb11ecdce8ef7a0e0d2975f 100644 --- a/apps/member/templates/member/includes/profile_info.html +++ b/apps/member/templates/member/includes/profile_info.html @@ -25,25 +25,27 @@ </a> </dd> - <dt class="col-xl-6">{% trans 'section'|capfirst %}</dt> - <dd class="col-xl-6">{{ user_object.profile.section }}</dd> + {% if "member.view_profile"|has_perm:user_object.profile %} + <dt class="col-xl-6">{% trans 'section'|capfirst %}</dt> + <dd class="col-xl-6">{{ user_object.profile.section }}</dd> - <dt class="col-xl-6">{% trans 'email'|capfirst %}</dt> - <dd class="col-xl-6"><a href="mailto:{{ user_object.email }}">{{ user_object.email }}</a></dd> + <dt class="col-xl-6">{% trans 'email'|capfirst %}</dt> + <dd class="col-xl-6"><a href="mailto:{{ user_object.email }}">{{ user_object.email }}</a></dd> - <dt class="col-xl-6">{% trans 'phone number'|capfirst %}</dt> - <dd class="col-xl-6"><a href="tel:{{ user_object.profile.phone_number }}">{{ user_object.profile.phone_number }}</a> - </dd> + <dt class="col-xl-6">{% trans 'phone number'|capfirst %}</dt> + <dd class="col-xl-6"><a href="tel:{{ user_object.profile.phone_number }}">{{ user_object.profile.phone_number }}</a> + </dd> - <dt class="col-xl-6">{% trans 'address'|capfirst %}</dt> - <dd class="col-xl-6">{{ user_object.profile.address }}</dd> + <dt class="col-xl-6">{% trans 'address'|capfirst %}</dt> + <dd class="col-xl-6">{{ user_object.profile.address }}</dd> - {% if user_object.note and "note.view_note"|has_perm:user_object.note %} - <dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt> - <dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd> + {% if user_object.note and "note.view_note"|has_perm:user_object.note %} + <dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt> + <dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd> - <dt class="col-xl-6">{% trans 'paid'|capfirst %}</dt> - <dd class="col-xl-6">{{ user_object.profile.paid|yesno }}</dd> + <dt class="col-xl-6">{% trans 'paid'|capfirst %}</dt> + <dd class="col-xl-6">{{ user_object.profile.paid|yesno }}</dd> + {% endif %} {% endif %} </dl>