[chronojump-server] Error control implemented when adding player



commit df4c6ca6f0388f822292c0528e6de4dfa8c8f798
Author: Max Ros i Morejon <mros33 gmail com>
Date:   Mon Feb 25 11:49:30 2019 +0100

    Error control implemented when adding player

 .../chronojump_networks/organizations/api/views.py        |  2 --
 .../templates/organizations/players/players_list.html     | 15 +++++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/chronojumpserver-django/chronojump_networks/organizations/api/views.py 
b/chronojumpserver-django/chronojump_networks/organizations/api/views.py
index 04b81a7..dc71db9 100644
--- a/chronojumpserver-django/chronojump_networks/organizations/api/views.py
+++ b/chronojumpserver-django/chronojump_networks/organizations/api/views.py
@@ -134,9 +134,7 @@ class PlayerListView(ListCreateAPIView):
         print("delete player")        
         data = dict(request.data)
         player_ids = data['player_ids[]']
-        print("delete player")
         for player_id in player_ids:
-            print("deleting %d player" % (int(player_id))) 
             o = Player.objects.get(id=int(player_id))
             o.delete()
             print("Removed player %d" % (int(player_id)))
diff --git a/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html 
b/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
index bb8a561..334b100 100644
--- a/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
@@ -205,9 +205,13 @@
         console.log("botó addmodifyplayer 0");
         e.preventDefault();
         $('#personId').val('');  
-        var player = serializePlayer();
-        console.log(player.id);
-        putPlayer(player);
+        if($('#input_rfid').val()=="") alert("{% trans 'Rfid is missing' %}");
+        else if($('#height').val()=="" || $('#weight').val()=="" || $('#fullname').val()=="") alert("{% 
trans 'All fields must be filled' %}");
+        else {
+            var player = serializePlayer();
+            console.log(player.id);
+            putPlayer(player);
+        }
     })
     
      // Get all the values in the form into json object 
@@ -243,8 +247,11 @@
                 alert("The player has been added");
                 table_players.ajax.reload(enablePlayersTableFunctionality,false);
                 $('#addPlayerModalForm').modal('hide');
+            },
+            error: function(request, status, error) { 
+                var parts = request.responseText.split('\n')
+                alert(parts[1]); 
             }
-
         })
     }
 


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