aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/staff/jams/participants.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-08-07 15:09:08 +0100
committerGravatar Gareth Coles <[email protected]>2018-08-07 15:09:16 +0100
commitaf54db6c136138c66cf5ca72419989525a0baa5c (patch)
tree8519aeab8d45277c51797c7dc23aacf3b56ed1bb /pysite/views/staff/jams/participants.py
parentA wizard is never late, nor is he early. (diff)
Initial project layout for django
Diffstat (limited to 'pysite/views/staff/jams/participants.py')
-rw-r--r--pysite/views/staff/jams/participants.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/pysite/views/staff/jams/participants.py b/pysite/views/staff/jams/participants.py
deleted file mode 100644
index 52f9bdec..00000000
--- a/pysite/views/staff/jams/participants.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import logging
-
-from rethinkdb import ReqlNonExistenceError
-from werkzeug.exceptions import NotFound
-
-from pysite.base_route import RouteView
-from pysite.constants import ALL_STAFF_ROLES
-from pysite.decorators import require_roles
-from pysite.mixins import DBMixin
-
-REQUIRED_KEYS = ["title", "date_start", "date_end"]
-log = logging.getLogger(__name__)
-
-
-class StaffView(RouteView, DBMixin):
- path = "/jams/participants/<int:jam>"
- name = "jams.participants"
-
- forms_table = "code_jam_forms"
- participants_table = "code_jam_participants"
- questions_table = "code_jam_questions"
- responses_table = "code_jam_responses"
- table_name = "code_jams"
- users_table = "users"
-
- @require_roles(*ALL_STAFF_ROLES)
- def get(self, jam: int):
- try:
- query = self.db.query(self.table_name).get(jam).merge(
- lambda jam_obj: {
- "participants":
- self.db.query(self.responses_table)
- .filter({"jam": jam_obj["number"]})
- .eq_join("snowflake", self.db.query(self.users_table))
- .without({"left": "snowflake"})
- .zip()
- .coerce_to("array")
- }
- )
-
- jam_data = self.db.run(query)
- except ReqlNonExistenceError:
- log.exception("Failed RethinkDB query")
- raise NotFound()
-
- form_obj = self.db.get(self.forms_table, jam)
- questions = {}
-
- if form_obj:
- for question in form_obj["questions"]:
- questions[question] = self.db.get(self.questions_table, question)
-
- return self.render(
- "staff/jams/participants.html",
- jam=jam_data, form=form_obj, questions=questions
- )