Skip to content
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

Receipt files missing from data export #6331

Closed
tomasr8 opened this issue May 8, 2024 · 1 comment · Fixed by #6338
Closed

Receipt files missing from data export #6331

tomasr8 opened this issue May 8, 2024 · 1 comment · Fixed by #6338
Assignees
Labels

Comments

@tomasr8
Copy link
Member

tomasr8 commented May 8, 2024

When using the data export feature, registration documents (receipts, etc..) are currently not included

We'd probably just need to extend this function:

def get_registration_files(user):
"""Get all files uploaded in registration file fields."""
return (RegistrationData.query
.join(Registration)
.filter(Registration.user == user,
RegistrationData.filename.isnot(None))
.all())

..and add a new case to the storage path builder:

def build_storage_path(file):
"""Build a path under which a given file be stored in the exported zip file.
The path includes both the id (to ensure uniqueness) and the title/name for
easy navigation.
"""
if isinstance(file, RegistrationData):
event = file.registration.event
prefix = 'registrations'
path = f'{event.id}_{event.title}'
elif isinstance(file, AttachmentFile):
prefix = 'attachments'
path = ''
elif isinstance(file, AbstractFile):
event = file.abstract.event
prefix = 'abstracts'
path = f'{event.id}_{event.title}/{file.abstract.id}_{file.abstract.title}'
elif isinstance(file, PaperFile):
event = file._contribution.event
prefix = 'papers'
path = f'{event.id}_{event.title}/{file._contribution.id}_{file.paper.title}'
else:
editable = file.revision.editable
event = editable.contribution.event
prefix = f'editables/{editable.type.name}'
path = f'{event.id}_{event.title}/{editable.id}_{editable.contribution.title}'
path = secure_path(path)
filename = build_filename(file)
return str(Path() / prefix / path / filename)

@tomasr8 tomasr8 added the bug label May 8, 2024
@ThiefMaster
Copy link
Member

I'd separate it into get_registration_documents. Also make sure to not include files which aren't is_published (those may even be tests a manager did, so I'd treat them just like manager-only fields and exclude them)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants