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
fix get_import_resource_class refactor #1315
Conversation
Thanks for raising @manelclos. Can you help me figure out why it isn't working? In 2.5.0, we have those methods in class ImportMixin(ImportExportMixinBase):
# ...
def get_resource_class(self):
"""Returns ResourceClass"""
if not self.resource_class:
return modelresource_factory(self.model)
else:
return self.resource_class
def get_import_resource_class(self):
"""
Returns ResourceClass to use for import.
"""
return self.get_resource_class() But now in main they are in mixin super classes: class BaseImportExportMixin:
formats = base_formats.DEFAULT_FORMATS
resource_class = None
def get_resource_class(self):
if not self.resource_class:
return modelresource_factory(self.model)
return self.resource_class
def get_resource_kwargs(self, request, *args, **kwargs):
return {}
class BaseImportMixin(BaseImportExportMixin):
def get_import_resource_class(self):
"""
Returns ResourceClass to use for import.
"""
return super().get_resource_class() However it has caused a regression for you, so are you able to say exactly what is causing the issue? thanks |
Yes, see the commit in the PR. The code was previously calling |
Sorry, I must be missing something. I would just like to understand why it is an issue so that I can fix any other occurrences if there are any. I ran an import with both v2.5.0 and main and they execute the same code (i.e the path I posted above). The current 'main' version calls
Presumably if you have overridden |
Yes, that is exactly it. I use the Sorry for not explaining it better in the first place. |
👍 Thanks for clarifying. I will look into this tomorrow and add some tests for other cases where this will happen. |
I've added some tests and also fixed a couple of other instances of the same issue. I checked the other mixins to confirm that the issue is not duplicated there as well. Also, I attempted to fix the issue of Github actions running twice. |
3033be4
to
5cf693c
Compare
Awesome! I've squashed my commit into yours. This is ready for merge now. |
I set the coveralls decrease threshold for failure to 0.05% to fix the failing checks (details here). |
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.
👍
Problem
This commit produced a regression in one of my applications. The method
get_resource_class
is no longer called on theModelAdmin
.Solution
Use original code,
self
was changed forsuper()
in the refactor.Acceptance Criteria
Local testing only. Will add tests if the change makes sense.