add profile visible flag
This commit is contained in:
parent
3b6225f621
commit
9f4795b9f1
@ -107,6 +107,7 @@ 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.freetext = request.json.get("freetext", "")
|
profile.freetext = request.json.get("freetext", "")
|
||||||
|
profile.visible = request.json.get("visible", False)
|
||||||
|
|
||||||
update_address(profile, request.json.get("address", {}))
|
update_address(profile, request.json.get("address", {}))
|
||||||
update_contacts(profile, request.json.get("contacts", {}))
|
update_contacts(profile, request.json.get("contacts", {}))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, SmallInteger, String, DateTime, ForeignKey
|
from sqlalchemy import Boolean, Column, Integer, SmallInteger, String, DateTime, ForeignKey
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
@ -28,6 +28,7 @@ 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="")
|
||||||
|
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)
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ class Profile(db.Model):
|
|||||||
"pronouns": self.pronouns,
|
"pronouns": self.pronouns,
|
||||||
"volunteerwork": self.volunteerwork,
|
"volunteerwork": self.volunteerwork,
|
||||||
"freetext": self.freetext,
|
"freetext": self.freetext,
|
||||||
|
"visible": self.visible,
|
||||||
"address": self.address.to_dict(),
|
"address": self.address.to_dict(),
|
||||||
"contacts": list(map(lambda contact: contact.to_dict(), self.contacts)),
|
"contacts": list(map(lambda contact: contact.to_dict(), self.contacts)),
|
||||||
"skills": list(map(lambda skill: skill.to_dict(), self.skills)),
|
"skills": list(map(lambda skill: skill.to_dict(), self.skills)),
|
||||||
|
@ -30,6 +30,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"pronouns": "Monsieur",
|
"pronouns": "Monsieur",
|
||||||
"volunteerwork": "ja",
|
"volunteerwork": "ja",
|
||||||
"freetext": "Hallo",
|
"freetext": "Hallo",
|
||||||
|
"visible": True,
|
||||||
"address": {
|
"address": {
|
||||||
"name": "Peeeda",
|
"name": "Peeeda",
|
||||||
"street": "Bachstraße",
|
"street": "Bachstraße",
|
||||||
@ -92,6 +93,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
self.assertEqual("Monsieur", profile.pronouns)
|
self.assertEqual("Monsieur", profile.pronouns)
|
||||||
self.assertEqual("ja", profile.volunteerwork)
|
self.assertEqual("ja", profile.volunteerwork)
|
||||||
self.assertEqual("Hallo", profile.freetext)
|
self.assertEqual("Hallo", profile.freetext)
|
||||||
|
self.assertTrue(profile.visible)
|
||||||
|
|
||||||
address = profile.address
|
address = profile.address
|
||||||
self.assertEqual(address.name, "Peeeda")
|
self.assertEqual(address.name, "Peeeda")
|
||||||
@ -156,6 +158,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"pronouns": "Herr Dr. Dr.",
|
"pronouns": "Herr Dr. Dr.",
|
||||||
"freetext": "Ich mag Kaffee",
|
"freetext": "Ich mag Kaffee",
|
||||||
"volunteerwork": "Gartenverein",
|
"volunteerwork": "Gartenverein",
|
||||||
|
"visible": False,
|
||||||
"address": {
|
"address": {
|
||||||
"additional": "Hinterhaus",
|
"additional": "Hinterhaus",
|
||||||
"city": "Bielefeld",
|
"city": "Bielefeld",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Initial migration.
|
"""Initial migration.
|
||||||
|
|
||||||
Revision ID: f95308aceda1
|
Revision ID: ebb2dd1fb371
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2021-06-20 19:11:47.086814
|
Create Date: 2021-07-02 16:20:18.160228
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = 'f95308aceda1'
|
revision = 'ebb2dd1fb371'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
@ -34,6 +34,7 @@ def upgrade():
|
|||||||
sa.Column('pronouns', sa.String(length=25), nullable=True),
|
sa.Column('pronouns', sa.String(length=25), nullable=True),
|
||||||
sa.Column('volunteerwork', sa.String(length=4000), nullable=True),
|
sa.Column('volunteerwork', sa.String(length=4000), nullable=True),
|
||||||
sa.Column('freetext', sa.String(length=4000), nullable=True),
|
sa.Column('freetext', sa.String(length=4000), nullable=True),
|
||||||
|
sa.Column('visible', sa.Boolean(), nullable=False),
|
||||||
sa.Column('created', sa.DateTime(), nullable=False),
|
sa.Column('created', sa.DateTime(), nullable=False),
|
||||||
sa.Column('updated', sa.DateTime(), nullable=False),
|
sa.Column('updated', sa.DateTime(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
Loading…
Reference in New Issue
Block a user