[chronojump-server] Fixed result filters display and modify task form



commit b0dcb9624012128dd8e77f7c6c2badcbced7f929
Author: Max Ros i Morejon <mros33 gmail com>
Date:   Wed Jan 30 17:36:33 2019 +0100

    Fixed result filters display and modify task form

 .../chronojump_networks/organizations/models.py    | 14 ++++++++++----
 .../chronojump_networks/templates/layout.html      |  4 ++--
 .../templates/organizations/gyms/gym_detail.html   | 22 ++++++++++++++++++----
 .../chronojump_networks/templates/pages/index.html |  4 ++--
 .../templates/results/results_list.html            | 13 ++++++-------
 5 files changed, 38 insertions(+), 19 deletions(-)
---
diff --git a/chronojumpserver-django/chronojump_networks/organizations/models.py 
b/chronojumpserver-django/chronojump_networks/organizations/models.py
index 3b21bc4..1122046 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/models.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/models.py
@@ -85,12 +85,18 @@ class User(AbstractUser):
         return players
         
     def stations_by_coach(self):
-        # filter properly
-        return []
+        group_list = [g.group.id for g in self.groups_by_coach.all()]
+        group_organizations = Organization.objects.filter(groups__in = group_list)
+        organization_list = [gp.id for gp in group_organizations]
+        gym_organization = Gym.objects.filter(organization_id__in = organization_list)
+        gym_list = [gm.id for gm in gym_organization]
+        stations = Station.objects.filter(gym_id__in = gym_list)
+        return stations
 
     def exercises_by_coach(self):
-        # TODO: filter properly
-        return []
+        station_list = self.stations_by_coach()
+        exercices = Exercise.objects.filter(station_id__in = station_list)
+        return exercices
 
 
 class Organization(ChronojumpBaseModel):
diff --git a/chronojumpserver-django/chronojump_networks/templates/layout.html 
b/chronojumpserver-django/chronojump_networks/templates/layout.html
index bd45a1d..48cb58d 100644
--- a/chronojumpserver-django/chronojump_networks/templates/layout.html
+++ b/chronojumpserver-django/chronojump_networks/templates/layout.html
@@ -15,9 +15,9 @@
       <li class="nav-item">
         <a class="nav-link active" href="{% url 'results:list' %}">{% trans 'Results' %}</a>
       </li>
-      <li class="nav-item">
+      <!--<li class="nav-item">
         <a class="nav-link disabled" href="#">{% trans 'Sprints' %}</a>
-      </li>
+      </li>-->
       {% if request.user.groups_by_coach %}
       <li class="nav-item dropdown active">
         <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownGroups" data-toggle="dropdown" 
aria-haspopup="true" aria-expanded="false">
diff --git a/chronojumpserver-django/chronojump_networks/templates/organizations/gyms/gym_detail.html 
b/chronojumpserver-django/chronojump_networks/templates/organizations/gyms/gym_detail.html
index 1135a8a..bae3f51 100644
--- a/chronojumpserver-django/chronojump_networks/templates/organizations/gyms/gym_detail.html
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/gyms/gym_detail.html
@@ -35,7 +35,6 @@
 </div>
 
 
-
 {% endblock %}
 
 {% block javascript %}
@@ -110,7 +109,7 @@
             return html;
           }
         },
-        {
+        /*{
           type: 'html',
           className: 'align-top',
           render: function(value, type, row) {
@@ -131,7 +130,7 @@
             html += '<i class="material-icons" style="margin-top:3px;font-size:16px;">block</i></button>';
             return html;
           }
-        }
+        }*/
       ],
       "drawCallback" : function ( settings ) {
             var api = this.api();
@@ -160,7 +159,18 @@
             } );
       },
       "dom": "<'row'<'col-sm-6'B><'col-sm-6'f>>rtip",
