-
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,36 +32,36 @@ | |
ticket_blueprint = Blueprint('ticket_blueprint', __name__, url_prefix='/v1/tickets') | ||
|
||
|
||
@ticket_blueprint.route('/<string:order_identifier>') | ||
@order_blueprint.route('/<string:order_identifier>/tickets-pdf') | ||
@ticket_blueprint.route('/<int:attendee_id>') | ||
@order_blueprint.route('/<int:attendee_id>/tickets-pdf') | ||
@jwt_required | ||
def ticket_attendee_authorized(order_identifier): | ||
def ticket_attendee_authorized(attendee_id): | ||
if current_user: | ||
try: | ||
order = Order.query.filter_by(identifier=order_identifier).first() | ||
order = Order.query.filter_by(user_id=attendee_id).first() | ||
except NoResultFound: | ||
raise NotFoundError( | ||
{'source': ''}, 'This ticket is not associated with any order' | ||
) | ||
raise NotFoundError({'source': ''}, 'No Ticket found for attendee') | ||
if ( | ||
has_access( | ||
'is_coorganizer_or_user_itself', | ||
event_id=order.event_id, | ||
user_id=order.user_id, | ||
user_id=attendee_id, | ||
) | ||
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, attendee_identifier=attendee_id | ||
) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. How is this attendee? This is an order |
||
+ '.pdf' | ||
) | ||
try: | ||
return return_file('ticket', file_path, order_identifier) | ||
return return_file('ticket', file_path, order.identifier) | ||
except FileNotFoundError: | ||
create_pdf_tickets_for_holder(order) | ||
return return_file('ticket', file_path, order_identifier) | ||
return return_file('ticket', file_path, order.identifier) | ||
else: | ||
raise ForbiddenError({'source': ''}, 'Unauthorized Access') | ||
else: | ||
|
@@ -85,27 +85,9 @@ def resend_emails(): | |
order = safe_query(Order, 'identifier', order_identifier, 'identifier') | ||
if has_access('is_coorganizer', event_id=order.event_id): | ||
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) | ||
ticket_path = ( | ||
'generated/tickets/{}/{}/'.format(key, generate_hash(key)) | ||
+ order_identifier | ||
+ '.pdf' | ||
) | ||
key = UPLOAD_PATHS['pdf']['order'].format(identifier=order_identifier) | ||
invoice_path = ( | ||
'generated/invoices/{}/{}/'.format(key, generate_hash(key)) | ||
+ order_identifier | ||
+ '.pdf' | ||
) | ||
|
||
# send email. | ||
send_email_to_attendees( | ||
order=order, | ||
purchaser_id=current_user.id, | ||
attachments=[ticket_path, invoice_path], | ||
) | ||
send_email_to_attendees(order=order, purchaser_id=current_user.id) | ||
return jsonify( | ||
status=True, | ||
message="Verification emails for order : {} has been sent successfully".format( | ||
|
@@ -327,28 +309,7 @@ def complete_order(order_id): | |
if (order.status == 'completed' or order.status == 'placed') and ( | ||
order.deleted_at is None | ||
): | ||
order_identifier = order.identifier | ||
|
||
key = UPLOAD_PATHS['pdf']['tickets_all'].format(identifier=order_identifier) | ||
ticket_path = ( | ||
'generated/tickets/{}/{}/'.format(key, generate_hash(key)) | ||
+ order_identifier | ||
+ '.pdf' | ||
) | ||
|
||
key = UPLOAD_PATHS['pdf']['order'].format(identifier=order_identifier) | ||
invoice_path = ( | ||
'generated/invoices/{}/{}/'.format(key, generate_hash(key)) | ||
+ order_identifier | ||
+ '.pdf' | ||
) | ||
|
||
# send email and notifications. | ||
send_email_to_attendees( | ||
order=order, | ||
purchaser_id=current_user.id, | ||
attachments=[ticket_path, invoice_path], | ||
) | ||
send_email_to_attendees(order=order, purchaser_id=current_user.id) | ||
|
||
send_notif_to_attendees(order, current_user.id) | ||
order_url = make_frontend_url(path=f'/orders/{order.identifier}') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
@iamareebjamal