Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Show last 5 contracts in user overview

Roland Geider91c6dbca8d8c
diff --git a/wger/core/templates/user/overview.html b/wger/core/templates/user/overview.html
index 9425e7936..be3d0af50 100644
--- a/wger/core/templates/user/overview.html
+++ b/wger/core/templates/user/overview.html
@@ -306,9 +306,9 @@
</ul>
</div>
-<h4>{% trans "Contracts" %}</h4>
+<h4>{% trans "Contracts" %} <small>({% blocktrans with number=5 %}last {{ number }}{% endblocktrans %})</small></h4>
<table class="table">
- {% for contract in current_user.contract_member.all %}
+ {% for contract in contracts %}
<tr>
<td>
{{ contract }}
diff --git a/wger/core/views/user.py b/wger/core/views/user.py
index d4df4faac..3b759c1fc 100644
--- a/wger/core/views/user.py
+++ b/wger/core/views/user.py
@@ -56,7 +56,11 @@ from wger.manager.models import (
from wger.nutrition.models import NutritionPlan
from wger.config.models import GymConfig
from wger.weight.models import WeightEntry
-from wger.gym.models import AdminUserNote, GymUserConfig
+from wger.gym.models import (
+ AdminUserNote,
+ GymUserConfig,
+ Contract
+)
logger = logging.getLogger(__name__)
@@ -445,4 +449,5 @@ class UserDetailView(WgerPermissionMixin, DetailView):
.order_by('-creation_date')[:5]
context['session'] = WorkoutSession.objects.filter(user=self.object).order_by('-date')[:10]
context['admin_notes'] = AdminUserNote.objects.filter(member=self.object)[:5]
+ context['contracts'] = Contract.objects.filter(member=self.object)[:5]
return context