-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: Endpoint to complete an order in new Orders API #6720
Conversation
app/api/custom/orders.py
Outdated
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.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace before ','
app/api/custom/orders.py
Outdated
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']): |
There was a problem hiding this comment.
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 Report
@@ 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.
|
app/api/custom/orders.py
Outdated
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.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace before ','
app/api/custom/orders.py
Outdated
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.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace before ','
app/api/custom/orders.py
Outdated
@@ -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]: |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
, 422) | ||
else: | ||
return make_response(jsonify(status='Unprocessable Entity', error='Billing information is mandatory ' | ||
'for this order.'), 422) |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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 ' |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.') | ||
, 422) | ||
else: | ||
return make_response(jsonify(status='Unprocessable Entity', error='Billing information incomplete.') |
There was a problem hiding this comment.
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 ','
app/api/custom/orders.py
Outdated
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.') |
There was a problem hiding this comment.
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 ','
app/api/custom/orders.py
Outdated
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) \ |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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.') |
There was a problem hiding this comment.
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 ','
app/api/custom/orders.py
Outdated
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): |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
updated_attendees = data['attendees'] | ||
for updated_attendee in updated_attendees: | ||
for attribute in updated_attendee: | ||
updated_attendee[attribute.replace('-', '_')] = updated_attendee.pop(attribute) |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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) |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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) |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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): |
There was a problem hiding this comment.
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)
@prateekj117 Can this be completed soon? |
@iamareebjamal Sure. Will look into it. |
…nt-server into complete-orders-api
…nto complete-orders-api
app/api/custom/orders.py
Outdated
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() |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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): |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
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, \ |
There was a problem hiding this comment.
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)
app/api/custom/orders.py
Outdated
.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= |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
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): |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
) | ||
) |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
db.session.query(TicketHolder.id).filter_by( | ||
ticket_id=int(ticket_info.id), deleted_at=None | ||
) | ||
db.session.query(TicketHolder.id).filter_by( |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
.filter(Ticket.id.in_(ticket_ids)) | ||
.filter_by(event_id=data['event_id'], deleted_at=None) | ||
.all() | ||
.filter(Ticket.id.in_(ticket_ids)) |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
db.session.commit() | ||
create_pdf_tickets_for_holder(order) | ||
if (order.status == 'completed' or order.status == 'placed') and \ | ||
(order.deleted_at is None): |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
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): |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
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: |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
updated_attendee[attribute.replace('-', '_')] = updated_attendee \ | ||
.pop(attribute) | ||
if get_count(db.session.query(TicketHolder).filter_by(order_id=order_id)) != \ | ||
len(updated_attendees): |
There was a problem hiding this comment.
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
app/api/custom/orders.py
Outdated
order_identifier | ||
), | ||
message="Verification emails for order : {} has been sent successfully" | ||
.format(order_identifier), |
There was a problem hiding this comment.
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
Complexity increasing per file
==============================
- app/api/custom/orders.py 20
Clones added
============
- app/api/custom/orders.py 5
See the complete overview on Codacy |
Fixes #6719