How to use the publish.admin.PublishableAdmin function in publish

To help you get started, we’ve selected a few publish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnsensible / django-publish / publish / tests.py View on Github external
def test_publish_selected_does_not_have_permission(self):
            self.admin_site.register(Page, PublishableAdmin)
            pages = Page.objects.exclude(id=self.fp3.id)
            
            class dummy_request(object):
                POST = {}

                class user(object):
                    @classmethod
                    def has_perm(cls, *arg):
                        return False 

                    @classmethod
                    def get_and_delete_messages(cls):
                        return []
            
            response = publish_selected(self.page_admin, dummy_request, pages)
            self.failIf(response is None)
github johnsensible / django-publish / publish / tests.py View on Github external
def setUp(self):
            super(TestUndeleteSelected, self).setUp()
            self.fp1 = FlatPage.objects.create(url='/fp1', title='FP1')
            
            self.fp1.publish()

            self.admin_site = AdminSite('Test Admin')
            self.page_admin = PublishableAdmin(FlatPage, self.admin_site)
github johnsensible / django-publish / publish / tests.py View on Github external
def setUp(self):
            super(TestPublishSelectedAction, self).setUp()
            self.fp1 = Page.objects.create(slug='fp1', title='FP1')
            self.fp2 = Page.objects.create(slug='fp2', title='FP2')
            self.fp3 = Page.objects.create(slug='fp3', title='FP3')

            self.admin_site = AdminSite('Test Admin')
            self.page_admin = PublishableAdmin(Page, self.admin_site)
            
            # override urls, so reverse works
            settings.ROOT_URLCONF=patterns('',
                ('^admin/', include(self.admin_site.urls)),
            )
github johnsensible / django-publish / publish / tests.py View on Github external
self.page1 = Page.objects.create(slug='page1', title='page 1')
            self.page2 = Page.objects.create(slug='page2', title='page 2')
            self.page1.publish()
            self.page2.publish()

            self.author1 = Author.objects.create(name='a1')
            self.author2 = Author.objects.create(name='a2')
            self.author1.publish()
            self.author2.publish()

            self.admin_site = AdminSite('Test Admin')
            
            class PageBlockInline(PublishableStackedInline):
                model = PageBlock

            class PageAdmin(PublishableAdmin):
                inlines = [PageBlockInline]

            self.admin_site.register(Page, PageAdmin)
            self.page_admin = PageAdmin(Page, self.admin_site)

            # override urls, so reverse works
            settings.ROOT_URLCONF=patterns('',
                ('^admin/', include(self.admin_site.urls)),
            )
github johnsensible / django-publish / publish / tests.py View on Github external
def setUp(self):
            super(TestDeleteSelected, self).setUp()
            self.fp1 = FlatPage.objects.create(url='/fp1', title='FP1')
            self.fp2 = FlatPage.objects.create(url='/fp2', title='FP2')
            self.fp3 = FlatPage.objects.create(url='/fp3', title='FP3')
            
            self.fp1.publish()
            self.fp2.publish()
            self.fp3.publish()
            
            self.admin_site = AdminSite('Test Admin')
            self.page_admin = PublishableAdmin(FlatPage, self.admin_site)
            
            # override urls, so reverse works
            settings.ROOT_URLCONF=patterns('',
                ('^admin/', include(self.admin_site.urls)),
            )
github johnsensible / django-publish / examplecms / pubcms / admin.py View on Github external
class PageBlockInlineAdmin(PublishableStackedInline):
    model = PageBlock
    extra = 1

class PageAdmin(PublishableAdmin):
    inlines = [PageBlockInlineAdmin]
    prepopulated_fields = {"slug": ("title",)}
    list_filter = ['publish_state', 'categories']

class CategoryAdmin(PublishableAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(Page, PageAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Image, PublishableAdmin)
github johnsensible / django-publish / publish / admin.py View on Github external
for obj in self.deleted_objects:
            if obj.pk is not None:
                obj.delete(mark_for_deletion=False)
        return saved_instances


class PublishableStackedInline(admin.StackedInline):
    formset = PublishableBaseInlineFormSet


class PublishableTabularInline(admin.TabularInline):
    formset = PublishableBaseInlineFormSet


# add in extra methods
for admin_class in [PublishableAdmin, PublishableStackedInline, PublishableTabularInline]:
    attach_filtered_formfields(admin_class)
github johnsensible / django-publish / examplecms / pubcms / admin.py View on Github external
from django.contrib import admin

from publish.admin import PublishableAdmin, PublishableStackedInline
from pubcms.models import Page, PageBlock, Category, Image

class PageBlockInlineAdmin(PublishableStackedInline):
    model = PageBlock
    extra = 1

class PageAdmin(PublishableAdmin):
    inlines = [PageBlockInlineAdmin]
    prepopulated_fields = {"slug": ("title",)}
    list_filter = ['publish_state', 'categories']

class CategoryAdmin(PublishableAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(Page, PageAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Image, PublishableAdmin)
github johnsensible / django-publish / examplecms / pubcms / admin.py View on Github external
from django.contrib import admin

from publish.admin import PublishableAdmin, PublishableStackedInline
from pubcms.models import Page, PageBlock, Category, Image

class PageBlockInlineAdmin(PublishableStackedInline):
    model = PageBlock
    extra = 1

class PageAdmin(PublishableAdmin):
    inlines = [PageBlockInlineAdmin]
    prepopulated_fields = {"slug": ("title",)}
    list_filter = ['publish_state', 'categories']

class CategoryAdmin(PublishableAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(Page, PageAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Image, PublishableAdmin)