From a401c6d4a7524a65b0964d3efd0da05074ab6870 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 5 Jul 2021 20:16:50 +0200 Subject: [PATCH] add availability --- ki/actions/seed.py | 1 + ki/handlers/update_profile.py | 1 + ki/models.py | 2 ++ ki/test/test_profile_endpoint.py | 3 +++ migrations/README | 1 + migrations/alembic.ini | 4 ---- migrations/env.py | 4 ---- ...migration.py => 808fe55111df_initial_migration.py} | 11 ++++------- 8 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 migrations/README rename migrations/versions/{ebb2dd1fb371_initial_migration.py => 808fe55111df_initial_migration.py} (95%) diff --git a/ki/actions/seed.py b/ki/actions/seed.py index 854bf89..f6d2976 100644 --- a/ki/actions/seed.py +++ b/ki/actions/seed.py @@ -65,6 +65,7 @@ def seed(dev: bool): peters_profile = Profile(nickname="peternichtlustig", pronouns="Herr Dr. Dr.", volunteerwork="Gartenverein", + availability="Immer", freetext="Ich mag Kaffee", user=peter) db.session.add(peters_profile) diff --git a/ki/handlers/update_profile.py b/ki/handlers/update_profile.py index 75d5fd1..97480b6 100644 --- a/ki/handlers/update_profile.py +++ b/ki/handlers/update_profile.py @@ -110,6 +110,7 @@ def update_profile(user_id: int): profile.pronouns = request.json.get("pronouns", "") profile.volunteerwork = request.json.get("volunteerwork", "") + profile.availability = request.json.get("availability", "") profile.freetext = request.json.get("freetext", "") profile.visible = request.json.get("visible", False) diff --git a/ki/models.py b/ki/models.py index 400df5b..afd5350 100644 --- a/ki/models.py +++ b/ki/models.py @@ -32,6 +32,7 @@ class Profile(db.Model): pronouns = Column(String(25), default="") volunteerwork = Column(String(4000), default="") freetext = Column(String(4000), default="") + availability = Column(String(4000), default="") visible = Column(Boolean, nullable=False, default=False) created = Column(DateTime, nullable=False, default=datetime.now) updated = Column(DateTime, onupdate=datetime.now, nullable=False, default=datetime.now) @@ -48,6 +49,7 @@ class Profile(db.Model): "nickname": self.nickname, "pronouns": self.pronouns, "volunteerwork": self.volunteerwork, + "availability": self.availability, "freetext": self.freetext, "visible": self.visible, "address": self.address.to_dict(), diff --git a/ki/test/test_profile_endpoint.py b/ki/test/test_profile_endpoint.py index b48def5..56638cd 100644 --- a/ki/test/test_profile_endpoint.py +++ b/ki/test/test_profile_endpoint.py @@ -33,6 +33,7 @@ class TestProfileEndpoint(ApiTest): data = { "pronouns": "Monsieur", "volunteerwork": "ja", + "availability": "Nie", "freetext": "Hallo", "visible": True, "address": { @@ -96,6 +97,7 @@ class TestProfileEndpoint(ApiTest): profile = user.profile self.assertEqual("Monsieur", profile.pronouns) self.assertEqual("ja", profile.volunteerwork) + self.assertEqual("Nie", profile.availability) self.assertEqual("Hallo", profile.freetext) self.assertTrue(profile.visible) @@ -165,6 +167,7 @@ class TestProfileEndpoint(ApiTest): "user_id": 1, "nickname": "peternichtlustig", "pronouns": "Herr Dr. Dr.", + "availability": "Immer", "freetext": "Ich mag Kaffee", "volunteerwork": "Gartenverein", "visible": False, diff --git a/migrations/README b/migrations/README new file mode 100644 index 0000000..98e4f9c --- /dev/null +++ b/migrations/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/migrations/alembic.ini b/migrations/alembic.ini index 3819021..ec9d45c 100644 --- a/migrations/alembic.ini +++ b/migrations/alembic.ini @@ -1,7 +1,3 @@ -; SPDX-FileCopyrightText: WTF Kooperative eG -; -; SPDX-License-Identifier: AGPL-3.0-or-later - # A generic, single database configuration. [alembic] diff --git a/migrations/env.py b/migrations/env.py index a5a8114..68feded 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,7 +1,3 @@ -# SPDX-FileCopyrightText: WTF Kooperative eG -# -# SPDX-License-Identifier: AGPL-3.0-or-later - from __future__ import with_statement import logging diff --git a/migrations/versions/ebb2dd1fb371_initial_migration.py b/migrations/versions/808fe55111df_initial_migration.py similarity index 95% rename from migrations/versions/ebb2dd1fb371_initial_migration.py rename to migrations/versions/808fe55111df_initial_migration.py index e339d05..e74b2ee 100644 --- a/migrations/versions/ebb2dd1fb371_initial_migration.py +++ b/migrations/versions/808fe55111df_initial_migration.py @@ -1,12 +1,8 @@ -# SPDX-FileCopyrightText: WTF Kooperative eG -# -# SPDX-License-Identifier: AGPL-3.0-or-later - """Initial migration. -Revision ID: ebb2dd1fb371 +Revision ID: 808fe55111df Revises: -Create Date: 2021-07-02 16:20:18.160228 +Create Date: 2021-07-05 20:13:50.560579 """ from alembic import op @@ -14,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'ebb2dd1fb371' +revision = '808fe55111df' down_revision = None branch_labels = None depends_on = None @@ -38,6 +34,7 @@ def upgrade(): sa.Column('pronouns', sa.String(length=25), nullable=True), sa.Column('volunteerwork', sa.String(length=4000), nullable=True), sa.Column('freetext', sa.String(length=4000), nullable=True), + sa.Column('availability', sa.String(length=4000), nullable=True), sa.Column('visible', sa.Boolean(), nullable=False), sa.Column('created', sa.DateTime(), nullable=False), sa.Column('updated', sa.DateTime(), nullable=False), -- 2.30.2