-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: allow reuse of status indicators #319
Conversation
Codecov Report
@@ Coverage Diff @@
## master #319 +/- ##
==========================================
+ Coverage 89.99% 90.53% +0.53%
==========================================
Files 68 68
Lines 2259 2324 +65
Branches 301 314 +13
==========================================
+ Hits 2033 2104 +71
+ Misses 171 165 -6
Partials 55 55
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
from djangocms_versioning.test_utils.blogpost import models | ||
|
||
|
||
class BlogContentAdmin(ExtendedVersionAdminMixin, admin.ModelAdmin): | ||
pass | ||
class BlogContentAdmin(StateIndicatorMixin, ExtendedVersionAdminMixin, admin.ModelAdmin): |
Check warning
Code scanning / CodeQL
Conflicting attributes in base classes
|
||
|
||
admin.site.register(models.BlogPost) | ||
class BlogPostAdmin(StateIndicatorMixin, ExtendedVersionAdminMixin, admin.ModelAdmin): |
Check warning
Code scanning / CodeQL
Conflicting attributes in base classes
@@ -326,6 +407,14 @@ | |||
return list_display | |||
|
|||
|
|||
class ExtendedIndicatorVersionAdminMixin(StateIndicatorMixin, ExtendedVersionAdminMixin): |
Check warning
Code scanning / CodeQL
Conflicting attributes in base classes
@Aiky30 I've updated the PR. I do not expect additional backwards incompatible behavior. This version of versioning will not work with Django CMS 4.0 anyways since it does not use monkey patching. All elements were tested, but only indirectly. I added tests to explicitly test especially the new query sets. |
js = ("admin/js/jquery.init.js", "djangocms_versioning/js/indicators.js",) | ||
# css for indicators and context menu | ||
css = { | ||
"all": (static_with_version("cms/css/cms.pagetree.css"),), |
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.
A ticket to create for a future change in the core and here is to separate the indicator styling out of this file.
djangocms_versioning/admin.py
Outdated
""" | ||
grouping_filters = {} | ||
for field in versionable.extra_grouping_fields: | ||
if hasattr(self, f"get_{field}_from_request"): |
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.
I'm not seeing unit test coverage for this new condition that checks that the get_field_form_request
. Is it covered by another test?
tests/test_indicators.py
Outdated
self.assertEqual(content.versions.first(), version1) | ||
|
||
# Now archive | ||
version1.archive(user=self.get_superuser()) |
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.
Not that important but each check could have been a separate test in the Class, with the version being defined in setup. would have been able to keep the AAA test pattern that's used elsewhere then too.
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.
Changed it.
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
@Aiky30 OK, I'm ready for round three! Thanks for asking for the test for The only open point is the import of
I figured that |
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.
Looks good and great test coverage. Good job. Thanks for taking the time to consider and act on the comments. :-)
Thanks for talking the time to look through this. I appreciate the comments (and the additional coverage prevented a bug 🙂). |
Description
This PR refactors the indicators.py setup to allow using indicators outside the PageTree (i.e. other versioned models). Existing functionality does not change.
latest_content()
has been added to theadmin_manager
query set. It respects prefetched content objects reducing db accessesUsage
The status indicator for versioning can be added to a ModelAdmin by:
Remarks:
cms.pagetree.css
(not the js) from the core into the admin formExtendedVersionAdminMixin
.ExtendedIndicatorVersionAdminMixin
combines state indicators and the extended versioning admin.Example: djangocms-alias
This is the result of relpacing
ExtendedVersionAdminMixin
withExtendedIndicatorVersionAdminMixin
for djangocms-alias:Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.