aboutsummaryrefslogtreecommitdiffstats
path: root/pysite
diff options
context:
space:
mode:
authorGravatar momothereal <[email protected]>2018-06-20 10:17:19 -0400
committerGravatar momothereal <[email protected]>2018-06-20 10:17:19 -0400
commit7180d4ba40d2cc48e8e54430852788644f73bd04 (patch)
tree99290635d35ea5b33c417defa76df07982ea3037 /pysite
parentCleanup team list querying, add tooltip to Gitlab user button (diff)
Fix teams not being restricted to their jam, and allow users to be in two teams for two different jams
Diffstat (limited to 'pysite')
-rw-r--r--pysite/views/staff/jams/actions.py6
-rw-r--r--pysite/views/staff/jams/teams/view.py14
2 files changed, 5 insertions, 15 deletions
diff --git a/pysite/views/staff/jams/actions.py b/pysite/views/staff/jams/actions.py
index de9e2d2c..3f8b4c20 100644
--- a/pysite/views/staff/jams/actions.py
+++ b/pysite/views/staff/jams/actions.py
@@ -335,10 +335,8 @@ class ActionView(APIView, DBMixin, RMQMixin):
.coerce_to("array"),
"teams":
self.db.query(self.teams_table)
- .outer_join(self.db.query(self.table_name),
- lambda team_row, jams_row: jams_row["teams"].contains(team_row["id"]))
- .pluck({"left": ["id", "name", "members"]})
- .zip()
+ .filter(lambda team_row: jam_obj["teams"].contains(team_row["id"]))
+ .pluck(["id", "name", "members"])
.coerce_to("array")
}
)
diff --git a/pysite/views/staff/jams/teams/view.py b/pysite/views/staff/jams/teams/view.py
index 6b30f9a2..662cc084 100644
--- a/pysite/views/staff/jams/teams/view.py
+++ b/pysite/views/staff/jams/teams/view.py
@@ -61,18 +61,10 @@ class StaffView(RouteView, DBMixin):
.coerce_to("array"), # Coerce the document stream into an array
"form": self.db.query(self.forms_table).get(jam), # Just get the correct form object
"teams":
- # Query the teams table
self.db.query(self.table_name)
- # Join the teams table against the jams table, to find all of the teams for this
- # specific jam - we can't simply filter because of the one-to-many relationship,
- # so we must use an inner join with a predicate function. This function is still
- # run on the server, however
- .inner_join(self.db.query(self.jams_table),
- lambda team_row, jams_row: jams_row["teams"].contains(team_row["id"]))
- # Only take the ID, name and members of each team, discard everything else
- .pluck({"left": ["id", "name", "members"]})
- .zip() # Combine the left and right documents together
- .coerce_to("array") # Coerce the document stream into an array
+ .filter(lambda team_row: jam_obj["teams"].contains(team_row["id"]))
+ .pluck(["id", "name", "members"])
+ .coerce_to("array")
}
)