-      buttons: [],
+      buttons: [
+        /*{% if user.id == gym.responsible.id %}
+        {
+            text: "{% trans 'Add new exercise' %}",
+            className: "btn addTaskBtn",
+            action: function() {
+                $('#taskModalForm').modal('show');
+            }
+        }
+        {% endif %}*/
+      
+      ],
       initComplete: function() {
         // Enable table functionality
         enableStationsTableFunctionality();
@@ -185,6 +195,10 @@
           $(this).html = '<i class="material-icons">keyboard_arrow_down</i>';
         }
       });
+      
+      /*$('.addTaskBtn').on('click', function() {
+        $('#exerciseModalForm').modal('show');
+      });*/
     }
 
   }); /* End of Document ready */
diff --git a/chronojumpserver-django/chronojump_networks/templates/pages/index.html 
b/chronojumpserver-django/chronojump_networks/templates/pages/index.html
index 635493b..0eb82ec 100644
--- a/chronojumpserver-django/chronojump_networks/templates/pages/index.html
+++ b/chronojumpserver-django/chronojump_networks/templates/pages/index.html
@@ -58,9 +58,9 @@
       <div class="col-sm-6">
         <a class="btn btn-outline-dark btn-block font-weight-bold text-uppercase" href="{% url 
'results:list' %}">{% trans 'Results' %}</a>
       </div>
-      <div class="col-sm-6">
+      <!--<div class="col-sm-6">
         <a class="btn btn-outline-dark btn-block font-weight-bold text-uppercase" href="#">{% trans 
'Sprints' %}</a>
-      </div>
+      </div>-->
     </div>
     {% if user.groups_by_coach %}
     <h2 class="text-center">{% trans 'My Groups' %}</h2>
diff --git a/chronojumpserver-django/chronojump_networks/templates/results/results_list.html 
b/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
index 410791f..8161f67 100644
--- a/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
+++ b/chronojumpserver-django/chronojump_networks/templates/results/results_list.html
@@ -48,8 +48,7 @@
   </div>
   <div class="col">
     <label for="filterByPlayer">{% trans 'Filter by player' %}</label>
-    <!-- <div id="filterByPlayer"></div>-->
-    <select name="group" class="form-control" id="playerSelect">
+    <select name="player" 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>
@@ -58,7 +57,7 @@
   </div>
   <div class="col">
     <label for="filterByStation">{% trans 'Filter by station' %}</label>
-    <select name="group" class="form-control" id="stationSelect">
+    <select name="station" 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>
@@ -67,7 +66,7 @@
   </div>
   <div class="col">
     <label for="filterByExercise">{% trans 'Filter by exercise' %}</label>
-    <select name="group" class="form-control" id="exerciseSelect">
+    <select name="exercise" 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>
@@ -295,7 +294,6 @@
                                // Show the date in dd/mm/yyyy
                                var dateStr = formatDateNumber(date.getDate()) + "/" + 
formatDateNumber(date.getMonth() + 1 ) + "/" +
                                date.getYear().toString().substr(-2);
-
                                csv += dateStr + ";"
                                + data.person + ";"
                                + data.station +";"
@@ -384,6 +382,7 @@
                        .appendTo($('#filterByPlayer'))
                        .on('change', function() {
                                // Player selected
+                               console.log("canvi player select");
                                var val = $.fn.dataTable.util.escapeRegex(
                                        $(this).val()
                                );
@@ -491,7 +490,6 @@
     $('#results').on( 'draw.dt', function () {
        console.log( 'Table redrawn' );
        deselectAllCheckboxes();
-
     } );
 
     function deselectAllCheckboxes() {
@@ -517,8 +515,9 @@
     /* Reload results for the group selected */
     $('#groupSelect').on('change', function() {
        table_results.ajax.reload(enableDeletion, true);
-      console.log("Reload by group change");
+        console.log("Reload by group change");
     });
+    
 
     $('.time-interval-btn').on('click', function() {
       $('.time-interval-btn').removeClass('active btn-primary').addClass('btn-secondary');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]