GithubHelp home page GithubHelp logo

isabella232 / wagtail-copyablemodeladmin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cfpb/wagtail-copyablemodeladmin

0.0 0.0 0.0 164 KB

CopyableModelAdmin is an extension of the Wagtail ModelAdmin that allows for model instances to be copied in the user interface with a "Copy" button

License: Creative Commons Zero v1.0 Universal

Python 100.00%

wagtail-copyablemodeladmin's Introduction

Wagtail CopyableModelAdmin

Build Status Coverage Status

CopyableModelAdmin is an extension of the Wagtail ModelAdmin that allows for model instances to be copied in the user interface with a "Copy" button.

Dependencies

  • Python 3.6+
  • Django 1.11+, 2.0+
  • Wagtail 1.13+, 2.0+

Installation

  1. Install wagtail-copyablemodeladmin:
pip install wagtail-copyablemodeladmin
  1. Add copyablemodeladmin as an installed app in your Django settings.py:
INSTALLED_APPS = (
    ...
    'copyablemodeladmin',
    ...
)

Usage

Please see the Wagtail ModelAdmin documentation for getting started with ModelAdmin.

When creating a ModelAdmin for objects that should be copyable, instead of inheriting from ModelAdmin, inherit from copyablemodeladmin.options.CopyableModelAdmin:

from wagtail.contrib.modeladmin.options import modeladmin_register
from copyablemodeladmin.options import CopyableModelAdmin
from myapp.models import Book


# Inherit from CopyableModelAdmin instead of ModelAdmin
class BookAdmin(CopyableModelAdmin):
    model = Book
    list_display = ('title', 'author')
    list_filter = ('author',)
    search_fields = ('title', 'author')

# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(BookAdmin)

In addition to CopyableModelAdmin, there are three mixin classes that can be added to other custom ModelAdmin subclasses:

from copyablemodeladmin.helpers import CopyButtonHelperMixin
from copyablemodeladmin.options import CopyableModelAdminMixin
from copyablemodeladmin.views import CopyViewMixin


class CustomCopyButtonHelper(CopyButtonHelperMixin, CustomButtonHelper):
    pass


class CustomCopyInstanceView(CopyViewMixin, CustomInstanceSpecificView):
    pass


class CustomCopyableModelAdmin(CopyableModelAdminMixin, ModelAdmin):
    button_helper_class = CustomCopyButtonHelper
    copy_view_class = CustomCopyInstanceView

Getting help

Please add issues to the issue tracker.

Getting involved

General instructions on how to contribute can be found in CONTRIBUTING.

Licensing

  1. TERMS
  2. LICENSE
  3. CFPB Source Code Policy

Credits and references

  1. Forked from cfgov-refresh

wagtail-copyablemodeladmin's People

Contributors

willbarton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.