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

Record import export #503

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Record import export #503

wants to merge 4 commits into from

Conversation

georgehelman
Copy link
Contributor

No description provided.

Comment on lines 233 to 234
disabled={!!batch?.generate_summary_errors?.batch}
title={batch?.generate_summary_errors?.batch?.join(' ') ?? ''}
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

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."
Copy link
Contributor

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.

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"
Copy link
Contributor

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.

@@ -186,7 +186,6 @@ function GenerationPage() {
</Button>
<Button
onClick={() => generateRecordsSpreadsheet()}
disabled={!!data?.generate_summary_errors?.batch}
title={data?.generate_summary_errors?.batch?.join(' ') ?? ''}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed as well. Otherwise, it will show errors for the account summary generation while hovering over the button

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

Successfully merging this pull request may close these issues.

3 participants