-
Notifications
You must be signed in to change notification settings - Fork 91
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
Snippets with RevisionMixin but not also DraftStateMixin crash. #857
Comments
@alexalligator thank you for this. That is a great catch. The suggested fix sounds about right. Would be good to double check what a snippet with only RevisionMixin does. i.e. if you save a new version, is that live? I suspect that is the case, but would appreciate confirmation |
This is my understanding: There is not concept of You can think of it as just a vanilla snippet instance that keeps a log of timestamped, serialized versions of itself ( You interact with the model itself as you would any vanilla Django model. There's no need to work out which 'revision' is live. So it's just a sort of audit log feature for the model. That's what we use it for. |
Thanks Alex, that is my understanding of it as well. It is always good to get a sanity check ;) and I am glad we're on the same page. Do you have time to submit a PR? |
Yep, will do. Glad to finally be able to give a little something back. |
Hi there and thanks for this great library.
I would like to draw your attention to this code here:
wagtail-localize/wagtail_localize/models.py
Lines 807 to 816 in 7797bd3
Taken from
TranslationSource.create_or_update_translation
.Here a new translation is being saved. The code checks to see if the translated object is a
RevisionMixin
and if so it creates a new_revision and then publishes it.Revision
fromwagtail.models
defines apublish()
method:Note that it in turn calls
self.content_object.publish
, whereself.content_object
is essentially the translated object we started with.The problem is that adding
RevisionMixin
to, say, a snippet does not give it apublish()
method, so you get anAttributeError
onself.content_object
.DraftStateMixin
does provide apublish()
method so snippets that have both drafts and revisions are fine but those with just revisions crash.Something along the lines of the following might fix this:
The text was updated successfully, but these errors were encountered: