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

Default format selections on export action #1389

Merged

Conversation

shimakaze-git
Copy link

@shimakaze-git shimakaze-git commented Feb 8, 2022

Problem

#1373

This is the PR for this issue.

When there is only one formats like the code below,the format on the Export action does not display ---.
By default, you can select the contents specified in formats.

from import_export.admin import ExportActionModelAdmin
from import_export.formats import base_formats

class CategoryAdmin(ExportActionModelAdmin):

    formats = [base_formats.CSV]

Solution

In the ExportActionMixin constructor of import_export/admin.py, if the size of formats exceeds 1, add --- to choices.

Acceptance Criteria

  • After modifying CategoryAdmin in tests/core/admin.py as follows, I confirmed that the format of the Export action in the admin screen is csv.

  • I added a unit tests.

django-import-export-admin

@coveralls
Copy link

coveralls commented Feb 8, 2022

Coverage Status

Coverage increased (+0.001%) to 98.074% when pulling 9927b8c on shimakaze-git:main into 0d4340f on django-import-export:main.

@matthewhegarty
Copy link
Contributor

Looks good. Thanks for adding this. I think we would add this into our forthcoming v3 release.

Please could you add unit tests to prove the contents of the choices list. For example, you could create a test class to verify the choices list passed into export_action_form_factory(). I don't know your level of experience but happy to help if required.

@shimakaze-git
Copy link
Author

@matthewhegarty

ok! I added a unit tests.
Is this okay?

@matthewhegarty
Copy link
Contributor

This looks great - thanks for adding the tests.

Would you be able to merge the release-3-x branch into this, and then squash commits? There should be a single commit with the log message:

Customize default format selections on export action (#1389)

Thanks so much for adding this.

@matthewhegarty matthewhegarty changed the base branch from main to release-3-x February 9, 2022 16:13
@shimakaze-git
Copy link
Author

@matthewhegarty

I've merged the release-3-x branch into the main branch.

@matthewhegarty
Copy link
Contributor

Thanks @shimakaze-git - I've updated the changelog. I'm going to squash the commits and then merge.

@matthewhegarty matthewhegarty merged commit e168c6a into django-import-export:release-3-x Feb 9, 2022
@shimakaze-git
Copy link
Author

@matthewhegarty Thanks!

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.

None yet

3 participants