Ejemplo n.º 1
0
class MediaAdminBase(admin_actions.MediaBaseActionsMixin, mixins.DropUploadAdminMixin, admin.ModelAdmin):
    list_display = ['is_public', 'admin_thumbnail', 'get_name_display',
        'get_categories_display',
        'modified']  # , 'created']
    list_display_links = ('admin_thumbnail', 'get_name_display')
    # list_editable = ['is_public']
    list_per_page = 25
    list_filter = ['is_public', 'categories', 'role']
    search_fields = [
        *i18n_fields('name'),
        'slug',
        *i18n_fields('caption'),
        *i18n_fields('credits'),
        *i18n_fields('copyright'),
    ]
    date_hierarchy = 'modified'
    ordering = ['-modified']

    fieldsets = (
        (None, {
            'fields': [
                'is_public',
                'file',
                *i18n_fields('name'),
                'role',
            ]}),
        (_("Texte"), {
            'fields': [
                *i18n_fields('caption'),
                *i18n_fields('credits'),
                *i18n_fields('copyright'),
            ]}),
        (_("Ordnung"), {
            'fields': [
                'categories',
            ]}),
    )
    filter_horizontal = ['categories']

    admin_thumbnail = AdminThumbnail(
        image_field='thumbnail',
        template='imagekit/admin/selectable_thumbnail.html')
    admin_thumbnail.short_description = _("Foto")

    # TODO class Media: add switch_languages script

    def get_name_display(self, obj):
        return format_html(
            "<small>{categories}</small><br>{caption}",
            categories=", ".join([str(p) for p in obj.categories.all()]),
            caption=str(obj),
        )
    get_name_display.short_description = _("Name")
    get_name_display.admin_order_field = lang_suffix(fieldname='name')

    def get_categories_display(self, obj):
        return mark_safe("<br>".join([str(c) for c in obj.categories.all()]))
    get_categories_display.short_description = _("Arbeitsmappen")
    get_categories_display.admin_order_field = 'categories__name'
Ejemplo n.º 2
0
class GalleryAdmin(admin.ModelAdmin):
    list_display = ('is_public', 'name', 'get_image_count')
    list_display_links = ['name']
    list_filter = ['is_public']
    search_fields = [
        *i18n_fields('name'),
        'slug',
        *i18n_fields('caption'),
        *i18n_fields('credits'),
    ]

    fieldsets = (
        (None, {
            'fields': [
                'is_public',
                *i18n_fields('name'),
                'slug',
            ]}),
        (_("Texte"), {
            'fields': [
                *i18n_fields('caption'),
                *i18n_fields('credits'),
            ]}),
        (_("Weiteres"), {
            'classes': ['collapse'],
            'fields': [
                'order_index',
            ]}),
    )
    prepopulated_fields = {
        'slug': [i18n_fields('name')[0]],
    }

    inlines = [ImageGalleryRelInline]

    def get_image_count(self, obj):
        return obj.images.count()
    get_image_count.short_description = _("Bilder")
Ejemplo n.º 3
0
 class Meta:
     verbose_name = _("Download")
     verbose_name_plural = _("Downloads")
     ordering = i18n_fields('name')
Ejemplo n.º 4
0
 class Meta:
     verbose_name = _("Bild-Typ")
     verbose_name_plural = _("Bild-Typen")
     ordering = i18n_fields('name')
Ejemplo n.º 5
0
 class Meta:
     verbose_name = _("Image Gallery")
     verbose_name_plural = _("Image Galleries")
     ordering = i18n_fields('name')
Ejemplo n.º 6
0
class MediaRoleAdmin(admin.ModelAdmin):
    list_display = i18n_fields('name')