<commit_before># coding : utf -8
from flask.ext.htmlbuilder import html
from flask.ext.admin.babel import lazy_gettext
from quokka import admin
from quokka.core.admin.models import ModelAdmin

from .models import Post


class PostAdmin(ModelAdmin):
    """
    All attributes added here for example
    more info in admin source
    github.com/mrjoes/flask-admin/blob/master/flask_admin/model/base.py
    or Flask-admin documentation
    """

    roles_accepted = ('admin', 'editor')
    can_create = True
    can_edit = True
    can_delete = True

    # list_template = 'admin/model/list.html'
    edit_template = 'admin/custom/edit.html'
    create_template = 'admin/custom/create.html'

    column_list = ('title', 'slug', 'channel', 'published', 'view_on_site')

    def view_on_site(self, request, obj, fieldname, *args, **kwargs):
        return html.a(
            href=obj.get_absolute_url('detail'),
            target='_blank',
        )(html.i(class_="icon icon-eye-open", style="margin-right: 5px;")(),
          lazy_gettext('View on site'))

    # column_exclude_list = []

    column_formatters = {'view_on_site': view_on_site}
    # column_type_formatters = {}
    # column_labels = {}
    # column_descriptions = {}
    # column_sortable_list = [] / ('name', ('user', 'user.username'))
    # column_default_sort = 'pk'
    # column_choices = {'column': ('value', 'display')}
    # column_display_pk = True
    column_filters = ['published', 'title']
    column_searchable_list = ('title', 'body', 'summary')

    form_columns = ['title', 'slug', 'channel', 'related_channels', 'summary',
                    'body', 'main_image', 'main_image_caption', 'published',
                    'show_on_channel', 'available_at', 'tags', 'comments',
                    'values']
    # form_excluded_columns = []
    # form = None
    # form_overrides = None

    form_widget_args = {
        'body': {
            'rows': 20,
            'cols': 20,
            'class': 'html_editor',
            'style': "margin: 0px; width: 725px; height: 360px;"
        },
        'summary': {
            'style': 'width: 400px; height: 100px;'
        },
        'title': {'style': 'width: 400px'},
        'slug': {'style': 'width: 400px'},
    }

    # form_args = {
    #     'body': {
    #         'widget': BigTextArea()
    #     }
    # }

    # form_extra_fields = {}

    # action_disallowed_list

    # page_size = 20
    form_ajax_refs = {
        'main_image': ('title',)
    }


admin.register(Post, PostAdmin, category="Content")<commit_msg>Fix ajax fields format<commit_after># coding : utf -8
from flask.ext.htmlbuilder import html
from flask.ext.admin.babel import lazy_gettext
from quokka import admin
from quokka.core.admin.models import ModelAdmin

from .models import Post


class PostAdmin(ModelAdmin):
    """
    All attributes added here for example
    more info in admin source
    github.com/mrjoes/flask-admin/blob/master/flask_admin/model/base.py
    or Flask-admin documentation
    """

    roles_accepted = ('admin', 'editor')
    can_create = True
    can_edit = True
    can_delete = True

    # list_template = 'admin/model/list.html'
    edit_template = 'admin/custom/edit.html'
    create_template = 'admin/custom/create.html'

    column_list = ('title', 'slug', 'channel', 'published', 'view_on_site')

    def view_on_site(self, request, obj, fieldname, *args, **kwargs):
        return html.a(
            href=obj.get_absolute_url('detail'),
            target='_blank',
        )(html.i(class_="icon icon-eye-open", style="margin-right: 5px;")(),
          lazy_gettext('View on site'))

    # column_exclude_list = []

    column_formatters = {'view_on_site': view_on_site}
    # column_type_formatters = {}
    # column_labels = {}
    # column_descriptions = {}
    # column_sortable_list = [] / ('name', ('user', 'user.username'))
    # column_default_sort = 'pk'
    # column_choices = {'column': ('value', 'display')}
    # column_display_pk = True
    column_filters = ['published', 'title']
    column_searchable_list = ('title', 'body', 'summary')

    form_columns = ['title', 'slug', 'channel', 'related_channels', 'summary',
                    'body', 'main_image', 'main_image_caption', 'published',
                    'show_on_channel', 'available_at', 'tags', 'comments',
                    'values']
    # form_excluded_columns = []
    # form = None
    # form_overrides = None

    form_widget_args = {
        'body': {
            'rows': 20,
            'cols': 20,
            'class': 'html_editor',
            'style': "margin: 0px; width: 725px; height: 360px;"
        },
        'summary': {
            'style': 'width: 400px; height: 100px;'
        },
        'title': {'style': 'width: 400px'},
        'slug': {'style': 'width: 400px'},
    }

    # form_args = {
    #     'body': {
    #         'widget': BigTextArea()
    #     }
    # }

    # form_extra_fields = {}

    # action_disallowed_list

    # page_size = 20
    form_ajax_refs = {
        'main_image': {"fields": ('title',)}
    }


admin.register(Post, PostAdmin, category="Content")
{'fraction_non_alphanumeric': 0.14870395634379263, 'fraction_numerical': 0.010524264275969596, 'mean_word_length': 2.6268551236749116, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4527863', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1612, 'n_words': 341}