diff options
Diffstat (limited to 'pysite')
-rw-r--r-- | pysite/migrations/tables/code_jam_participants/__init__.py | 0 | ||||
-rw-r--r-- | pysite/migrations/tables/code_jam_participants/v1.py | 11 | ||||
-rw-r--r-- | pysite/migrations/tables/users/v2.py | 11 | ||||
-rw-r--r-- | pysite/tables.py | 1 | ||||
-rw-r--r-- | pysite/views/main/jams/profile.py | 16 |
5 files changed, 23 insertions, 16 deletions
diff --git a/pysite/migrations/tables/code_jam_participants/__init__.py b/pysite/migrations/tables/code_jam_participants/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pysite/migrations/tables/code_jam_participants/__init__.py diff --git a/pysite/migrations/tables/code_jam_participants/v1.py b/pysite/migrations/tables/code_jam_participants/v1.py new file mode 100644 index 00000000..c6e7bff6 --- /dev/null +++ b/pysite/migrations/tables/code_jam_participants/v1.py @@ -0,0 +1,11 @@ +def run(db, table, table_obj): + """ + Remove stored dates of birth from code jam participants + """ + + for document in db.get_all(table): + if "dob" in document: + del document["dob"] + + db.insert(table, document, conflict="replace", durability="soft") + db.sync(table) diff --git a/pysite/migrations/tables/users/v2.py b/pysite/migrations/tables/users/v2.py new file mode 100644 index 00000000..820d0d6d --- /dev/null +++ b/pysite/migrations/tables/users/v2.py @@ -0,0 +1,11 @@ +def run(db, table, table_obj): + """ + Remove stored email addresses from every user document - "apparently `update` doesn't update" update + """ + + for document in db.get_all(table): + if "email" in document: + del document["email"] + + db.insert(table, document, conflict="replace", durability="soft") + db.sync(table) diff --git a/pysite/tables.py b/pysite/tables.py index be43c588..b33f04b9 100644 --- a/pysite/tables.py +++ b/pysite/tables.py @@ -112,7 +112,6 @@ TABLES = { primary_key="id", keys=sorted([ "id", # str - "dob", # str "github_username", # str "timezone" # str ]) diff --git a/pysite/views/main/jams/profile.py b/pysite/views/main/jams/profile.py index d8a663f7..f84534e6 100644 --- a/pysite/views/main/jams/profile.py +++ b/pysite/views/main/jams/profile.py @@ -1,5 +1,3 @@ -import datetime - from flask import redirect, request, url_for from werkzeug.exceptions import BadRequest @@ -47,24 +45,12 @@ class JamsProfileView(RouteView, DBMixin, OAuthMixin): if not participant: participant = {"id": self.user_data["user_id"]} - dob = request.form.get("dob") github_username = request.form.get("github_username") timezone = request.form.get("timezone") - if not dob or not github_username or not timezone: + if not github_username or not timezone: return BadRequest() - # Convert given datetime strings into actual objects, adding timezones to keep rethinkdb happy - dob = datetime.datetime.strptime(dob, "%Y-%m-%d") - dob = dob.replace(tzinfo=datetime.timezone.utc) - - now = datetime.datetime.now(tz=datetime.timezone.utc) - then = now.replace(year=now.year - 13) - - if then < dob: - raise BadRequest() # They're too young, but this is validated on the form - - participant["dob"] = dob participant["github_username"] = github_username participant["timezone"] = timezone |