diff options
author | 2018-06-24 22:47:23 +0100 | |
---|---|---|
committer | 2018-06-24 22:47:23 +0100 | |
commit | 9c7a25181bb3f050eb3d03f57a09f4af3c57c7b8 (patch) | |
tree | 1bee655a16a4a4cd1c1972fd8cdfb64f049a4316 /pysite | |
parent | [Jams] Fix margin on theme label (diff) |
[Jams] Fix broken team-jam assoc on edit
Diffstat (limited to 'pysite')
-rw-r--r-- | pysite/migrations/tables/code_jam_teams/v2.py | 13 | ||||
-rw-r--r-- | pysite/views/staff/jams/actions.py | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/pysite/migrations/tables/code_jam_teams/v2.py b/pysite/migrations/tables/code_jam_teams/v2.py new file mode 100644 index 00000000..c6d7c972 --- /dev/null +++ b/pysite/migrations/tables/code_jam_teams/v2.py @@ -0,0 +1,13 @@ +def run(db, table, table_obj): + """ + Associate the ID of each team's code jam (team -> jam) - again + """ + + for document in db.get_all(table): + if "jam" not in document: + # find the code jam containing this team + for jam in db.get_all("code_jams"): + if document["id"] in jam["teams"]: + document["jam"] = jam["number"] + db.insert(table, document, conflict="update", durability="soft") + db.sync(table) diff --git a/pysite/views/staff/jams/actions.py b/pysite/views/staff/jams/actions.py index c97f0d8c..761ba7d6 100644 --- a/pysite/views/staff/jams/actions.py +++ b/pysite/views/staff/jams/actions.py @@ -337,7 +337,7 @@ class ActionView(APIView, DBMixin, RMQMixin): "teams": self.db.query(self.teams_table) .filter(lambda team_row: jam_obj["teams"].contains(team_row["id"])) - .pluck(["id", "name", "members"]) + .pluck(["id", "name", "members", "jam"]) .coerce_to("array") } ) |