Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
22 changes: 13 additions & 9 deletions app/api/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ 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'):
def is_billing_info(data, order):
Copy link
Member

Choose a reason for hiding this comment

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

is_billing_info?

Copy link
Member Author

Choose a reason for hiding this comment

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

If is_billing_info needed for all orders or not.

if order.event.is_billing_info_mandatory and 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')):
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information incomplete")
"Billing information is mandatory for this order.")
Copy link
Member

Choose a reason for hiding this comment

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

Remove period from the end


def check_billing_info(data, order):
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')):

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Member

Choose a reason for hiding this comment

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

Why? Is it relevant to this issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

This are the mandatory checks for billing details hence I have merged the two as suggested .

Copy link
Member

Choose a reason for hiding this comment

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

@kushthedude Ok. Change PR title.

Copy link
Member

Choose a reason for hiding this comment

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

Revert this please. The previous format was according to PEP8

raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information is incomplete.")

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent
indentation contains mixed spaces and tabs

Copy link
Member

Choose a reason for hiding this comment

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

Remove the period from the end



class OrdersListPost(ResourceList):
Expand Down Expand Up @@ -319,8 +322,9 @@ def before_update_object(self, order, data, view_kwargs):
:param view_kwargs:
:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
check_billing_info(data)
if data.get('amount') or data.get('is_billing_enabled') or order.event.is_billing_info_mandatory:
Copy link
Member

Choose a reason for hiding this comment

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

There's a problem, this will require billing info on any paid order, whereas it is explicitly stated in the issue to make it optional unless is_billing_info_mandatory is True.

Skipping this PR for now, will add in minor version

Copy link
Member Author

Choose a reason for hiding this comment

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

Merging it after release would be better I guess too.

is_billing_info(data, order)
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 ###