forked from kompetenzinventar/ki-backend
availibility
This commit is contained in:
parent
8bdc1564be
commit
8772a13163
@ -2,6 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: flake8
|
||||
|
@ -26,7 +26,15 @@ def seed_contacttypes():
|
||||
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/")
|
||||
|
||||
user = User(auth_id=nickname)
|
||||
@ -35,7 +43,9 @@ def seed_user(nickname, visible=False, skills=[], languages=[], volunteerwork=""
|
||||
profile = Profile(nickname=nickname,
|
||||
pronouns="",
|
||||
volunteerwork=volunteerwork,
|
||||
availability=availability,
|
||||
availabilityStatus=availabilityStatus,
|
||||
availabilityText=availabilityText,
|
||||
availabilityHoursPerWeek=availabilityHoursPerWeek,
|
||||
freetext=freetext,
|
||||
visible=visible,
|
||||
user=user)
|
||||
@ -91,7 +101,9 @@ def seed(dev: bool):
|
||||
peters_profile = Profile(nickname="peternichtlustig",
|
||||
pronouns="Herr Dr. Dr.",
|
||||
volunteerwork="Gartenverein",
|
||||
availability="Immer",
|
||||
availabilityStatus=True,
|
||||
availabilityHoursPerWeek=42,
|
||||
availabilityText="Immer",
|
||||
freetext="Ich mag Kaffee",
|
||||
user=peter)
|
||||
db.session.add(peters_profile)
|
||||
@ -135,7 +147,9 @@ def seed(dev: bool):
|
||||
seed_user("dirtydieter",
|
||||
visible=True,
|
||||
volunteerwork="Müll sammeln",
|
||||
availability="Nur nachts",
|
||||
availabilityStatus=True,
|
||||
availabilityHoursPerWeek=24,
|
||||
availabilityText="Nur Nachts!",
|
||||
freetext="1001010010111!!!",
|
||||
skills=[(Skill.skill_id_php, 5)])
|
||||
|
||||
|
@ -135,7 +135,9 @@ 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.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.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="")
|
||||
volunteerwork = 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)
|
||||
created = Column(DateTime, 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,
|
||||
"pronouns": self.pronouns,
|
||||
"volunteerwork": self.volunteerwork,
|
||||
"availability": self.availability,
|
||||
"availabilityStatus": self.availabilityStatus,
|
||||
"availabilityText": self.availabilityText,
|
||||
"availabilityHoursPerWeek": self.availabilityHoursPerWeek,
|
||||
"freetext": self.freetext,
|
||||
"visible": self.visible,
|
||||
"address": self.address.to_dict() if self.address else None,
|
||||
|
@ -33,7 +33,8 @@ class TestProfileEndpoint(ApiTest):
|
||||
data = {
|
||||
"pronouns": "Monsieur",
|
||||
"volunteerwork": "ja",
|
||||
"availability": "Nie",
|
||||
"availabilityStatus": False,
|
||||
"availabilityText": "Nie",
|
||||
"freetext": "Hallo",
|
||||
"visible": True,
|
||||
"address": {
|
||||
@ -110,7 +111,7 @@ class TestProfileEndpoint(ApiTest):
|
||||
profile = user.profile
|
||||
self.assertEqual("Monsieur", profile.pronouns)
|
||||
self.assertEqual("ja", profile.volunteerwork)
|
||||
self.assertEqual("Nie", profile.availability)
|
||||
self.assertEqual("Nie", profile.availabilityText)
|
||||
self.assertEqual("Hallo", profile.freetext)
|
||||
self.assertTrue(profile.visible)
|
||||
|
||||
@ -198,7 +199,9 @@ class TestProfileEndpoint(ApiTest):
|
||||
"user_id": 1,
|
||||
"nickname": "peternichtlustig",
|
||||
"pronouns": "Herr Dr. Dr.",
|
||||
"availability": "Immer",
|
||||
"availabilityStatus": True,
|
||||
"availabilityHoursPerWeek": 25,
|
||||
"availabilityText": "Immer",
|
||||
"freetext": "Ich mag Kaffee",
|
||||
"volunteerwork": "Gartenverein",
|
||||
"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