-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add a resend email route for organizers #6163
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
Changes from 3 commits
d71c128
17b2604
639a187
013ed41
94d374f
6d93fc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,16 @@ | |
|
|
||
| from app import get_settings | ||
| from app import limiter | ||
| from app.api.helpers.db import save_to_db, get_count | ||
| from app.api.helpers.db import save_to_db, get_count, safe_query | ||
| from app.api.helpers.errors import ForbiddenError, UnprocessableEntityError, NotFoundError, BadRequestError | ||
| from app.api.helpers.files import make_frontend_url | ||
| from app.api.helpers.mail import send_email_to_attendees | ||
| from app.api.helpers.mail import send_email_with_action, \ | ||
| send_email_confirmation | ||
| from app.api.helpers.notification import send_notification_with_action | ||
| from app.api.helpers.third_party_auth import GoogleOAuth, FbOAuth, TwitterOAuth, InstagramOAuth | ||
| from app.api.helpers.utilities import get_serializer, str_generator | ||
| from app.api.helpers.permission_manager import has_access | ||
| from app.models import db | ||
| from app.models.order import Order | ||
| from app.models.mail import PASSWORD_RESET, PASSWORD_CHANGE, \ | ||
|
|
@@ -363,3 +365,37 @@ def decorated(*args, **kwargs): | |
| def environment_details(): | ||
| envdump = EnvironmentDump(include_config=False) | ||
| return envdump.dump_environment() | ||
|
|
||
|
|
||
| @ticket_blueprint.route('/orders/resend-email', methods=['POST']) | ||
| @limiter.limit( | ||
| '5/minute', key_func=lambda: request.json['data']['order'], error_message='Limit for this action exceeded' | ||
| ) | ||
| @limiter.limit( | ||
| '60/minute', key_func=get_remote_address, error_message='Limit for this action exceeded' | ||
| ) | ||
| def resend_emails(): | ||
| """ | ||
| Sends confirmation email for pending and completed orders on organizer request | ||
| :param order_identifier: | ||
| :return: JSON response if the email was succesfully sent | ||
| """ | ||
| order_identifier = request.json['data']['order'] | ||
| order = safe_query(db, Order, 'identifier', order_identifier, 'identifier') | ||
| if (has_access('is_coorganizer', event_id=order.event_id)): | ||
uds5501 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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]) | ||
|
Member
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. I believe that attachments should be empty for
Member
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. I think placed orders should have tickets too. They are meant to show this ticket when they reach event venue
Member
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.
Agreed 👍 |
||
| return jsonify(status=True, message="Verification emails for order : {} has been sent succesfully". | ||
| format(order_identifier)) | ||
| else: | ||
| return jsonify(status=False, message="Only placed and complete orders are verified") | ||
|
||
| else: | ||
| raise ForbiddenError({'source': ''}, "Co-Organizer Access Required").respond() | ||
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.
Where is limit by 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.
@iamareebjamal modified order to user key.