Skip to content

Conversation

@3Dgoo
Copy link
Contributor

@3Dgoo 3Dgoo commented Nov 7, 2024

Description

This change improves the GridFieldExportButton csv export filename.

Currently the export filename is always the following no matter what the model is:

export-$now.csv

With a date format of:

d-m-Y-H-i

The developer cannot modify this. If the cms user is exporting multiple models, they all have the same name, making it hard to differentiate between exports. The time stamp of d-m-Y-H-i is not necessarily ideal.

This PR changes the default csv export file name to:

[classname]-export-[timestamp].csv

With a default date format of:

Y-m-d-H-i-s

The [classname] will automatically be replaced with the model classname. Resulting in the following example filenames:

order-export-2024-11-07-23-15-20.csv
product-export-2024-11-07-23-16-59.csv

The filename and date format can also be easily changed on a per button basis through the code.

Manual testing steps

Go to the CMS security section:

/admin/security/

Press Export CSV.

Observer file name.

Issues

#11458

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@3Dgoo 3Dgoo force-pushed the feature/grid-field-export-improvement branch 6 times, most recently from 3ab48a2 to c7e771a Compare November 7, 2024 13:41
@3Dgoo 3Dgoo closed this Nov 7, 2024
@3Dgoo 3Dgoo force-pushed the feature/grid-field-export-improvement branch from c7e771a to d871f40 Compare November 7, 2024 22:36
@3Dgoo
Copy link
Contributor Author

3Dgoo commented Nov 7, 2024

To do: Make those two variables yml configurable

@3Dgoo 3Dgoo reopened this Nov 7, 2024
@3Dgoo 3Dgoo changed the title Improve GridFieldExportButton csv export filename ENH Improve GridFieldExportButton csv export filename Nov 7, 2024
@3Dgoo 3Dgoo force-pushed the feature/grid-field-export-improvement branch from 400a755 to 6cc9719 Compare November 7, 2024 22:55
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.

1 participant