availibility #54

Merged
weeman merged 5 commits from feature/53-availability into main 2021-10-12 19:04:42 +02:00
6 changed files with 40 additions and 60 deletions
Showing only changes of commit cac14b4cfb - Show all commits

View File

@ -31,10 +31,10 @@ def seed_user(nickname,
skills=[],
languages=[],
volunteerwork="",
availabilityStatus=False,
availability_status=False,
freetext="",
availabilityText="",
availabilityHoursPerWeek=42):
availability_text="",
availability_hours_per_week=42):
app.logger.info(f"seeding {nickname} \\o/")
user = User(auth_id=nickname)
@ -43,9 +43,9 @@ def seed_user(nickname,
profile = Profile(nickname=nickname,
pronouns="",
volunteerwork=volunteerwork,
availabilityStatus=availabilityStatus,
availabilityText=availabilityText,
availabilityHoursPerWeek=availabilityHoursPerWeek,
availability_status=availability_status,
availability_text=availability_text,
availability_hours_per_week=availability_hours_per_week,
freetext=freetext,
visible=visible,
user=user)
@ -101,9 +101,9 @@ def seed(dev: bool):
peters_profile = Profile(nickname="peternichtlustig",
pronouns="Herr Dr. Dr.",
volunteerwork="Gartenverein",
availabilityStatus=True,
availabilityHoursPerWeek=42,
availabilityText="Immer",
availability_status=True,
availability_hours_per_week=42,
availability_text="Immer",
freetext="Ich mag Kaffee",
user=peter)
db.session.add(peters_profile)
@ -147,9 +147,9 @@ def seed(dev: bool):
seed_user("dirtydieter",
visible=True,
volunteerwork="Müll sammeln",
availabilityStatus=True,
availabilityHoursPerWeek=24,
availabilityText="Nur Nachts!",
availability_status=True,
availability_hours_per_week=24,
availability_text="Nur Nachts!",
freetext="1001010010111!!!",
skills=[(Skill.skill_id_php, 5)])

View File

@ -135,9 +135,9 @@ def update_profile(user_id: int):
profile.pronouns = request.json.get("pronouns", "")
profile.volunteerwork = request.json.get("volunteerwork", "")
profile.availabilityStatus = request.json.get("availabilityStatus", False)
profile.availabilityText = request.json.get("availabilityText", "")
profile.availabilityHoursPerWeek = request.json.get("availabilityHoursPerWeek", 0)
profile.availability_status = request.json.get("availability_status", False)
profile.availability_text = request.json.get("availability_text", "")
profile.availability_hours_per_week = request.json.get("availability_hours_per_week", 0)
profile.freetext = request.json.get("freetext", "")
profile.visible = request.json.get("visible", False)

View File

@ -33,9 +33,9 @@ class Profile(db.Model):
volunteerwork = Column(String(4000), default="")
freetext = Column(String(4000), default="")
availabilityStatus = Column(Boolean, default=False)
availabilityText = Column(String(4000), default="")
availabilityHoursPerWeek = Column(Integer, default=0)
availability_status = Column(Boolean, default=False)
availability_text = Column(String(4000), default="")
availability_hours_per_week = Column(Integer, default=0)
visible = Column(Boolean, nullable=False, default=False)
created = Column(DateTime, nullable=False, default=datetime.now)
@ -54,9 +54,9 @@ class Profile(db.Model):
"nickname": self.nickname,
"pronouns": self.pronouns,
"volunteerwork": self.volunteerwork,
"availabilityStatus": self.availabilityStatus,
"availabilityText": self.availabilityText,
"availabilityHoursPerWeek": self.availabilityHoursPerWeek,
"availability_status": self.availability_status,
"availability_text": self.availability_text,
"availability_hours_per_week": self.availability_hours_per_week,
"freetext": self.freetext,
"visible": self.visible,
"address": self.address.to_dict() if self.address else None,

View File

@ -33,8 +33,9 @@ class TestProfileEndpoint(ApiTest):
data = {
"pronouns": "Monsieur",
"volunteerwork": "ja",
"availabilityStatus": False,
"availabilityText": "Nie",
"availability_status": False,
"availability_text": "Nie",
"availability_hours_per_week": "23",
"freetext": "Hallo",
"visible": True,
"address": {
@ -111,7 +112,9 @@ class TestProfileEndpoint(ApiTest):
profile = user.profile
self.assertEqual("Monsieur", profile.pronouns)
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.assertTrue(profile.visible)
@ -199,9 +202,9 @@ class TestProfileEndpoint(ApiTest):
"user_id": 1,
"nickname": "peternichtlustig",
"pronouns": "Herr Dr. Dr.",
"availabilityStatus": True,
"availabilityHoursPerWeek": 25,
"availabilityText": "Immer",
"availability_status": True,
"availability_hours_per_week": 42,
"availability_text": "Immer",
"freetext": "Ich mag Kaffee",
"volunteerwork": "Gartenverein",
"visible": False,

View File

@ -11,24 +11,25 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '459520b01f34'
down_revision = '99f6b0756445'
down_revision = '9183e2335b05'
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')
with op.batch_alter_table("profile") as batch_op:
batch_op.add_column(sa.Column('availability_status', sa.Boolean(), nullable=False))
batch_op.add_column(sa.Column('availability_text', sa.String(length=4000), nullable=True))
batch_op.add_column(sa.Column('availability_hours_per_week', sa.Integer(), nullable=True))
batch_op.drop_column('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')
with op.batch_alter_table("profile") as batch_op:
batch_op.drop_column('profile', 'availability_hours_per_week')
batch_op.drop_column('profile', 'availability_text')
batch_op.drop_column('profile', 'availability_status')
# ### end Alembic commands ###

View File

@ -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