Exemplo n.º 1
0
# Sitetree admin override needs to be moved somewhere else
from sitetree.admin import TreeItemAdmin, TreeAdmin, override_tree_admin, override_item_admin

class CustomTreeItemAdmin(TreeItemAdmin):
    # That will turn a tree item representation from the default variant
    # with collapsible groupings into a flat one.
    fieldsets = None
    fields = ('parent', 'title', 'url')

# Now we tell the SiteTree to replace generic representations with custom.
override_item_admin(CustomTreeItemAdmin)
Exemplo n.º 2
0
            'fields': ('access_loggedin', 'access_guest', 'access_restricted',
                       'access_permissions', 'access_perm_type')
        }),
        (_('Display settings'), {
            'classes': ('collapse', ),
            'fields': ('hidden', 'inmenu', 'inbreadcrumbs', 'insitetree')
        }),
        (_('Additional settings'), {
            'classes': ('collapse', ),
            'fields': ('hint', 'description', 'alias', 'urlaspattern')
        }),
    )


# Now we tell the SiteTree to replace generic representations with custom.
override_item_admin(G3WTreeItemAdmin)


class GroupAdmin(GuardedModelAdmin):
    model = Group


admin.site.register(Group, GroupAdmin)


class MacroGroupAdmin(GuardedModelAdmin, OrderedModelAdmin):
    model = MacroGroup


admin.site.register(MacroGroup, MacroGroupAdmin)
Exemplo n.º 3
0
from modeltranslation.admin import TranslationAdmin

from sitetree.admin import TreeItemAdmin, override_item_admin


class ModeltranslationTreeItemAdmin(TreeItemAdmin, TranslationAdmin):
    """This allows admin contrib to support translations for tree items."""


override_item_admin(ModeltranslationTreeItemAdmin)
Exemplo n.º 4
0
from sitetree.admin import TreeItemAdmin, override_item_admin
from django.utils.translation import ugettext_lazy as _

# And our custom tree item admin model.


class CustomTreeItemAdmin(TreeItemAdmin):
    # That will turn a tree item representation from the default variant
    # with collapsible groupings into a flat one.
    fieldsets = (
        (_('Basic settings'), {
        'fields': ('parent', 'title', 'url',)
        }),
        (_('Access settings'), {
        'classes': ('collapse',),
        'fields': ('access_loggedin', 'access_guest', 'access_restricted', 'access_permissions', 'access_perm_type')
        }),
        (_('Display settings'), {
        'classes': ('collapse',),
        'fields': ('hidden', 'inmenu', 'inbreadcrumbs', 'insitetree')
        }),
        (_('Additional settings'), {
        'classes': ('collapse',),
        'fields': ('hint', 'css_class', 'description', 'alias', 'urlaspattern')
        }),
    )

# Now we tell the SiteTree to replace generic representations with custom.
override_item_admin(CustomTreeItemAdmin)
Exemplo n.º 5
0
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from sitetree.admin import TreeItemAdmin, override_item_admin

class TreeItemAdmin(TreeItemAdmin):
	fieldsets = TreeItemAdmin.fieldsets

	fieldsets += (
       (_('Styling'), {
            'fields': ('css_class',)
        }),
    )

# override_item_admin(TreeAdmin)
override_item_admin(TreeItemAdmin)
Exemplo n.º 6
0
        if not form.cleaned_data.get('authors'):
            form.cleaned_data['authors'] = Author.objects.filter(
                pk=request.user.pk)

        entry.last_update = timezone.now()
        entry.save()
 
class ZinniaCategoryTranslatedAdmin(zinnia_admin.CategoryAdmin, TranslationAdmin, ModelTranslationMedia):
    list_display = ('title',)
    def formfield_for_dbfield(self, db_field, **kwargs):
        field = super(ZinniaCategoryTranslatedAdmin, self).formfield_for_dbfield(db_field, **kwargs)
        self.patch_translation_field(db_field, field, **kwargs)
        return field

class ClockTownTranslatedAdmin(TranslationAdmin, ModelTranslationMedia, OrderedModelAdmin):
    list_display = ('town', 'reorder')
  
admin.site.unregister(zinnia_models.Entry)
admin.site.unregister(zinnia_models.Category)
admin.site.register(zinnia_models.Entry, ZinniaEntryTranslatedAdmin)
admin.site.register(zinnia_models.Category, ZinniaCategoryTranslatedAdmin)
admin.site.register(ClockTown, ClockTownTranslatedAdmin)


class TreeItemTranslatedAdmin(TreeItemAdmin, TranslationAdmin, ModelTranslationMedia):
    pass

override_item_admin(TreeItemTranslatedAdmin)
admin.site.register(MenuImage)
Exemplo n.º 7
0
class TreeItemAdmin(ModelAdminWithDefaultPagination, sitetree_admin.TreeItemAdmin):
    """
    Reduce fields available when editing TreeItems
    """
    fieldsets = (
        (_('Basic settings'), {
            'fields': ('title', 'url',)
        }),
        (_('Access settings'), {
            'fields': ('access_loggedin', 'access_guest')
        }),
    )


sitetree_admin.override_tree_admin(TreeAdmin)
sitetree_admin.override_item_admin(TreeItemAdmin)


class FlatPageAdmin(ModelAdminWithDefaultPagination, flatpages_admin.FlatPageAdmin):
    """
    Customization of the FlatPageAdmin
    """
    # Reduce the visible fields in the admin
    fieldsets = (
        (None, {'fields': ('url', 'title', 'content', 'registration_required')}),)

    def save_model(self, request, obj, form, change):
        logger.debug('Change ? %s', change)
        if change:
            # Only saved objects can get items assigned to their
            # Many to many relationships