Skip to content

Commit

Permalink
ListUser: Remove "Détails" column if the doesn't have retrieve permis…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
Eyap53 committed Mar 5, 2018
1 parent e16fd8d commit 8ce546e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions users/templates/users/user_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
</a></th>
{% endfor %}
<th>Etat</th>
<th>Détail</th>
{% if has_perm_retrieve_user %}
<th>Détail</th>
{% endif %}
</tr>
</thead>
<tbody>
Expand All @@ -59,9 +61,11 @@
<td>{{ user.year }}</td>
<td>{{ user.balance }}€</td>
<td>{% if user.is_active %}Activé{% else %}Désactivé{% endif %}</td>
<td>
<a href="{% url 'url_user_retrieve' group_name=group_name pk=user.pk %}">Détail</a>
</td>
{% if has_perm_retrieve_user %}
<td>
<a href="{% url 'url_user_retrieve' group_name=group_name pk=user.pk %}">Détail</a>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down
4 changes: 3 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ def get_context_data(self, **kwargs):
context['user_list'] = self.form_query(
User.objects.all().exclude(groups=1))


# Permission Retrieveuser
if Permission.objects.get(codename='retrieve_user') in self.group.permissions.all():
context['has_perm_retrieve_user'] = True

return context

Expand Down

0 comments on commit 8ce546e

Please sign in to comment.