-
Notifications
You must be signed in to change notification settings - Fork 31
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
Provide additional information when sending publish/unpublish events #348
Conversation
When sending post publishing events, include the list of unpublished versions. When sending post unpublishing events, include the version to be published.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #348 +/- ##
=======================================
Coverage 90.86% 90.86%
=======================================
Files 72 72
Lines 2530 2530
Branches 356 356
=======================================
Hits 2299 2299
Misses 170 170
Partials 61 61
☔ View full report in Codecov by Sentry. |
@GaretJax Can you provide some information on the use case? |
This allows a developer to hook up the the signal and differentiate between two usecases which currently look similar:
Up until now, both "unpublish" (and publish) signals look the same. With this change, we can see if another version will be published with this unpublish event and handle the signal differently. |
@kinkerl Thanks for explaining the pull request. I think I understand what you want to achieve. Still, I am not sure why you would need this. The basic design of djangocms-versioning is based on a finite state machine, i.e. how a version reached its state must be irrelevant, only the current state counts. For your example, this means: It must not make a difference if I unpublish version x, go to lunch and subsequently publish draft y or if I publish draft y and thereby implicitly unpublish version x within the same second. In both scenarios, the states in the beginning and in the end are the same. I am uncertain if it is a good idea to send different signals for the same process. In any case, the receiver can easily find out if there is a most recently unpublished version and take some action based on that. This would lead to the same behaviour with or without “lunch” in between. What use case would need to differentiate between those two scenarios? |
Lets assume we have a page published with versioning on a specific URL and i use elastic search as a search solution.
I aggree that a receiver can make an assumption/approximation about this which is not certain. However, it gets tricky for a receiver of an unpublish signal to figure out if another page might be going to get published in the future. |
Thanks, @kinkerl! I'll take this to the tech committee. |
@kinkerl Hey man, hope you're good, long time. Are you able to replicate this scenario in a unit test? This package is by far the most complicated and has the best coverage of any of the V4 packages. Some example sof signal tests that may help: https://github.com/django-cms/djangocms-versioning/blob/master/tests/test_signals.py |
added tests for to_be_published and unpublished attributes in signals
hey @Aiky30 , hope you are good ;) Added a test which covers the scenario. |
Can I also ask for an update of the docs ( |
No problem. However, i am not quite sure what you mean with "Can you please advise that the result of the signal functions called only depends on the final state of the version?" |
@fsbraun any update? Thanks! |
@kinkerl I think some docs with examples of usage would be great here. The elasticsearch scenario is an ideal one. I think the integration docs would be most suitable. |
@kinkerl Thanks for this contribution and the docs update! |
…vents (cherry-pick django-cms#348)
* feat: Provide additional information when sending publish/unpublish events (cherry-pick #348) * fix: Add keyword arguments in VersionAdminMixin render_change_form (cherry-pick #356) --------- Co-authored-by: Josh Yu <[email protected]>
Description
Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.