Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Show gym in general user list

Roland Geider3d119f08d50b
diff --git a/wger/core/views/user.py b/wger/core/views/user.py
index e3afade9d..8a1b3c133 100644
--- a/wger/core/views/user.py
+++ b/wger/core/views/user.py
@@ -459,7 +459,7 @@ class UserListView(WgerPermissionMixin, ListView):
Overview of all users in the instance
'''
model = User
- permission_required = ('gym.manage_gyms')
+ permission_required = ('gym.manage_gyms',)
template_name = 'user/list.html'
def get_queryset(self):
@@ -469,7 +469,7 @@ class UserListView(WgerPermissionMixin, ListView):
out = {'admins': [],
'members': []}
- for u in User.objects.select_related('usercache').all():
+ for u in User.objects.select_related('usercache', 'userprofile__gym').all():
out['members'].append({'obj': u,
'last_log': u.usercache.last_activity})
@@ -480,6 +480,11 @@ class UserListView(WgerPermissionMixin, ListView):
Pass other info to the template
'''
context = super(UserListView, self).get_context_data(**kwargs)
- context['user_table'] = {'keys': [_('ID'), _('Username'), _('Name'), _('Last activity')],
+ context['show_gym'] = True
+ context['user_table'] = {'keys': [_('ID'),
+ _('Username'),
+ _('Name'),
+ _('Last activity'),
+ _('Gym')],
'users': context['object_list']['members']}
return context
diff --git a/wger/gym/templates/gym/partial_user_list.html b/wger/gym/templates/gym/partial_user_list.html
index e01b0384d..0ac51ca97 100644
--- a/wger/gym/templates/gym/partial_user_list.html
+++ b/wger/gym/templates/gym/partial_user_list.html
@@ -37,6 +37,17 @@ $(document).ready( function () {
<td data-order="{{current_user.last_log|date:'U'}}">
{{current_user.last_log|default:'-/-'}}
</td>
+ {% if show_gym %}
+ <td>
+ {% if current_user.obj.userprofile.gym_id %}
+ <a href="{{ current_user.obj.userprofile.gym.get_absolute_url }}">
+ {{ current_user.obj.userprofile.gym }}
+ </a>
+ {% else %}
+ -/-
+ {% endif %}
+ </td>
+ {% endif %}
</tr>
{% empty %}
<tr>