availibility #54
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
repos:
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
@ -26,7 +26,15 @@ def seed_contacttypes():
|
|||||||
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
||||||
|
|
||||||
|
|
||||||
def seed_user(nickname, visible=False, skills=[], languages=[], volunteerwork="", availability="", freetext=""):
|
def seed_user(nickname,
|
||||||
|
visible=False,
|
||||||
|
skills=[],
|
||||||
|
languages=[],
|
||||||
|
volunteerwork="",
|
||||||
|
availabilityStatus=False,
|
||||||
|
freetext="",
|
||||||
|
availabilityText="",
|
||||||
|
availabilityHoursPerWeek=42):
|
||||||
app.logger.info(f"seeding {nickname} \\o/")
|
app.logger.info(f"seeding {nickname} \\o/")
|
||||||
|
|
||||||
user = User(auth_id=nickname)
|
user = User(auth_id=nickname)
|
||||||
@ -35,7 +43,9 @@ def seed_user(nickname, visible=False, skills=[], languages=[], volunteerwork=""
|
|||||||
profile = Profile(nickname=nickname,
|
profile = Profile(nickname=nickname,
|
||||||
pronouns="",
|
pronouns="",
|
||||||
volunteerwork=volunteerwork,
|
volunteerwork=volunteerwork,
|
||||||
availability=availability,
|
availabilityStatus=availabilityStatus,
|
||||||
|
availabilityText=availabilityText,
|
||||||
|
availabilityHoursPerWeek=availabilityHoursPerWeek,
|
||||||
freetext=freetext,
|
freetext=freetext,
|
||||||
visible=visible,
|
visible=visible,
|
||||||
user=user)
|
user=user)
|
||||||
@ -91,7 +101,9 @@ def seed(dev: bool):
|
|||||||
peters_profile = Profile(nickname="peternichtlustig",
|
peters_profile = Profile(nickname="peternichtlustig",
|
||||||
pronouns="Herr Dr. Dr.",
|
pronouns="Herr Dr. Dr.",
|
||||||
volunteerwork="Gartenverein",
|
volunteerwork="Gartenverein",
|
||||||
availability="Immer",
|
availabilityStatus=True,
|
||||||
|
availabilityHoursPerWeek=42,
|
||||||
|
availabilityText="Immer",
|
||||||
freetext="Ich mag Kaffee",
|
freetext="Ich mag Kaffee",
|
||||||
user=peter)
|
user=peter)
|
||||||
db.session.add(peters_profile)
|
db.session.add(peters_profile)
|
||||||
@ -135,7 +147,9 @@ def seed(dev: bool):
|
|||||||
seed_user("dirtydieter",
|
seed_user("dirtydieter",
|
||||||
visible=True,
|
visible=True,
|
||||||
volunteerwork="Müll sammeln",
|
volunteerwork="Müll sammeln",
|
||||||
availability="Nur nachts",
|
availabilityStatus=True,
|
||||||
|
availabilityHoursPerWeek=24,
|
||||||
|
availabilityText="Nur Nachts!",
|
||||||
freetext="1001010010111!!!",
|
freetext="1001010010111!!!",
|
||||||
skills=[(Skill.skill_id_php, 5)])
|
skills=[(Skill.skill_id_php, 5)])
|
||||||
|
|
||||||
|
@ -135,7 +135,9 @@ def update_profile(user_id: int):
|
|||||||
|
|
||||||
profile.pronouns = request.json.get("pronouns", "")
|
profile.pronouns = request.json.get("pronouns", "")
|
||||||
profile.volunteerwork = request.json.get("volunteerwork", "")
|
profile.volunteerwork = request.json.get("volunteerwork", "")
|
||||||
profile.availability = request.json.get("availability", "")
|
profile.availabilityStatus = request.json.get("availabilityStatus", False)
|
||||||
|
profile.availabilityText = request.json.get("availabilityText", "")
|
||||||
|
profile.availabilityHoursPerWeek = request.json.get("availabilityHoursPerWeek", 0)
|
||||||
profile.freetext = request.json.get("freetext", "")
|
profile.freetext = request.json.get("freetext", "")
|
||||||
profile.visible = request.json.get("visible", False)
|
profile.visible = request.json.get("visible", False)
|
||||||
|
|
||||||
|
10
ki/models.py
10
ki/models.py
@ -32,7 +32,11 @@ class Profile(db.Model):
|
|||||||
pronouns = Column(String(25), default="")
|
pronouns = Column(String(25), default="")
|
||||||
volunteerwork = Column(String(4000), default="")
|
volunteerwork = Column(String(4000), default="")
|
||||||
freetext = Column(String(4000), default="")
|
freetext = Column(String(4000), default="")
|
||||||
availability = Column(String(4000), default="")
|
|
||||||
|
availabilityStatus = Column(Boolean, default=False)
|
||||||
|
availabilityText = Column(String(4000), default="")
|
||||||
|
availabilityHoursPerWeek = Column(Integer, default=0)
|
||||||
|
|
||||||
visible = Column(Boolean, nullable=False, default=False)
|
visible = Column(Boolean, nullable=False, default=False)
|
||||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||||
updated = Column(DateTime, onupdate=datetime.now, nullable=False, default=datetime.now)
|
updated = Column(DateTime, onupdate=datetime.now, nullable=False, default=datetime.now)
|
||||||
@ -50,7 +54,9 @@ class Profile(db.Model):
|
|||||||
"nickname": self.nickname,
|
"nickname": self.nickname,
|
||||||
"pronouns": self.pronouns,
|
"pronouns": self.pronouns,
|
||||||
"volunteerwork": self.volunteerwork,
|
"volunteerwork": self.volunteerwork,
|
||||||
"availability": self.availability,
|
"availabilityStatus": self.availabilityStatus,
|
||||||
|
"availabilityText": self.availabilityText,
|
||||||
|
"availabilityHoursPerWeek": self.availabilityHoursPerWeek,
|
||||||
"freetext": self.freetext,
|
"freetext": self.freetext,
|
||||||
"visible": self.visible,
|
"visible": self.visible,
|
||||||
"address": self.address.to_dict() if self.address else None,
|
"address": self.address.to_dict() if self.address else None,
|
||||||
|
@ -33,7 +33,8 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
data = {
|
data = {
|
||||||
"pronouns": "Monsieur",
|
"pronouns": "Monsieur",
|
||||||
"volunteerwork": "ja",
|
"volunteerwork": "ja",
|
||||||
"availability": "Nie",
|
"availabilityStatus": False,
|
||||||
|
"availabilityText": "Nie",
|
||||||
"freetext": "Hallo",
|
"freetext": "Hallo",
|
||||||
"visible": True,
|
"visible": True,
|
||||||
"address": {
|
"address": {
|
||||||
@ -110,7 +111,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
profile = user.profile
|
profile = user.profile
|
||||||
self.assertEqual("Monsieur", profile.pronouns)
|
self.assertEqual("Monsieur", profile.pronouns)
|
||||||
self.assertEqual("ja", profile.volunteerwork)
|
self.assertEqual("ja", profile.volunteerwork)
|
||||||
self.assertEqual("Nie", profile.availability)
|
self.assertEqual("Nie", profile.availabilityText)
|
||||||
self.assertEqual("Hallo", profile.freetext)
|
self.assertEqual("Hallo", profile.freetext)
|
||||||
self.assertTrue(profile.visible)
|
self.assertTrue(profile.visible)
|
||||||
|
|
||||||
@ -198,7 +199,9 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"user_id": 1,
|
"user_id": 1,
|
||||||
"nickname": "peternichtlustig",
|
"nickname": "peternichtlustig",
|
||||||
"pronouns": "Herr Dr. Dr.",
|
"pronouns": "Herr Dr. Dr.",
|
||||||
"availability": "Immer",
|
"availabilityStatus": True,
|
||||||
|
"availabilityHoursPerWeek": 25,
|
||||||
|
"availabilityText": "Immer",
|
||||||
"freetext": "Ich mag Kaffee",
|
"freetext": "Ich mag Kaffee",
|
||||||
"volunteerwork": "Gartenverein",
|
"volunteerwork": "Gartenverein",
|
||||||
"visible": False,
|
"visible": False,
|
||||||
|
34
migrations/versions/459520b01f34_.py
Normal file
34
migrations/versions/459520b01f34_.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 459520b01f34
|
||||||
|
Revises: 99f6b0756445
|
||||||
|
Create Date: 2021-10-03 14:45:30.389359
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '459520b01f34'
|
||||||
|
down_revision = '99f6b0756445'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('profile', sa.Column('availabilityStatus', sa.Boolean(), nullable=True))
|
||||||
|
op.add_column('profile', sa.Column('availabilityText', sa.String(length=4000), nullable=True))
|
||||||
|
op.add_column('profile', sa.Column('availabilityHoursPerWeek', sa.Integer(), nullable=True))
|
||||||
|
op.drop_column('profile', 'availability')
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('profile', sa.Column('availability', sa.VARCHAR(length=4000), nullable=True))
|
||||||
|
op.drop_column('profile', 'availabilityHoursPerWeek')
|
||||||
|
op.drop_column('profile', 'availabilityText')
|
||||||
|
op.drop_column('profile', 'availabilityStatus')
|
||||||
|
# ### end Alembic commands ###
|
24
migrations/versions/99f6b0756445_.py
Normal file
24
migrations/versions/99f6b0756445_.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 99f6b0756445
|
||||||
|
Revises: 9183e2335b05
|
||||||
|
Create Date: 2021-10-03 14:45:10.980556
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '99f6b0756445'
|
||||||
|
down_revision = '9183e2335b05'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user