Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fcf6de4
enh: Addition of billing info related fields
kushthedude Sep 15, 2019
f0641e0
Update rev-2019-09-15-08:29:32-d1c2b8711223_.py
kushthedude Sep 16, 2019
936264a
Update rev-2019-09-15-08:29:32-d1c2b8711223_.py
kushthedude Sep 16, 2019
68ed374
Merge branch 'development' into fields
kushthedude Sep 24, 2019
2f50044
Adding another function
kushthedude Sep 24, 2019
249d067
Update orders.py
kushthedude Sep 24, 2019
2b65543
Merge branch 'development' into fields
kushthedude Sep 25, 2019
ae86e49
Update orders.py
kushthedude Sep 25, 2019
5848ae5
Merge branch 'development' into fields
kushthedude Sep 27, 2019
12b5842
Merge branch 'development' into fields
kushthedude Sep 30, 2019
a4216ad
Merge branch 'development' into fields
iamareebjamal Sep 30, 2019
2d9c08d
Merge branch 'development' into fields
iamareebjamal Oct 1, 2019
9d31d76
Merge branch 'development' into fields
kushthedude Oct 1, 2019
d6cfe4f
Merge branch 'development' into fields
kushthedude Oct 2, 2019
8ddaa3c
Merge branch 'development' into fields
kushthedude Oct 3, 2019
61d2671
Merge branch 'development' into fields
kushthedude Oct 12, 2019
67beb26
Merging the functions
kushthedude Oct 12, 2019
124f19f
Merge branch 'development' into fields
kushthedude Oct 13, 2019
38933b8
Addition of `server_default`
kushthedude Oct 15, 2019
df8798d
Removing unused arg
kushthedude Oct 18, 2019
2db0673
Merge branch 'development' into fields
kushthedude Oct 18, 2019
687bd2a
Merge branch 'development' into fields
kushthedude Nov 19, 2019
306cdc3
Updating migration version
kushthedude Nov 23, 2019
cb7265d
Final fixes
kushthedude Nov 24, 2019
873980c
Merge branch 'development' into fields
kushthedude Nov 24, 2019
c74d885
Hound violation
kushthedude Nov 25, 2019
f07085a
Syntax enhancement
kushthedude Nov 25, 2019
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
11 changes: 4 additions & 7 deletions app/api/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ def is_payment_valid(order, mode):
return (order.paid_via == 'paypal') and order.transaction_id


def check_billing_info(data):
if data.get('amount') and data.get('amount') > 0 and not data.get('is_billing_enabled'):
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information is mandatory for paid orders")
if data.get('is_billing_enabled') and not (data.get('company') and data.get('address') and data.get('city') and
data.get('zipcode') and data.get('country')):
def check_billing_info(data, order):
if order.event.is_billing_info_mandatory and data.get('amount') and data.get('amount') > 0 and not (data.get('company')
and data.get('address') and data.get('city') and data.get('zipcode') and data.get('country')):
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information incomplete")

Expand Down Expand Up @@ -320,7 +317,7 @@ def before_update_object(self, order, data, view_kwargs):
:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
check_billing_info(data)
check_billing_info(data, order)
if (not has_access('is_coorganizer', event_id=order.event_id)) and (not current_user.id == order.user_id):
raise ForbiddenException({'pointer': ''}, "Access Forbidden")

Expand Down
2 changes: 1 addition & 1 deletion app/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Event(SoftDeletionModel):
payment_currency = db.Column(db.String)
paypal_email = db.Column(db.String)
is_tax_enabled = db.Column(db.Boolean, default=False)
is_billing_info_mandatory = db.Column(db.Boolean, default=False)
is_billing_info_mandatory = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_paypal = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_stripe = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_cheque = db.Column(db.Boolean, default=False, nullable=False)
Expand Down
2 changes: 1 addition & 1 deletion app/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Order(SoftDeletionModel):
transaction_id = db.Column(db.String)
paid_via = db.Column(db.String)
payment_mode = db.Column(db.String)
is_billing_enabled = db.Column(db.Boolean)
is_billing_enabled = db.Column(db.Boolean, nullable=False, default=False)
brand = db.Column(db.String)
exp_month = db.Column(db.Integer)
exp_year = db.Column(db.Integer)
Expand Down
39 changes: 39 additions & 0 deletions migrations/versions/rev-2019-09-15-08:29:32-d1c2b8711223_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""empty message
Revision ID: d1c2b8711223
Revises: 7c32ba647a18
Create Date: 2019-09-15 08:29:32.373041
"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = 'd1c2b8711223'
down_revision = '7c32ba647a18'


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('events', 'is_billing_info_mandatory',
existing_type=sa.BOOLEAN(),
nullable=False)
op.alter_column('orders', 'is_billing_enabled',
existing_type=sa.BOOLEAN(),
server_default='False',
nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('orders', 'is_billing_enabled',
existing_type=sa.BOOLEAN(),
nullable=True)
op.alter_column('events', 'is_billing_info_mandatory',
existing_type=sa.BOOLEAN(),
nullable=True)
# ### end Alembic commands ###