[chronojump-server] Fixing player list in results view. Using GroupPlayer instead of Player. Filters have been disabled
- From: Marcos Venteo Garcia <mventeo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Fixing player list in results view. Using GroupPlayer instead of Player. Filters have been disabled
- Date: Mon, 24 Sep 2018 21:33:13 +0000 (UTC)
commit ac4446b4f82b1f58356cc87cf046ad14cd0e0009
Author: Marcos Venteo GarciÌa <mventeo me com>
Date: Mon Sep 24 23:32:55 2018 +0200
Fixing player list in results view. Using GroupPlayer instead of Player. Filters have been disabled
.../chronojump_networks/organizations/models.py | 16 ++++++++++++++++
.../chronojump_networks/results/api/views.py | 11 ++++++-----
.../templates/results/results_list.html | 22 +++++++++++++++++++---
3 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/chronojumpserver-django/chronojump_networks/organizations/models.py
b/chronojumpserver-django/chronojump_networks/organizations/models.py
index 0c52745..28e578a 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/models.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/models.py
@@ -76,6 +76,22 @@ class User(AbstractUser):
else:
return ""
+ def players_by_coach(self):
+ group_list = [g.group.id for g in self.groups_by_coach.all()]
+
+ group_players = GroupPlayer.objects.filter(group_id__in = group_list)
+ player_list = [gp.player_id for gp in group_players]
+ players = Player.objects.filter(id__in = player_list)
+ return players
+
+ def stations_by_coach(self):
+ # filter properly
+ return []
+
+ def exercises_by_coach(self):
+ # TODO: filter properly
+ return []
+
class Organization(ChronojumpBaseModel):
class Meta:
diff --git a/chronojumpserver-django/chronojump_networks/results/api/views.py
b/chronojumpserver-django/chronojump_networks/results/api/views.py
index e8ab9e7..a730680 100644
--- a/chronojumpserver-django/chronojump_networks/results/api/views.py
+++ b/chronojumpserver-django/chronojump_networks/results/api/views.py
@@ -7,7 +7,7 @@ from rest_framework.response import Response
from rest_framework.generics import ListAPIView, RetrieveAPIView, DestroyAPIView,
RetrieveUpdateDestroyAPIView
from rest_framework.permissions import IsAuthenticated
-from chronojump_networks.organizations.models import User, Group, Player
+from chronojump_networks.organizations.models import User, Group, Player, GroupPlayer
from datetime import datetime, timedelta
class ResultEncoderList(ListAPIView):
@@ -24,11 +24,12 @@ class ResultEncoderList(ListAPIView):
# Get all results from all the groups of the coach
coach = get_object_or_404(User, pk=coach_id)
group_list = [g.group.id for g in coach.groups_by_coach.all()]
- players = Player.objects.filter(groups__in = group_list)
- player_list = [p.id for p in players]
+
+ players = GroupPlayer.objects.filter(group_id__in = group_list)
+ player_list = [p.player_id for p in players]
else:
- players = Player.objects.filter(groups = int(group_id))
- player_list = [p.id for p in players]
+ players = GroupPlayer.objects.filter(group_id = int(group_id))
+ player_list = [p.player_id for p in players]
if timeInterval > 0 :
print(timeInterval)
diff --git a/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
b/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
index 2e70fad..410791f 100644
--- a/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
+++ b/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
@@ -48,15 +48,31 @@
</div>
<div class="col">
<label for="filterByPlayer">{% trans 'Filter by player' %}</label>
- <div id="filterByPlayer"></div>
+ <!-- <div id="filterByPlayer"></div>-->
+ <select name="group" class="form-control" id="playerSelect">
+ <option value="all">{% trans 'All players' %}
+ {% for player in user.players_by_coach %}
+ <option value={{player.id}}>{{player.name}}</option>
+ {% endfor %}
+ </select>
</div>
<div class="col">
<label for="filterByStation">{% trans 'Filter by station' %}</label>
- <div id="filterByStation"></div>
+ <select name="group" class="form-control" id="stationSelect">
+ <option value="all">{% trans 'All stations' %}
+ {% for station in user.stations_by_coach %}
+ <option value={{station.id}}>{{station.name}}</option>
+ {% endfor %}
+ </select>
</div>
<div class="col">
<label for="filterByExercise">{% trans 'Filter by exercise' %}</label>
- <div id="filterByExercise"></div>
+ <select name="group" class="form-control" id="exerciseSelect">
+ <option value="all">{% trans 'All exercises' %}
+ {% for exercise in user.exercises_by_coach %}
+ <option value={{exercise.id}}>{{exercise.name}}</option>
+ {% endfor %}
+ </select>
</div>
</div>
<div class="row datatables_wrapped">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]