-
Notifications
You must be signed in to change notification settings - Fork 58
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
[change] Removed support for restoring FirmwareBuild objects #173
[change] Removed support for restoring FirmwareBuild objects #173
Conversation
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.
It was not asked in #170 to remove reversion support for everything in firmware upgrader.
It was asked to remove support for FirmwareBuild objects, i.e Build objects.
Start from updating BuildAdmin
class BuildAdmin(BaseVersionAdmin): |
Reference django-reversion documentation to learn about VersionAdmin: https://django-reversion.readthedocs.io/en/stable/admin.html
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.
It was not asked in #170 to remove reversion support for everything in firmware upgrader.
It was asked to remove support for FirmwareBuild objects, i.e Build objects.
Start from updating BuildAdmin
class BuildAdmin(BaseVersionAdmin): Reference django-reversion documentation to learn about VersionAdmin: https://django-reversion.readthedocs.io/en/stable/admin.html
Gagan is correct. There's also a conflict with the latest master, please rebase on the latest master.
Replaced Version Admin with ModelAdmin as a superclass in admin.py/BuildAdmin, Also removed the reversion_register function which was meant to register the model associated with BuildAdmin (Firmware Build), for recovery option. Fixes openwisp#170
In admin.py, replaced BaseVersionAdmin from BaseAdmin, as a superclass for 'BuildAdmin', as it is no longer desired to add a recovery option for firmware builds and images Fixes openwisp#170
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.
The tests are failing due to following code
reversion.register(model=DeviceFirmware, follow=['device', 'image']) |
It is required to remove image
from the list in above code.
openwisp_firmware_upgrader/admin.py
Outdated
'build', | ||
) | ||
return super().reversion_register(model, **kwargs) | ||
# removed overriding reversion_register as recovery operation is no longer desired |
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.
You can also remove this comment
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.
@AbhigyaShridhar can you proceed with this?
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.
Hi @pandafy , I made the requested changes. The branch was already up to date with master though. Please let me know if something else needs to be done.
Apologies for the late reply, was facing some health issues in the past week.
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.
Hi @pandafy , I made the requested changes. The branch was already up to date with master though. Please let me know if something else needs to be done.
Thank you for the update!
Apologies for the late reply, was facing some health issues in the past week.
No worries, get well soon! 😊
@@ -90,7 +90,7 @@ class CategoryFilter(MultitenantOrgFilter): | |||
|
|||
|
|||
@admin.register(load_model('Build')) | |||
class BuildAdmin(BaseVersionAdmin): | |||
class BuildAdmin(BaseAdmin): |
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.
We don't want to remove reversion for Build model, but for FirmwareImage model.
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.
Correction: After discussion with @nemesisdesign, we came to the conclusion that we want to remove Build
model from reversion. Hence, the above change is correct.
To fix tests, it is required to remove following snippet of code as well
openwisp-firmware-upgrader/openwisp_firmware_upgrader/admin.py
Lines 53 to 56 in 91fe0b2
def reversion_register(self, model, **kwargs): | |
if model == Category: | |
kwargs['follow'] = (*kwargs['follow'], 'build_set') | |
return super().reversion_register(model, **kwargs) |
Replaced BaseVersionAdmin from BaseAdmin as a super class in BuildAdmin and removed reversion support from BuildAdmin, thus no longer allowing recovery of deleted Firmware Builds. Also removed the overriding of the 'reversion_register' method in CategoryAdmin to avoid failure of tests. Fixes openwisp#170
@@ -109,7 +109,7 @@ def test_upgrade_selected_error(self): | |||
def test_upgrade_intermediate_page_related(self): | |||
self._login() | |||
env = self._create_upgrade_env() | |||
with self.assertNumQueries(17): | |||
with self.assertNumQueries(15): |
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.
The number of queries changes because we removed VersionAdmin
from BuildAdmin
class
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.
@AbhigyaShridhar can you rebase this PR on the latest master branch?
openwisp_firmware_upgrader/admin.py
Outdated
'build', | ||
) | ||
return super().reversion_register(model, **kwargs) | ||
# removed overriding reversion_register as recovery operation is no longer desired |
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.
@AbhigyaShridhar can you proceed with this?
…#173 Removed an extra comment, also did some minor formating to make sure all checks in ./run-qa-checks work fixes openwisp#173
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.
LGTM 👍🏼 ! Thank you for contributing @AbhigyaShridhar
Deferring merge to @nemesisdesign 😄
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.
Thanks @AbhigyaShridhar @pandafy! 👍
[firmware-upgrader/admin.py/Firmware Build Recovery] Removed reversion as a dependency to remove recovery of deleted builds #170
I removed reversion from requirements.txt and from admin.py to remove the Recovery of deleted firmware builds option.
Fixes #170'