Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Endpoint to complete an order in new Orders API #6720

Merged
merged 33 commits into from
May 8, 2020

Conversation

prateekj117
Copy link
Member

Fixes #6719

updated_attendees = data['attendees']

if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != len(updated_attendees):
return make_response(jsonify(status='Unprocessable Entity', error='You need to provide info of all attendees.')

Choose a reason for hiding this comment

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

whitespace before ','

return make_response(jsonify(status='Order Unsuccessful', error='Ticket already sold out.'), 409)
attendee_list = []
for ticket in tickets:
for ticket_amount in range(ticket['quantity']):

Choose a reason for hiding this comment

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

Loop control variable 'ticket_amount' not used within the loop body. If this is intended, start the name with an underscore.

@codecov
Copy link

codecov bot commented Jan 4, 2020

Codecov Report

Merging #6720 into development will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #6720   +/-   ##
============================================
  Coverage        60.54%   60.54%           
============================================
  Files              259      259           
  Lines            13649    13649           
============================================
  Hits              8264     8264           
  Misses            5385     5385           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 932b146...932b146. Read the comment docs.

if data['is_billing_enabled']:
if ('company' not in data) or ('address' not in data) or ('city' not in data) or ('zipcode' not in data) \
or ('country' not in data):
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')

Choose a reason for hiding this comment

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

whitespace before ','

if data['is_billing_enabled']:
if ('company' not in data) or ('address' not in data) or ('city' not in data) \
or ('zipcode' not in data) or ('country' not in data):
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')

Choose a reason for hiding this comment

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

whitespace before ','

@@ -122,14 +123,15 @@ def create_order():
.format(tickets_not_found, data['event_id'])), 404)
for ticket_info in ticket_list:
if (ticket_info.quantity - get_count(db.session.query(TicketHolder.id).filter_by(
ticket_id=int(ticket_info.id), deleted_at=None))) < quantity[ticket_info.id]:
ticket_id=int(ticket_info.id), deleted_at=None))) < quantity[ticket_info.id]:

Choose a reason for hiding this comment

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

visually indented line with same indent as next logical line

, 422)
else:
return make_response(jsonify(status='Unprocessable Entity', error='Billing information is mandatory '
'for this order.'), 422)

Choose a reason for hiding this comment

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

line too long (102 > 90 characters)

