class ChannelAdmin(ModelAdmin): edit_template = 'admin/custom/edit.html' create_template = 'admin/custom/create.html' roles_accepted = ('admin', 'editor') column_list = ('title', 'long_slug', 'is_homepage', 'channel_type', 'created_at', 'available_at', 'published') column_filters = ['published', 'is_homepage', 'include_in_rss', 'show_in_menu', 'indexable'] column_searchable_list = ('title', 'description') form_columns = ['title', 'slug', 'description', 'parent', 'is_homepage', 'include_in_rss', 'indexable', 'show_in_menu', 'order', 'published', 'canonical_url', 'values', 'channel_type', 'inherit_parent', 'content_filters', 'available_at', 'available_until', 'render_content'] column_formatters = {'created_at': ModelAdmin.formatters.get('datetime'), 'available_at': ModelAdmin.formatters.get('datetime')} form_subdocuments = {} form_widget_args = { 'description': { 'rows': 20, 'cols': 20, 'class': 'text_editor', 'style': "margin: 0px; width: 400px; height: 250px;" }, 'title': {'style': 'width: 400px'}, 'slug': {'style': 'width: 400px'}, } form_ajax_refs = { 'render_content': AjaxModelLoader('render_content', Content, fields=['title', 'slug']), 'parent': {'fields': ['title', 'slug', 'long_slug']}, }
class ImageAdmin(MediaAdmin): roles_accepted = ('admin', 'editor', 'author') column_list = ('title', 'full_path', 'thumb', 'published') form_columns = ['title', 'slug', 'path', 'channel', 'content_format', 'comments_enabled', 'summary', 'published'] column_formatters = { 'thumb': _list_thumbnail } form_extra_fields = { 'path': ImageUploadField( 'Image', base_path=lazy_media_path(), thumbnail_size=get_setting_value('MEDIA_IMAGE_THUMB_SIZE', default=(200, 200, True)), endpoint="quokka.core.media", namegen=dated_path, permission=0o777, allowed_extensions="MEDIA_IMAGE_ALLOWED_EXTENSIONS", ) } form_ajax_refs = { 'channel': AjaxModelLoader( 'channel', Channel, fields=['title', 'slug', 'long_slug'], filters={"long_slug__startswith": "media/image"} ) }
class AudioAdmin(FileAdmin): form_columns = [ 'title', 'slug', 'path', 'embed', 'channel', 'content_format', 'comments_enabled', 'summary', 'published' ] form_ajax_refs = { 'channel': AjaxModelLoader('channel', Channel, fields=['title', 'slug', 'long_slug'], filters={"long_slug__startswith": "media/audio"}) }
class ImageAdmin(MediaAdmin): roles_accepted = ('admin', 'editor', 'author') column_list = ('title', 'path', 'thumb', 'published') form_columns = ['title', 'slug', 'path', 'channel', 'content_format', 'comments_enabled', 'summary', 'published'] def _list_thumbnail(self, context, model, name): if not model.path: return '' return Markup( '<img src="%s" width="100">' % url_for( 'media', filename=form.thumbgen_filename(model.path) ) ) column_formatters = { 'thumb': _list_thumbnail } form_extra_fields = { 'path': ImageUploadField( 'Image', base_path=lazy_media_path(), thumbnail_size=get_setting_value('MEDIA_IMAGE_THUMB_SIZE', default=(200, 200, True)), endpoint="media", namegen=dated_path, permission=0o777, allowed_extensions="MEDIA_IMAGE_ALLOWED_EXTENSIONS", ) } form_ajax_refs = { 'channel': AjaxModelLoader( 'channel', Channel, fields=['title', 'slug', 'long_slug'], filters={"long_slug__startswith": "media/image"} ) }
class FileAdmin(MediaAdmin): form_args = { 'path': { 'label': 'File', 'base_path': lazy_media_path(), 'namegen': dated_path, 'permission': 0o777 }, 'summary': {'widget': TextEditor()}, 'slug': {'widget': PrepopulatedText(master='title')}, } form_ajax_refs = { 'channel': AjaxModelLoader( 'channel', Channel, fields=['title', 'slug', 'long_slug'], filters={"long_slug__startswith": "media/files"} ) }