Skip to content

Fixes #17443: Adds ExportTemplate.file_name field #18911

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

Merged
merged 3 commits into from
Mar 20, 2025

Conversation

jnovinger
Copy link
Member

Fixes: #17443

  • adds ExportTemplate.file_name field
  • adds logic to ExportTemplate.render_to_response() to use file_name if populated
  • adds field to required places (API serializers, forms, filterset, etc.)
  • updates tests for new field
  • adds a new utils, filename_from_model, to standardize generating export filenames for models
  • adds tests for new util func

@jnovinger jnovinger requested review from a team and bctiemann and removed request for a team March 14, 2025 19:39
@jeremystretch jeremystretch requested review from jeremystretch and removed request for bctiemann March 19, 2025 12:49
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Thanks @jnovinger! Just had some very minor cleanup suggestions.

@@ -155,6 +155,10 @@ class ExportTemplateBulkEditForm(BulkEditForm):
max_length=50,
required=False
)
file_name = forms.CharField(
Copy link
Member

Choose a reason for hiding this comment

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

We should add file_name to nullable_fields below as well, to enable the "set null" option in the bulk edit form.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any guidance on when a field should or should not be included in nullable_fields?

Copy link
Member

Choose a reason for hiding this comment

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

Ideally any optional, non-M2M field on the model should be nullable, I think. There are probably some exceptions to that rule but none come to mind offhand.

@jnovinger
Copy link
Member Author

@jeremystretch , rather than adding another schema migration, I edited the existing migration to reflect the new max length for ExportTemplate.file_name. Apologies for making testing any more complicated. If you'd prefer it the other way, just let me know.

@jnovinger jnovinger requested a review from jeremystretch March 19, 2025 17:47
@jnovinger
Copy link
Member Author

jnovinger commented Mar 19, 2025

Ah, looks like there are some conflicting migrations from a recent merge to feature. Fixing that up now. Fixed.

- Adds `file_name` to `ExportTemplateBulkEditForm.nullable_fields`
- Shortens max length of `ExportTemplate.file_name` to 200 chars
- Adds tests for `ExportTemplateFilterSet.file_extension`
@jnovinger jnovinger force-pushed the 17443-exporttemplate-filename-field branch from b78824e to 76bf80a Compare March 19, 2025 17:57
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Thanks @jnovinger!

@jeremystretch jeremystretch merged commit 80440fd into feature Mar 20, 2025
6 checks passed
@jeremystretch jeremystretch deleted the 17443-exporttemplate-filename-field branch March 20, 2025 13:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants