Skip to content

Commit

Permalink
fix: Fixes the incomplete path of ticket downloads (#5830)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsaicharan1 authored and iamareebjamal committed Apr 22, 2019
1 parent 26bb6c7 commit 977b80a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/api/auth.py
Expand Up @@ -8,6 +8,7 @@
from flask_jwt import current_identity as current_user, jwt_required
from sqlalchemy.orm.exc import NoResultFound
from app.api.helpers.order import create_pdf_tickets_for_holder
from app.api.helpers.storage import generate_hash

from app import get_settings
from app.api.helpers.db import save_to_db, get_count
Expand Down Expand Up @@ -290,8 +291,8 @@ def ticket_attendee_authorized(order_identifier):
except NoResultFound:
return NotFoundError({'source': ''}, 'This ticket is not associated with any order').respond()
if current_user.id == user_id:
file_path = os.path.join('/generated/tickets/{}'.format(UPLOAD_PATHS['pdf']['ticket_attendee']
.format(identifier=order_identifier)), order_identifier + '.pdf')
key = UPLOAD_PATHS['pdf']['ticket_attendee'].format(identifier=order_identifier)
file_path = '../generated/tickets/{}/{}/'.format(key, generate_hash(key)) + order_identifier + '.pdf'
try:
response = make_response(send_file(file_path))
response.headers['Content-Disposition'] = 'attachment; filename=ticket-%s.zip' % order_identifier
Expand Down
2 changes: 1 addition & 1 deletion app/api/helpers/files.py
Expand Up @@ -257,7 +257,7 @@ def make_frontend_url(path, parameters=None):
))


def create_save_pdf(pdf_data, key, dir_path='/static/uploads/pdf/temp/', identifier=get_file_name(), upload_dir='static/media'):
def create_save_pdf(pdf_data, key, dir_path='/static/uploads/pdf/temp/', identifier=get_file_name(), upload_dir='static/media/'):
"""
Create and Saves PDFs from html
:param pdf_data:
Expand Down
4 changes: 2 additions & 2 deletions app/api/helpers/storage.py
Expand Up @@ -130,7 +130,7 @@ def save(self, path):
# MAIN
#########

def upload(uploaded_file, key, upload_dir='static/media', **kwargs):
def upload(uploaded_file, key, upload_dir='static/media/', **kwargs):
"""
Upload handler
"""
Expand All @@ -155,7 +155,7 @@ def upload(uploaded_file, key, upload_dir='static/media', **kwargs):
return upload_local(uploaded_file, key, upload_dir, **kwargs)


def upload_local(uploaded_file, key, upload_dir='static/media', **kwargs):
def upload_local(uploaded_file, key, upload_dir='static/media/', **kwargs):
"""
Uploads file locally. Base dir - static/media/
"""
Expand Down

0 comments on commit 977b80a

Please sign in to comment.