# 'Copy A Snippet' Feature for Wagtail CMS
You can now "copy" snippets (non-page models) in Wagtail CMS
## Installation
1. Install the python package wagtailsnippetscopy from pip
`pip install wagtailsnippetscopy`
Alternatively, you can install download or clone this repo and call `pip install -e .`.
2. Add to INSTALLED_APPS in your **settings.py**:
`'wagtailsnippetscopy',`
3. Register a model (with a title field name) you wish to enable copy functionality for:
```python
from wagtailsnippetscopy.registry import snippet_copy_registry
snippet_copy_registry.register(YourModel, {})
```
4. Add SnippetCopyMixin to your Snippet model in order to enable get_copy_url callback() for the model:
```python
from wagtailsnippetscopy.models import SnippetCopyMixin
class Graph(SnippetCopyMixin, models.Model):
```
5. If you wish copy link to automatically appear in modeladmin list you should add SnippetCopyModelAdminMixin to the ModelAdmin class:
In admin.py:
```python
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtailsnippetscopy.admin import SnippetCopyModelAdminMixin
from .models import YourModel
class YourModelAdmin(SnippetCopyModelAdminMixin, ModelAdmin):
model = YourModel
modeladmin_register(GraphAdmin)
```
6. Copy link follows the following pattern:
```
/admin/copy-snippet/<app_label>/<model_name>/<object_id>/
```
## Bugs and suggestions
If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.
[https://github.com/timonweb/wagtailsnippetscopy/issues](https://github.com/timonweb/wagtailsnippetscopy/issues)
by [Tim Kamanin](https://timonweb.com/wagtail-developer/)
Raw data
{
"_id": null,
"home_page": "https://timonweb.com",
"name": "wagtailsnippetscopy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Tim Kamanin",
"author_email": "tim@timonweb.com",
"download_url": "https://files.pythonhosted.org/packages/ea/02/cf0c3dd909830d2c99455b0128a424f2e7822b39835d240ad17ee6eb6c29/wagtailsnippetscopy-0.5.2.tar.gz",
"platform": null,
"description": "# 'Copy A Snippet' Feature for Wagtail CMS\n\nYou can now \"copy\" snippets (non-page models) in Wagtail CMS\n\n## Installation\n\n1. Install the python package wagtailsnippetscopy from pip\n\n`pip install wagtailsnippetscopy`\n\nAlternatively, you can install download or clone this repo and call `pip install -e .`.\n\n2. Add to INSTALLED_APPS in your **settings.py**:\n\n`'wagtailsnippetscopy',`\n\n3. Register a model (with a title field name) you wish to enable copy functionality for:\n\n```python\nfrom wagtailsnippetscopy.registry import snippet_copy_registry\n\nsnippet_copy_registry.register(YourModel, {})\n```\n\n4. Add SnippetCopyMixin to your Snippet model in order to enable get_copy_url callback() for the model:\n\n```python\nfrom wagtailsnippetscopy.models import SnippetCopyMixin\n\nclass Graph(SnippetCopyMixin, models.Model):\n```\n\n5. If you wish copy link to automatically appear in modeladmin list you should add SnippetCopyModelAdminMixin to the ModelAdmin class:\n\nIn admin.py:\n\n```python\nfrom wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register\nfrom wagtailsnippetscopy.admin import SnippetCopyModelAdminMixin\nfrom .models import YourModel\n\nclass YourModelAdmin(SnippetCopyModelAdminMixin, ModelAdmin):\n model = YourModel\n\nmodeladmin_register(GraphAdmin)\n```\n\n6. Copy link follows the following pattern:\n\n```\n/admin/copy-snippet/<app_label>/<model_name>/<object_id>/\n```\n\n## Bugs and suggestions\n\nIf you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.\n\n[https://github.com/timonweb/wagtailsnippetscopy/issues](https://github.com/timonweb/wagtailsnippetscopy/issues)\n\nby [Tim Kamanin](https://timonweb.com/wagtail-developer/)\n",
"bugtrack_url": null,
"license": "The MIT License (MIT)",
"summary": "Copy A Snippet Feature for Wagtail CMS",
"version": "0.5.2",
"project_urls": {
"Homepage": "https://timonweb.com",
"Repository": "https://github.com/timonweb/wagtailsnippetscopy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7cdf49b1f684d2d6e2f76aef5dd0521dc0fd53427bb2260be11f51e844f298f6",
"md5": "bd232b425354f331a21908fc48f8727d",
"sha256": "36b7554a68a3fca6c8ad56b829132cf49a3e98d51920a793b2c3f760e8c09bbf"
},
"downloads": -1,
"filename": "wagtailsnippetscopy-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bd232b425354f331a21908fc48f8727d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 6520,
"upload_time": "2023-06-14T13:36:49",
"upload_time_iso_8601": "2023-06-14T13:36:49.687987Z",
"url": "https://files.pythonhosted.org/packages/7c/df/49b1f684d2d6e2f76aef5dd0521dc0fd53427bb2260be11f51e844f298f6/wagtailsnippetscopy-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ea02cf0c3dd909830d2c99455b0128a424f2e7822b39835d240ad17ee6eb6c29",
"md5": "0f540c476833b58c83a9659ac4686035",
"sha256": "9688e981c056b2c136c6166c3210c7d12dadd5d026957737bff036d1fee7b304"
},
"downloads": -1,
"filename": "wagtailsnippetscopy-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "0f540c476833b58c83a9659ac4686035",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 4351,
"upload_time": "2023-06-14T13:36:51",
"upload_time_iso_8601": "2023-06-14T13:36:51.041778Z",
"url": "https://files.pythonhosted.org/packages/ea/02/cf0c3dd909830d2c99455b0128a424f2e7822b39835d240ad17ee6eb6c29/wagtailsnippetscopy-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-14 13:36:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "timonweb",
"github_project": "wagtailsnippetscopy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "wagtailsnippetscopy"
}