<commit_before>"""EntryAdmin for zinnia-tinymce"""
from django.forms import Media
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.contrib.staticfiles.storage import staticfiles_storage

from tinymce.widgets import TinyMCE

from zinnia.models import Entry
from zinnia.admin.entry import EntryAdmin


class EntryAdminTinyMCEMixin(object):
    """
    Mixin adding TinyMCE for editing Entry.content field.
    """

    def _media(self):
        """
        The medias needed to enhance the admin page.
        """
        media = super(EntryAdminTinyMCEMixin, self).media

        media += TinyMCE().media + Media(
            js=[reverse('tinymce-js', args=['admin/zinnia/entry']),
                staticfiles_storage.url(
                    'zinnia_tinymce/js/filebrowser.js')]
        )

        return media
    media = property(_media)


class EntryAdminTinyMCE(EntryAdminTinyMCEMixin,
                        EntryAdmin):
    """
    Enrich the default EntryAdmin with TinyMCE.
    """
    pass

admin.site.unregister(Entry)
admin.site.register(Entry, EntryAdminTinyMCE)<commit_msg>Use the callback view<commit_after>"""EntryAdmin for zinnia-tinymce"""
from django.forms import Media
from django.contrib import admin
from django.core.urlresolvers import reverse

from tinymce.widgets import TinyMCE

from zinnia.models import Entry
from zinnia.admin.entry import EntryAdmin


class EntryAdminTinyMCEMixin(object):
    """
    Mixin adding TinyMCE for editing Entry.content field.
    """

    def _media(self):
        """
        The medias needed to enhance the admin page.
        """
        media = super(EntryAdminTinyMCEMixin, self).media

        media += TinyMCE().media + Media(
            js=[reverse('tinymce-js', args=['admin/zinnia/entry']),
                reverse('tinymce-filebrowser-callback')]
        )

        return media
    media = property(_media)


class EntryAdminTinyMCE(EntryAdminTinyMCEMixin,
                        EntryAdmin):
    """
    Enrich the default EntryAdmin with TinyMCE.
    """
    pass

admin.site.unregister(Entry)
admin.site.register(Entry, EntryAdminTinyMCE)
{'fraction_non_alphanumeric': 0.09322820037105752, 'fraction_numerical': 0.0, 'mean_word_length': 2.8935018050541514, 'pattern_counts': {'":': 0, '<': 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': '2064719', 'n_tokens_mistral': 656, 'n_tokens_neox': 625, 'n_words': 151}