Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/api/helpers/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,11 @@
'TWD',
'USD'
]

AGE_GROUP_CHOICES = [
'19 or less',
'20 to 29',
'30 to 39',
'40 to 49',
'50 or above'
]
4 changes: 3 additions & 1 deletion app/api/schema/attendees.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from marshmallow import validate
from marshmallow_jsonapi import fields
from marshmallow_jsonapi.flask import Relationship

from app.api.helpers.utilities import dasherize
from app.api.schema.base import SoftDeletionSchema
from app.api.helpers.validations import validate_complex_fields_json
from marshmallow import validates_schema

from app.api.helpers.static import AGE_GROUP_CHOICES

class AttendeeSchemaPublic(SoftDeletionSchema):
"""
Expand Down Expand Up @@ -48,6 +49,7 @@ def validate_json(self, data, original_data):
facebook = fields.Url(allow_none=True)
github = fields.Url(allow_none=True)
gender = fields.Str(allow_none=True)
age_group = fields.Str(validate=validate.OneOf(choices=AGE_GROUP_CHOICES), allow_none=True)
birth_date = fields.DateTime(allow_none=True)

ticket_id = fields.Str(allow_none=True)
Expand Down
1 change: 1 addition & 0 deletions app/models/custom_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"facebook": {"include": 0, "require": 0},
"github": {"include": 1, "require": 0},
"gender": {"include": 0, "require": 0},
"age_group": {"include": 0, "require": 0},
}

session_form_str = json.dumps(SESSION_FORM, separators=(',', ':'))
Expand Down
1 change: 1 addition & 0 deletions app/models/ticket_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TicketHolder(SoftDeletionModel):
facebook: str = db.Column(db.String)
github: str = db.Column(db.String)
gender: str = db.Column(db.String)
age_group: str = db.Column(db.String)
birth_date: datetime = db.Column(db.DateTime(timezone=True))
pdf_url: str = db.Column(db.String)
ticket_id: int = db.Column(db.Integer, db.ForeignKey('tickets.id', ondelete='CASCADE'))
Expand Down
30 changes: 30 additions & 0 deletions migrations/versions/rev-2020-01-17-18:09:31-6ebafb385765_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""empty message

Revision ID: 6ebafb385765
Revises: 30a490ad1609
Create Date: 2020-01-17 18:09:31.897988

"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = '6ebafb385765'
down_revision = '30a490ad1609'


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('settings', 'secret')
op.add_column('ticket_holders', sa.Column('age_group', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('ticket_holders', 'age_group')
op.add_column('settings', sa.Column('secret', sa.VARCHAR(), autoincrement=False, nullable=True))
# ### end Alembic commands ###