return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')
, 422)
else:
return make_response(jsonify(status='Unprocessable Entity', error='Billing information is mandatory '

Choose a reason for hiding this comment

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

line too long (113 > 90 characters)

return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')
, 422)
else:
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')

Choose a reason for hiding this comment

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

line too long (116 > 90 characters)
whitespace before ','

if data['is_billing_enabled']:
if ('company' not in data) or ('address' not in data) or ('city' not in data) \
or ('zipcode' not in data) or ('country' not in data):
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.')

Choose a reason for hiding this comment

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

line too long (120 > 90 characters)
whitespace before ','

order.status = 'pending'
if 'is_billing_enabled' in data:
if data['is_billing_enabled']:
if ('company' not in data) or ('address' not in data) or ('city' not in data) \

Choose a reason for hiding this comment

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

line too long (95 > 90 characters)

for attribute in updated_attendee:
updated_attendee[attribute.replace('-', '_')] = updated_attendee.pop(attribute)
if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != len(updated_attendees):
return make_response(jsonify(status='Unprocessable Entity', error='You need to provide info of all attendees.')

Choose a reason for hiding this comment

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

line too long (119 > 90 characters)
whitespace before ','

for updated_attendee in updated_attendees:
for attribute in updated_attendee:
updated_attendee[attribute.replace('-', '_')] = updated_attendee.pop(attribute)
if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != len(updated_attendees):

Choose a reason for hiding this comment

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

line too long (104 > 90 characters)

updated_attendees = data['attendees']
for updated_attendee in updated_attendees:
for attribute in updated_attendee:
updated_attendee[attribute.replace('-', '_')] = updated_attendee.pop(attribute)

Choose a reason for hiding this comment

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

line too long (91 > 90 characters)

return make_response(jsonify(status='Access Forbidden', error='You cannot update an order.'), 403)
if has_access('is_coorganizer', event_id=order.event_id) and 'status' in data:
if data['status'] != 'cancelled':
return make_response(jsonify(status='Access Forbidden', error='You can only cancel an order.'), 403)

Choose a reason for hiding this comment

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

line too long (112 > 90 characters)

order = Order.query.filter_by(id=order_id).first()
order_schema = OrderSchema()
if (not has_access('is_coorganizer', event_id=order.event_id)) and (not current_user.id == order.user_id):
return make_response(jsonify(status='Access Forbidden', error='You cannot update an order.'), 403)

Choose a reason for hiding this comment

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

line too long (106 > 90 characters)

data[attribute.replace('-', '_')] = data.pop(attribute)
order = Order.query.filter_by(id=order_id).first()
order_schema = OrderSchema()
if (not has_access('is_coorganizer', event_id=order.event_id)) and (not current_user.id == order.user_id):

Choose a reason for hiding this comment

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

line too long (110 > 90 characters)

@iamareebjamal
Copy link
Member

@prateekj117 Can this be completed soon?

@prateekj117
Copy link
Member Author

@iamareebjamal Sure. Will look into it.

elif data['status'] == 'cancelled':
order.status = 'cancelled'
db.session.add(order)
attendees = db.session.query(TicketHolder).filter_by(order_id=order_id, deleted_at=None).all()

Choose a reason for hiding this comment

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

line too long (106 > 90 characters)

db.session.add(order)
db.session.commit()
create_pdf_tickets_for_holder(order)
if (order.status == 'completed' or order.status == 'placed') and (order.deleted_at is None):

Choose a reason for hiding this comment

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

line too long (96 > 90 characters)

from app.api.helpers.order import calculate_order_amount, create_pdf_tickets_for_holder
from app.api.helpers.permission_manager import has_access
from app.api.helpers.storage import UPLOAD_PATHS, generate_hash
from app.api.schema.attendees import AttendeeSchema
from app.api.schema.orders import OrderSchema
from app.extensions.limiter import limiter
from app.api.helpers.notification import send_notif_ticket_cancel, send_notif_to_attendees, \

Choose a reason for hiding this comment

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

line too long (93 > 90 characters)

.pop(attribute)
if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != \
len(updated_attendees):
return make_response(jsonify(status='Unprocessable Entity', error=

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

order = Order.query.filter_by(id=order_id).first()
order_schema = OrderSchema()
if (not has_access('is_coorganizer', event_id=order.event_id)) and \
(not current_user.id == order.user_id):

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

)
)

Choose a reason for hiding this comment

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

continuation line missing indentation or outdented

db.session.query(TicketHolder.id).filter_by(
ticket_id=int(ticket_info.id), deleted_at=None
)
db.session.query(TicketHolder.id).filter_by(

Choose a reason for hiding this comment

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

continuation line missing indentation or outdented

.filter(Ticket.id.in_(ticket_ids))
.filter_by(event_id=data['event_id'], deleted_at=None)
.all()
.filter(Ticket.id.in_(ticket_ids))

Choose a reason for hiding this comment

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

continuation line unaligned for hanging indent

db.session.commit()
create_pdf_tickets_for_holder(order)
if (order.status == 'completed' or order.status == 'placed') and \
(order.deleted_at is None):

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

if data['is_billing_enabled']:
if ('company' not in data) or ('address' not in data) or \
('city' not in data) or ('zipcode' not in data) or \
('country' not in data):

Choose a reason for hiding this comment

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

visually indented line with same indent as next logical line

for attendee, updated_attendee in zip(attendees, updated_attendees):
for field in form_fields:
if field.is_required is True and field.field_identifier \
not in updated_attendee:

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

updated_attendee[attribute.replace('-', '_')] = updated_attendee \
.pop(attribute)
if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != \
len(updated_attendees):

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

order_identifier
),
message="Verification emails for order : {} has been sent successfully"
.format(order_identifier),

Choose a reason for hiding this comment

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

continuation line unaligned for hanging indent

@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- app/api/custom/orders.py  20
         

Clones added
============
- app/api/custom/orders.py  5
         

See the complete overview on Codacy

@iamareebjamal iamareebjamal changed the title Endpoint to complete an order in new Orders API feat: Endpoint to complete an order in new Orders API May 8, 2020
@auto-label auto-label bot added the feature label May 8, 2020
@iamareebjamal iamareebjamal merged commit 2a043e3 into fossasia:development May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endpoint for charging and fulfilling an order
4 participants