<commit_before>from zeit.cms.content.browser.form import CommonMetadataFormBase
from zeit.cms.i18n import MessageFactory as _
import copy
import gocept.form.grouped
import zeit.cms.related.interfaces
import zeit.cms.workflow.interfaces
import zeit.content.video.interfaces
import zeit.push.browser.form
import zope.dublincore.interfaces
import zope.formlib.form
import zope.formlib.form


class Base(zeit.push.browser.form.SocialBase):

    form_fields = zope.formlib.form.FormFields(
        zeit.content.video.interfaces.IVideo,
        zeit.cms.related.interfaces.IRelatedContent,
        zeit.cms.workflow.interfaces.IPublishInfo,
        zope.dublincore.interfaces.IDCTimes,
        render_context=zope.formlib.interfaces.DISPLAY_UNWRITEABLE
    ).select(
        'supertitle', 'title', 'subtitle', 'teaserText',
        'product', 'ressort', 'keywords', 'serie',
        'dailyNewsletter', 'banner', 'banner_id',
        'breaking_news', 'has_recensions', 'commentsAllowed',
        'commentsPremoderate', 'related', 'channels', 'lead_candidate',
        'video_still_copyright',
        # remaining:
        '__name__',
        'created', 'date_first_released', 'modified', 'expires',
        'thumbnail', 'video_still', 'flv_url', 'authorships')

    social_fields = copy.copy(zeit.push.browser.form.SocialBase.social_fields)

    field_groups = (
        gocept.form.grouped.Fields(
            _("Texts"),
            ('supertitle', 'title', 'teaserText', 'video_still_copyright'),
            css_class='wide-widgets column-left'),
        gocept.form.grouped.Fields(
            _("Navigation"),
            ('product', 'ressort', 'keywords', 'serie'),
            css_class='column-right'),
        gocept.form.grouped.Fields(
            _("Options"),
            ('dailyNewsletter', 'banner', 'banner_id',
             'breaking_news', 'has_recensions', 'commentsAllowed',
             'commentsPremoderate'),
            css_class='column-right checkboxes'),
        social_fields,
        CommonMetadataFormBase.auto_cp_fields,
        gocept.form.grouped.Fields(
            _('Teaser elements'),
            ('related',),
            css_class='wide-widgets column-left'),
        gocept.form.grouped.RemainingFields(
            '', css_class='column-left'),
    )


class Edit(Base, zeit.cms.browser.form.EditForm):

    title = _('Video')

    @zope.formlib.form.action(
        _('Apply'), condition=zope.formlib.form.haveInputWidgets)
    def handle_edit_action(self, action, data):
        self.applyAccountData(self.context, data)
        super(Edit, self).handle_edit_action.success(data)

<commit_msg>ZON-3917: No need to copy if we don't modify (belongs to commit:6ddde9e)<commit_after>from zeit.cms.content.browser.form import CommonMetadataFormBase
from zeit.cms.i18n import MessageFactory as _
import gocept.form.grouped
import zeit.cms.related.interfaces
import zeit.cms.workflow.interfaces
import zeit.content.video.interfaces
import zeit.push.browser.form
import zope.dublincore.interfaces
import zope.formlib.form
import zope.formlib.form


class Base(zeit.push.browser.form.SocialBase):

    form_fields = zope.formlib.form.FormFields(
        zeit.content.video.interfaces.IVideo,
        zeit.cms.related.interfaces.IRelatedContent,
        zeit.cms.workflow.interfaces.IPublishInfo,
        zope.dublincore.interfaces.IDCTimes,
        render_context=zope.formlib.interfaces.DISPLAY_UNWRITEABLE
    ).select(
        'supertitle', 'title', 'subtitle', 'teaserText',
        'product', 'ressort', 'keywords', 'serie',
        'dailyNewsletter', 'banner', 'banner_id',
        'breaking_news', 'has_recensions', 'commentsAllowed',
        'commentsPremoderate', 'related', 'channels', 'lead_candidate',
        'video_still_copyright',
        # remaining:
        '__name__',
        'created', 'date_first_released', 'modified', 'expires',
        'thumbnail', 'video_still', 'flv_url', 'authorships')

    field_groups = (
        gocept.form.grouped.Fields(
            _("Texts"),
            ('supertitle', 'title', 'teaserText', 'video_still_copyright'),
            css_class='wide-widgets column-left'),
        gocept.form.grouped.Fields(
            _("Navigation"),
            ('product', 'ressort', 'keywords', 'serie'),
            css_class='column-right'),
        gocept.form.grouped.Fields(
            _("Options"),
            ('dailyNewsletter', 'banner', 'banner_id',
             'breaking_news', 'has_recensions', 'commentsAllowed',
             'commentsPremoderate'),
            css_class='column-right checkboxes'),
        zeit.push.browser.form.SocialBase.social_fields,
        CommonMetadataFormBase.auto_cp_fields,
        gocept.form.grouped.Fields(
            _('Teaser elements'),
            ('related',),
            css_class='wide-widgets column-left'),
        gocept.form.grouped.RemainingFields(
            '', css_class='column-left'),
    )


class Edit(Base, zeit.cms.browser.form.EditForm):

    title = _('Video')

    @zope.formlib.form.action(
        _('Apply'), condition=zope.formlib.form.haveInputWidgets)
    def handle_edit_action(self, action, data):
        self.applyAccountData(self.context, data)
        super(Edit, self).handle_edit_action.success(data)


{'fraction_non_alphanumeric': 0.13158395132154402, 'fraction_numerical': 0.0019015021867275148, 'mean_word_length': 3.046153846153846, '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': '1069452', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1603, 'n_words': 249}