-
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:ticket pdf associated with attendee id #7400
Conversation
This doesn't change anything |
@iamareebjamal - What i understood by the task was to made the ticket-pdf downloadable by attendee_id. |
@iamareebjamal - Currently the api serves the file from |
What difference does it make when it is still downloading an order ticket PDF? The end result is the same. The goal is to have individual PDF of each attendee. This is single PDF for all attendees |
app/api/custom/orders.py
Outdated
) | ||
or order.is_attendee(current_user) | ||
): | ||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | ||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=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.
This is taking order identifier as key, how can it ever be for an attendee. Please understand the issue first
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.
Can I know the path of the attendee ticket pdf?
file_path = ( | ||
'../generated/tickets/{}/{}/'.format(key, generate_hash(key)) | ||
+ order_identifier | ||
+ 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.
How is this attendee? This is an order
@iamareebjamal - The generated folder has all the pdf with order identifer, I might be wrong but here attatching the screenshot which causes confusion |
Exactly. That's the issue. Please read the issue again, carefully this time |
Will this path work good? - |
order ID first and then attendee ID |
@iamareebjamal - tthis looks good? |
Codecov Report
@@ Coverage Diff @@
## development #7400 +/- ##
===============================================
+ Coverage 64.59% 64.81% +0.22%
===============================================
Files 262 262
Lines 13246 13220 -26
===============================================
+ Hits 8556 8569 +13
+ Misses 4690 4651 -39
Continue to review full report at Codecov.
|
app/api/custom/orders.py
Outdated
@@ -87,7 +87,9 @@ def resend_emails(): | |||
if order.status == 'completed' or order.status == 'placed': | |||
# fetch tickets attachment | |||
order_identifier = order.identifier | |||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | |||
key = UPLOAD_PATHS['pdf']['tickets_all'].format( | |||
identifier=order_identifier, attendee_identifier=str(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.
order.user_id is not attendee
app/api/custom/orders.py
Outdated
@@ -329,7 +331,9 @@ def complete_order(order_id): | |||
): | |||
order_identifier = order.identifier | |||
|
|||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | |||
key = UPLOAD_PATHS['pdf']['tickets_all'].format( | |||
identifier=order_identifier, attendee_identifier=str(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.
order.user_id is not attendee
app/api/helpers/order.py
Outdated
@@ -73,6 +73,7 @@ def create_pdf_tickets_for_holder(order): | |||
UPLOAD_PATHS['pdf']['tickets_all'], | |||
dir_path='/static/uploads/pdf/tickets/', | |||
identifier=order.identifier, | |||
extra_identifiers={'attendee_identifier': str(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.
order.user_id is not attendee
app/api/helpers/order.py
Outdated
@@ -88,6 +89,7 @@ def create_pdf_tickets_for_holder(order): | |||
UPLOAD_PATHS['pdf']['tickets_all'], | |||
dir_path='/static/uploads/pdf/tickets/', | |||
identifier=order.identifier, | |||
extra_identifiers={'attendee_identifier': str(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.
order.user_id is not attendee
app/api/orders.py
Outdated
@@ -121,7 +121,9 @@ def on_order_completed(order): | |||
# fetch tickets attachment | |||
order_identifier = order.identifier | |||
|
|||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | |||
key = UPLOAD_PATHS['pdf']['tickets_all'].format( | |||
identifier=order_identifier, attendee_identifier=str(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.
order.user_id is not attendee
app/api/orders.py
Outdated
@@ -525,7 +527,9 @@ def after_update_object(self, order, data, view_kwargs): | |||
# Send email to attendees with invoices and tickets attached | |||
order_identifier = order.identifier | |||
|
|||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | |||
key = UPLOAD_PATHS['pdf']['tickets_all'].format( | |||
identifier=order_identifier, attendee_identifier=str(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.
order.user_id is not attendee
@iamareebjamal - Done! |
if current_user: | ||
try: | ||
order = Order.query.filter_by(identifier=order_identifier).first() | ||
order = Order.query.filter_by(user_id=attendee_id).first() |
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.
Not really. As I already told you, Order.user_id != Attendee.id
Attendee == TicketHolder
Attendee != Order.user
You need to understand what is Ticket Buyer and what is an attendee or a ticket holder. Then understand why the issue was raised and what is the actual problem. We discussed this in meeting as well. And then think if the changes actually solve the problem
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 fault, I missed to change this. Will update the PR. Does the rest of the PR seems OK or not? @iamareebjamal
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.
Ticket Buyer is the person who is ordering the ticket
Ticket Holder = Can be ticket buyer or some other person
Issue was raised because on frontend download tickets, a random ticket was downloaded - to solve this we will have to save ticket attendee wise.
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.
I don't understand why you removed the code. Why was it necessary. How is it compatible with previous behaviour?
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.
I removed the code as the ticket pdf is now created and saved attendee wise so the ticket path needs to be changed for every ticket holder. The same common code is now moved to create pdf function.
Previously the ticket pdf path seems to be constant using order_identifier but now it needs to be ticketholder wise @iamareebjamal
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.
It still wasn't constant. It changed with order. Now it changes with ticket holder. I understand that. But you removed the code of sending the attachments and other things. We need that. It should be adapted to recent changes
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.
I have a question, shall the invoice path and ticket path then be sent as attatchement to the function as earlier? If yes then I have to loop for the ticket path from everywhere where the function is used or should I add a parameter attachment in function and append that function parameter value to the invoice, ticket_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.
Also, I think that send_Email function should not have this code as it's a generic function? What are your views
for holder in order.ticket_holders:
To be completed and merged after #7412 |
Fixes #7397 ticket pdf associated with attendee id
Short description of what this resolves:
Changes proposed in this pull request:
Checklist
development
branch.