Преглед изворни кода

Fixing some issues in the to_dict methods

Kirk Trombley пре 5 година
родитељ
комит
a6bfa26a1c
1 измењених фајлова са 8 додато и 6 уклоњено
  1. 8 6
      server/db.py

+ 8 - 6
server/db.py

@@ -51,17 +51,19 @@ class Game(db.Model):
         db.session.add(p)
         db.session.commit()
 
+        return p
+
     def to_dict(self):
         return {
             "gameId": self.game_id,
             "timer": self.timer,
             "rounds": self.rounds,
-            "coords": [{
+            "coords": {
                 str(c.round_number): {
                     "lat": c.latitude,
                     "lng": c.longitude,
-                }
-            } for c in self.coordinates],
+                } for c in self.coordinates
+            },
             "players": [p.to_dict() for p in self.players],
         }
 
@@ -102,13 +104,13 @@ class Player(db.Model):
             "name": self.player_name,
             "currentRound": self.get_current_round(),
             "totalScore": self.get_total_score(),
-            "guesses": [{
+            "guesses": {
                 str(g.round_number): {
                     "lat": g.latitude,
                     "lng": g.longitude,
                     "score": g.round_score,
-                }
-            } for g in self.guesses],
+                } for g in self.guesses
+            },
         }