-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Feature/10921 snippet copy function #11270
Conversation
Manage this branch in SquashTest this branch here: https://smark-1feature10921-snippet-co-p882k.squash.io |
@smark-1 thank you for this PR and well done on getting your first PR up. I have started the CI, please review any failures and resolve them if you can. Additionally, it would be good for you to set up some tests for this. |
I resolved some of the failures. but many of the errors seem to be caused by |
Hi @smark-1, just looking at this both as the original author of the issue, and because I'd like to see this addition make it into the next release. I also will need a snippet copy function for code I'm porting over from ModelAdmin, which I want to make work under Wagtail 5.2 LTS, so will need backport equivalent functionality for that. I have a suggestion, which will make the code a bit more consistent and hopefully clear up the
Hope this helps. |
@dkirkham Thank you. I can't figure out where the |
@dkirkham I was able to figure out how the inspect view works and I got the new copy view to work the same way. Now there are only 35 errors that all the message "django.urls.exceptions.NoReverseMatch: Reverse for 'copy' not found. 'copy' is not a valid view function or pattern name." This is definitely an improvement, but I am not sure how to resolve these errors. |
Hi @smark-1, I see what's happening. Some of your changes are to This does beg the question, should we be adding the copy function to I think that a copy function is pretty fundamental and applicable to a model, and not related to the goodness that snippets add with all the publishing-related functions. Hence I'd suggest seeing if the copy function can be added primarily to Maybe @lb- or @laymonage, you would care to comment? |
Hi @smark-1, I've set up a simple project with a minimal model, snippet and snippet with inline model. The copy functionality in both The next step is to add some tests, for both |
@dkirkham I was very busy this past week. I hope to finish adding the tests and documentation sometime this week. |
@lb- I think this is ready for review |
@smark-1 are you able to rebase on |
Just a note, whatever naming/approach we decide here we would probably want to use that on I know that this copy function is about the view class but maybe we should consider a way to override the form class in isolation of the view. |
b3b1688
to
bbe78d3
Compare
Another comment @lb-, I left a question at #10921 (comment) about what hooks should be called during the copy process, with no response so far. I haven't checked this, but I expect the copy code in this PR will only call the |
@dkirkham It seems like you don't have any specific use cases for the before_copy_snippet and after_copy_snippet hooks and I can't think of any use cases for this myself. If there is a rare use case someone should be able to override the copy_view_class to provide themselves with the desired functionality. |
Hi @smark-1, I don't have any specific use cases, but I could imagine there might be some, for instance to prepare the data being copied before it is presented to editors. The argument for inclusion is for consistency with the existing hooks eg. https://docs.wagtail.org/en/stable/reference/hooks.html#snippets and the Page copy hooks. |
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.
Thank you @smark-1 & @dkirkham - this feature works great.
I tested the default and disabled behaviour, tested user permissions and a few other smoke tests of creation and could not find any issues.
I think the scope of this is small and a really great improvement to the Model/Snippet ViewSet functionality.
It would be great to see the ability to override just the copy form class more easily and maybe review the hooks but they can be raised as new issues if the community feels there is value there.
As noted on the original issue, it might be nice to update the page titles for the copy view but that too can be done as a future improvement.
I have rebased and made a few final touches on the PR (below) and will push and check the CI all runs.
- Consistently add
copy
code/attributes/docs above the inspect, various parts of the changes had this below or above the inspect part. Just trying to be consistent. - Add basic documentation for this feature in the relevant snippets/generic viewset pages.
- Clean up a few code line breaks / white space changes that were not needed.
- Add release notes considerations.
6e04312
to
f12083e
Compare
f12083e
to
babc2ff
Compare
Adds #10921
Please check the following:
make lint
from the Wagtail root.Please describe additional details for testing this change.
Footnotes
Development Testing ↩
Browser and device support ↩
Accessibility Target ↩