availibility #54
@ -31,10 +31,10 @@ def seed_user(nickname,
|
|||||||
skills=[],
|
skills=[],
|
||||||
languages=[],
|
languages=[],
|
||||||
volunteerwork="",
|
volunteerwork="",
|
||||||
availabilityStatus=False,
|
availability_status=False,
|
||||||
freetext="",
|
freetext="",
|
||||||
availabilityText="",
|
availability_text="",
|
||||||
availabilityHoursPerWeek=42):
|
availability_hours_per_week=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)
|
||||||
@ -43,9 +43,9 @@ def seed_user(nickname,
|
|||||||
profile = Profile(nickname=nickname,
|
profile = Profile(nickname=nickname,
|
||||||
pronouns="",
|
pronouns="",
|
||||||
volunteerwork=volunteerwork,
|
volunteerwork=volunteerwork,
|
||||||
availabilityStatus=availabilityStatus,
|
availability_status=availability_status,
|
||||||
availabilityText=availabilityText,
|
availability_text=availability_text,
|
||||||
availabilityHoursPerWeek=availabilityHoursPerWeek,
|
availability_hours_per_week=availability_hours_per_week,
|
||||||
freetext=freetext,
|
freetext=freetext,
|
||||||
visible=visible,
|
visible=visible,
|
||||||
user=user)
|
user=user)
|
||||||
@ -101,9 +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",
|
||||||
availabilityStatus=True,
|
availability_status=True,
|
||||||
availabilityHoursPerWeek=42,
|
availability_hours_per_week=42,
|
||||||
availabilityText="Immer",
|
availability_text="Immer",
|
||||||
freetext="Ich mag Kaffee",
|
freetext="Ich mag Kaffee",
|
||||||
user=peter)
|
user=peter)
|
||||||
db.session.add(peters_profile)
|
db.session.add(peters_profile)
|
||||||
@ -147,9 +147,9 @@ def seed(dev: bool):
|
|||||||
seed_user("dirtydieter",
|
seed_user("dirtydieter",
|
||||||
visible=True,
|
visible=True,
|
||||||
volunteerwork="Müll sammeln",
|
volunteerwork="Müll sammeln",
|
||||||
availabilityStatus=True,
|
availability_status=True,
|
||||||
availabilityHoursPerWeek=24,
|
availability_hours_per_week=24,
|
||||||
availabilityText="Nur Nachts!",
|
availability_text="Nur Nachts!",
|
||||||
freetext="1001010010111!!!",
|
freetext="1001010010111!!!",
|
||||||
skills=[(Skill.skill_id_php, 5)])
|
skills=[(Skill.skill_id_php, 5)])
|
||||||
|
|
||||||
|
@ -135,9 +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.availabilityStatus = request.json.get("availabilityStatus", False)
|
profile.availability_status = request.json.get("availability_status", False)
|
||||||
profile.availabilityText = request.json.get("availabilityText", "")
|
profile.availability_text = request.json.get("availability_text", "")
|
||||||
profile.availabilityHoursPerWeek = request.json.get("availabilityHoursPerWeek", 0)
|
profile.availability_hours_per_week = request.json.get("availability_hours_per_week", 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)
|
||||||
|
|
||||||
|
12
ki/models.py
12
ki/models.py
@ -33,9 +33,9 @@ class Profile(db.Model):
|
|||||||
volunteerwork = Column(String(4000), default="")
|
volunteerwork = Column(String(4000), default="")
|
||||||
freetext = Column(String(4000), default="")
|
freetext = Column(String(4000), default="")
|
||||||
|
|
||||||
availabilityStatus = Column(Boolean, default=False)
|
availability_status = Column(Boolean, default=False)
|
||||||
availabilityText = Column(String(4000), default="")
|
availability_text = Column(String(4000), default="")
|
||||||
availabilityHoursPerWeek = Column(Integer, default=0)
|
availability_hours_per_week = 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)
|
||||||
@ -54,9 +54,9 @@ class Profile(db.Model):
|
|||||||
"nickname": self.nickname,
|
"nickname": self.nickname,
|
||||||
"pronouns": self.pronouns,
|
"pronouns": self.pronouns,
|
||||||
"volunteerwork": self.volunteerwork,
|
"volunteerwork": self.volunteerwork,
|
||||||
"availabilityStatus": self.availabilityStatus,
|
"availability_status": self.availability_status,
|
||||||
"availabilityText": self.availabilityText,
|
"availability_text": self.availability_text,
|
||||||
"availabilityHoursPerWeek": self.availabilityHoursPerWeek,
|
"availability_hours_per_week": self.availability_hours_per_week,
|
||||||
"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,8 +33,9 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
data = {
|
data = {
|
||||||
"pronouns": "Monsieur",
|
"pronouns": "Monsieur",
|
||||||
"volunteerwork": "ja",
|
"volunteerwork": "ja",
|
||||||
"availabilityStatus": False,
|
"availability_status": False,
|
||||||
"availabilityText": "Nie",
|
"availability_text": "Nie",
|
||||||
|
"availability_hours_per_week": "23",
|
||||||
"freetext": "Hallo",
|
"freetext": "Hallo",
|
||||||
"visible": True,
|
"visible": True,
|
||||||
"address": {
|
"address": {
|
||||||
@ -111,7 +112,9 @@ 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.availabilityText)
|
self.assertEqual(False, profile.availability_status)
|
||||||
|
self.assertEqual("Nie", profile.availability_text)
|
||||||
|
self.assertEqual(23, profile.availability_hours_per_week)
|
||||||
self.assertEqual("Hallo", profile.freetext)
|
self.assertEqual("Hallo", profile.freetext)
|
||||||
self.assertTrue(profile.visible)
|
self.assertTrue(profile.visible)
|
||||||
|
|
||||||
@ -199,9 +202,9 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"user_id": 1,
|
"user_id": 1,
|
||||||
"nickname": "peternichtlustig",
|
"nickname": "peternichtlustig",
|
||||||
"pronouns": "Herr Dr. Dr.",
|
"pronouns": "Herr Dr. Dr.",
|
||||||
"availabilityStatus": True,
|
"availability_status": True,
|
||||||
"availabilityHoursPerWeek": 25,
|
"availability_hours_per_week": 42,
|
||||||
"availabilityText": "Immer",
|
"availability_text": "Immer",
|
||||||
"freetext": "Ich mag Kaffee",
|
"freetext": "Ich mag Kaffee",
|
||||||
"volunteerwork": "Gartenverein",
|
"volunteerwork": "Gartenverein",
|
||||||
"visible": False,
|
"visible": False,
|
||||||
|
@ -11,24 +11,25 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '459520b01f34'
|
revision = '459520b01f34'
|
||||||
down_revision = '99f6b0756445'
|
down_revision = '9183e2335b05'
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.add_column('profile', sa.Column('availabilityStatus', sa.Boolean(), nullable=True))
|
with op.batch_alter_table("profile") as batch_op:
|
||||||
op.add_column('profile', sa.Column('availabilityText', sa.String(length=4000), nullable=True))
|
batch_op.add_column(sa.Column('availability_status', sa.Boolean(), nullable=False))
|
||||||
op.add_column('profile', sa.Column('availabilityHoursPerWeek', sa.Integer(), nullable=True))
|
batch_op.add_column(sa.Column('availability_text', sa.String(length=4000), nullable=True))
|
||||||
op.drop_column('profile', 'availability')
|
batch_op.add_column(sa.Column('availability_hours_per_week', sa.Integer(), nullable=True))
|
||||||
|
batch_op.drop_column('availability')
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.add_column('profile', sa.Column('availability', sa.VARCHAR(length=4000), nullable=True))
|
with op.batch_alter_table("profile") as batch_op:
|
||||||
op.drop_column('profile', 'availabilityHoursPerWeek')
|
batch_op.drop_column('profile', 'availability_hours_per_week')
|
||||||
op.drop_column('profile', 'availabilityText')
|
batch_op.drop_column('profile', 'availability_text')
|
||||||
op.drop_column('profile', 'availabilityStatus')
|
batch_op.drop_column('profile', 'availability_status')
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
"""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