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 @@ -
{% trans 'section'|capfirst %}
-
{{ user_object.profile.section }}
+ {% if "member.view_profile"|has_perm:user_object.profile %} +
{% trans 'section'|capfirst %}
+
{{ user_object.profile.section }}
-
{% trans 'email'|capfirst %}
-
{{ user_object.email }}
+
{% trans 'email'|capfirst %}
+
{{ user_object.email }}
-
{% trans 'phone number'|capfirst %}
-
{{ user_object.profile.phone_number }} -
+
{% trans 'phone number'|capfirst %}
+
{{ user_object.profile.phone_number }} +
-
{% trans 'address'|capfirst %}
-
{{ user_object.profile.address }}
+
{% trans 'address'|capfirst %}
+
{{ user_object.profile.address }}
- {% if user_object.note and "note.view_note"|has_perm:user_object.note %} -
{% trans 'balance'|capfirst %}
-
{{ user_object.note.balance | pretty_money }}
+ {% if user_object.note and "note.view_note"|has_perm:user_object.note %} +
{% trans 'balance'|capfirst %}
+
{{ user_object.note.balance | pretty_money }}
-
{% trans 'paid'|capfirst %}
-
{{ user_object.profile.paid|yesno }}
+
{% trans 'paid'|capfirst %}
+
{{ user_object.profile.paid|yesno }}
+ {% endif %} {% endif %}