def order_invoices(order_identifier): if current_user: try: order = Order.query.filter_by(identifier=order_identifier).first() except NoResultFound: return NotFoundError({ 'source': '' }, 'Order Invoice not found').respond() if current_user.can_download_tickets(order): key = UPLOAD_PATHS['pdf']['order'].format( identifier=order_identifier) file_path = ('../generated/invoices/{}/{}/'.format( key, generate_hash(key)) + order_identifier + '.pdf') try: return return_file('invoice', file_path, order_identifier) except FileNotFoundError: create_pdf_tickets_for_holder(order) return return_file('invoice', file_path, order_identifier) else: return ForbiddenError({ 'source': '' }, 'Unauthorized Access').respond() else: return ForbiddenError({ 'source': '' }, 'Authentication Required to access Invoice').respond()
def ticket_attendee_authorized(order_identifier): if current_user: try: order = Order.query.filter_by(identifier=order_identifier).first() except NoResultFound: return NotFoundError({ 'source': '' }, 'This ticket is not associated with any order').respond() if current_user.can_download_tickets(order): key = UPLOAD_PATHS['pdf']['tickets_all'].format( identifier=order_identifier) file_path = ( '../generated/tickets/{}/{}/'.format(key, generate_hash(key)) + order_identifier + '.pdf') try: return return_file('ticket', file_path, order_identifier) except FileNotFoundError: create_pdf_tickets_for_holder(order) return return_file('ticket', file_path, order_identifier) else: return ForbiddenError({ 'source': '' }, 'Unauthorized Access').respond() else: return ForbiddenError({ 'source': '' }, 'Authentication Required to access ticket').respond()