Skip to content

Commit 6938ec4

Browse files
committed
add age_group field in ticket holder model
1 parent 0183671 commit 6938ec4

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

app/api/helpers/static.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,11 @@
423423
'TWD',
424424
'USD'
425425
]
426+
427+
AGE_GROUP_CHOICES = [
428+
'19 or less',
429+
'20 to 29',
430+
'30 to 39',
431+
'40 to 49',
432+
'50 or above'
433+
]

app/api/schema/attendees.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from marshmallow import validate
12
from marshmallow_jsonapi import fields
23
from marshmallow_jsonapi.flask import Relationship
34

45
from app.api.helpers.utilities import dasherize
56
from app.api.schema.base import SoftDeletionSchema
67
from app.api.helpers.validations import validate_complex_fields_json
78
from marshmallow import validates_schema
8-
9+
from app.api.helpers.static import AGE_GROUP_CHOICES
910

1011
class AttendeeSchemaPublic(SoftDeletionSchema):
1112
"""
@@ -48,6 +49,7 @@ def validate_json(self, data, original_data):
4849
facebook = fields.Url(allow_none=True)
4950
github = fields.Url(allow_none=True)
5051
gender = fields.Str(allow_none=True)
52+
age_group = fields.Str(validate=validate.OneOf(choices=AGE_GROUP_CHOICES), allow_none=True)
5153
birth_date = fields.DateTime(allow_none=True)
5254

5355
ticket_id = fields.Str(allow_none=True)

app/models/custom_form.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"facebook": {"include": 0, "require": 0},
5959
"github": {"include": 1, "require": 0},
6060
"gender": {"include": 0, "require": 0},
61+
"age_group": {"include": 0, "require": 0},
6162
}
6263

6364
session_form_str = json.dumps(SESSION_FORM, separators=(',', ':'))

app/models/ticket_holder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class TicketHolder(SoftDeletionModel):
3535
facebook: str = db.Column(db.String)
3636
github: str = db.Column(db.String)
3737
gender: str = db.Column(db.String)
38+
age_group: str = db.Column(db.String)
3839
birth_date: datetime = db.Column(db.DateTime(timezone=True))
3940
pdf_url: str = db.Column(db.String)
4041
ticket_id: int = db.Column(db.Integer, db.ForeignKey('tickets.id', ondelete='CASCADE'))
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""empty message
2+
3+
Revision ID: 6ebafb385765
4+
Revises: 30a490ad1609
5+
Create Date: 2020-01-17 18:09:31.897988
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
import sqlalchemy_utils
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision = '6ebafb385765'
16+
down_revision = '30a490ad1609'
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.drop_column('settings', 'secret')
22+
op.add_column('ticket_holders', sa.Column('age_group', sa.String(), nullable=True))
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column('ticket_holders', 'age_group')
29+
op.add_column('settings', sa.Column('secret', sa.VARCHAR(), autoincrement=False, nullable=True))
30+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)