Skip to content
4 changes: 2 additions & 2 deletions app/api/schema/ticket_fees.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Meta:
inflect = dasherize

id = fields.Integer(dump_only=True)
currency = fields.Str(validate=validate.OneOf(choices=PAYMENT_CURRENCY_CHOICES), allow_none=True)
country = fields.String(allow_none=True)
currency = fields.Str(validate=validate.OneOf(choices=PAYMENT_CURRENCY_CHOICES), allow_none=False)
country = fields.String(allow_none=False)
service_fee = fields.Float(validate=lambda n: n >= 0, allow_none=True)
maximum_fee = fields.Float(validate=lambda n: n >= 0, allow_none=True)
1 change: 0 additions & 1 deletion app/api/ticket_fees.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from flask_rest_jsonapi import ResourceDetail, ResourceList

from app import db
from app.api.bootstrap import api
from app.api.schema.ticket_fees import TicketFeesSchema
Expand Down
4 changes: 2 additions & 2 deletions app/models/ticket_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class TicketFees(db.Model):
__tablename__ = 'ticket_fees'

id = db.Column(db.Integer, primary_key=True)
currency = db.Column(db.String)
country = db.Column(db.String)
currency = db.Column(db.String, unique=True)
country = db.Column(db.String, unique=True)
service_fee = db.Column(db.Float)
maximum_fee = db.Column(db.Float)

Expand Down
30 changes: 30 additions & 0 deletions migrations/versions/cb4ccda76a2b_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""empty message
Revision ID: cb4ccda76a2b
Revises: 0e80c49a6e28
Create Date: 2019-06-03 22:57:01.500527
"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = 'cb4ccda76a2b'
down_revision = '0e80c49a6e28'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uds5501 change down_revision and revises to Revision ID of migration in my latest merged PR



def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(None, 'ticket_fees', ['country'])
op.create_unique_constraint(None, 'ticket_fees', ['currency'])
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'ticket_fees', type_='unique')
op.drop_constraint(None, 'ticket_fees', type_='unique')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions tests/hook_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,7 @@ def ticket_fees_post(transaction):
"""
with stash['app'].app_context():
ticket_fees = TicketFeesFactory()
ticket_fees.country = 'US'
db.session.add(ticket_fees)
db.session.commit()

Expand Down