-
Notifications
You must be signed in to change notification settings - Fork 16
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
Record import export #503
Record import export #503
Conversation
56cc4a4
to
5e52f46
Compare
5e52f46
to
c42211b
Compare
src/features/ExistingPetitions.jsx
Outdated
disabled={!!batch?.generate_summary_errors?.batch} | ||
title={batch?.generate_summary_errors?.batch?.join(' ') ?? ''} |
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 think we should only disable if it's impossible to generate the record summary spreadsheet. As far as I'm aware, that's not the case so I think you can remove this.
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.
Okay, I got rid of it.
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
]; | ||
const MAX_FILES = 1; | ||
const MAX_FILE_SIZE = 30000; |
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.
Do we really want this max file size? I can't tell if it's in bytes, KB or MB, so it may be pretty small.
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 got rid of it.
], | ||
) | ||
def import_spreadsheet(self, request): | ||
files = request.data.getlist("files") |
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.
Consider try/except block to gracefully handle errors. Also do you need to make the transaction atomic?
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 added an atomic block to the import_data method of the resource
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.
So does it handle it gracefully if user imports spreadsheet with unexpected format? Or is try/except needed?
dear_petition/petition/resources.py
Outdated
self.change_worksheet(sheet_name=title) | ||
|
||
def append(self, values, fields, is_header=False, num_indent=0, bold=False, color=None,): | ||
assert len(values) == len(fields), "The values and fields passed to append should match." |
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.
Better to raise error. I believe asserts can be disabled through configuration.
dear_petition/petition/resources.py
Outdated
def export(self, batch_object=None, *args, **kwargs): | ||
# Initialize a new dataset with headers | ||
assert isinstance(batch_object,models.Batch), "Queryset must be a Batch object" |
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.
Better to raise error. I believe asserts can be disabled through configuration.
No description provided.