-
Notifications
You must be signed in to change notification settings - Fork 25
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
Validate XLS rows count before exporting. #612
base: main
Are you sure you want to change the base?
Conversation
e404fcb
to
f318d0b
Compare
f318d0b
to
64da1ed
Compare
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.
Target the branch "v2.5-rc5" please.
CHANGELOG.txt
Outdated
# Prevent an error when reaching 65535 rows during an .XLS file export, which is a hard limit defined by the .XLS | ||
format specs. Display a clear error message prior to the export. |
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.
In the changelog, I try to write sentences with more literal style, something like "The export for .XLS file now displays an error when...".
creme/creme_core/backends/base.py
Outdated
def validate(self, **kwargs): | ||
pass |
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.
Maybe should we add a doc-string with classical "keys" (how to know if we should use "count", "total", "total_count" or "total_number" ?
Or add keywords only arguments with default values like def validate(self, *, total_count=None):
(which would be IDE friendly).
I prefer the second solution.
from ...backends import export_backend_registry | ||
from ...backends.base import ExportBackend | ||
from ...core.exceptions import ConflictError |
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 try to avoid ...
in the code base (I use only .
& ..
).
self.assertIsNone(export_backend_registry.get_backend_class(TestExportBackend.id)) | ||
export_backend_registry._backend_classes[TestExportBackend.id] = TestExportBackend | ||
response = self.assertGET409(self._build_contact_dl_url(doc_type=TestExportBackend.id)) | ||
self.assertContains(response, 'TestExportBackend.validate fail', status_code=409) | ||
export_backend_registry._backend_classes = None |
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.
It would be more straightforward to copy the original _backend_classes
value & restore the value in a finally
block.
A better solution would be to store the registry in an attribute of the class view, to set our own registry in setupClass()
& restore the original one in tearDownClass()
.
64da1ed
to
7213414
Compare
7213414
to
1956d32
Compare
1956d32
to
b2a5418
Compare
…g when you change password for another user).
… latest focused item obviously not reset it on frame update
b2a5418
to
91d82cf
Compare
Prevent an error when reaching 65535 rows during an .XLS file export, which is a hard limit defined by the .XLS format specs.
Display a clear error message prior to the export, returning an http 409 error code.