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

Update method reference in get_actions #1681

Merged
merged 6 commits into from Nov 11, 2023
Merged

Update method reference in get_actions #1681

merged 6 commits into from Nov 11, 2023

Conversation

KommuSoft
Copy link
Contributor

@KommuSoft KommuSoft commented Nov 9, 2023

The method reference in get_actions within import_export/admin.py was updated from using ExportActionMixin.export_admin_action to type(self).export_admin_action. This change ensures that the function call always refers to the current instance's class method. This is particularly important in situations where the class has been inherited and the method overridden. Fixing #1680.

Problem

Subclassing .export_admin_action did not work: the old method was still triggered.

Solution

Allow subclassing .export_admin_action by using type(self) instead of ExportActionMixin.

The method reference in get_actions within import_export/admin.py was updated from using ExportActionMixin.export_admin_action to type(self).export_admin_action. This change ensures that the function call always refers to the current instance's class method. This is particularly important in situations where the class has been inherited and the method overridden.
@matthewhegarty
Copy link
Contributor

Hi Willem, thanks for submitting. Is it possible you could provide a test case which proves the issue is fixed? Also feel free to add an entry to CHANGELOG.rst.

@coveralls
Copy link

coveralls commented Nov 9, 2023

Coverage Status

coverage: 100.0%. remained the same
when pulling 1f5712a on hapytex:issues/issue-1680
into 6319211 on django-import-export:main.

@KommuSoft
Copy link
Contributor Author

Hi Willem, thanks for submitting. Is it possible you could provide a test case which proves the issue is fixed? Also feel free to add an entry to CHANGELOG.rst.

Yes. I've added a test, if the change in the import_export/admin.py is reverted, the test fails, since then it will not trigger the subclassed method.

With the change, the test succeeds.

@matthewhegarty
Copy link
Contributor

Looks good, thanks for taking the time to submit this patch.

@matthewhegarty matthewhegarty merged commit d81869d into django-import-export:main Nov 11, 2023
11 checks passed
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