-
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: Separate ticket for each attendee #7458
Conversation
Codecov Report
@@ Coverage Diff @@
## development #7458 +/- ##
===============================================
- Coverage 65.39% 65.38% -0.01%
===============================================
Files 265 265
Lines 13234 13249 +15
===============================================
+ Hits 8654 8663 +9
- Misses 4580 4586 +6
Continue to review full report at Codecov.
|
app/api/custom/orders.py
Outdated
@order_blueprint.route('/attendees/<int:attendee_id>.pdf') | ||
@jwt_required | ||
def ticket_attendee_pdf(attendee_id): | ||
if current_user: |
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.
No need of this check
app/api/custom/orders.py
Outdated
@jwt_required | ||
def ticket_attendee_pdf(attendee_id): | ||
if current_user: | ||
try: |
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.
Too broad try block
app/api/custom/orders.py
Outdated
except FileNotFoundError: | ||
return NotFoundError({'source': ''}, 'File Not found') | ||
else: | ||
raise ForbiddenError({'source': ''}, 'Unauthorized Access') |
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.
Use early return
app/api/custom/orders.py
Outdated
try: | ||
return send_from_directory('../', file_path, as_attachment=True) | ||
except FileNotFoundError: | ||
return NotFoundError({'source': ''}, 'File Not found') |
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.
This will fail if the file doesn't exist
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.
What shall be the behaviour?
bccccb8
to
a8c1b00
Compare
app/api/custom/orders.py
Outdated
try: | ||
return send_from_directory('../', file_path, as_attachment=True) | ||
except FileNotFoundError: | ||
return NotFoundError({'source': ''}, 'File Not found') |
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.
Should generate the file and send if file not found
a8c1b00
to
ddfc2c7
Compare
app/api/custom/orders.py
Outdated
): | ||
|
||
raise ForbiddenError({'source': ''}, 'Unauthorized Access') | ||
else: |
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.
No need of else
app/api/custom/orders.py
Outdated
if os.path.exists(file_path): | ||
return send_from_directory('../', file_path, as_attachment=True) | ||
else: | ||
create_pdf_tickets_for_holder(ticket_holder.order) | ||
return send_from_directory('../', file_path, as_attachment=True) |
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.
if os.path.exists(file_path): | |
return send_from_directory('../', file_path, as_attachment=True) | |
else: | |
create_pdf_tickets_for_holder(ticket_holder.order) | |
return send_from_directory('../', file_path, as_attachment=True) | |
if not os.path.isfile(file_path): | |
create_pdf_tickets_for_holder(ticket_holder.order) | |
return send_from_directory('../', file_path, as_attachment=True) |
Think of the simplest way to achieve a solution which minimizes duplication
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.
And this change needs to be in other endpoint as well
ddfc2c7
to
9b88b30
Compare
app/api/custom/invoices.py
Outdated
try: | ||
return send_from_directory('../', file_path, as_attachment=True) | ||
except FileNotFoundError: | ||
if not os.path.exists(file_path): |
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.
if not os.path.exists(file_path): | |
if not os.path.isfile(file_path): |
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.
@iamareebjamal - this change should be done everywhere then because i read that isfile will return true only when it points to a file while exist can return true for a directory also.
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.
pdf is a file, not a directory
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.
In my past review, I wrote isfile only
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.
This is my bad apologies.
app/api/custom/orders.py
Outdated
try: | ||
return send_from_directory('../', file_path, as_attachment=True) | ||
except FileNotFoundError: | ||
if not os.path.exists(file_path): |
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.
if not os.path.exists(file_path): | |
if not os.path.isfile(file_path): |
9b88b30
to
a3cf1a1
Compare
Fixes #7397 feat: Ticket pdf path made with attendee identifier
Short description of what this resolves:
Changes proposed in this pull request:
Checklist
development
branch.