<commit_before>from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
import time
import models


class CssBackgroundPlugIn(CMSPluginBase):
    model = models.CssBackground
    name = 'CSS Background'
    render_template = 'css_background.html'
    raw_id_fields = ('image',)
    fieldsets = (
        (None, {
            'fields': ('bg_type', 'image', ('r', 'g', 'b', 'a')),
        }),
    )

    def render(self, context, instance, placeholder):
        context.update({
            'instance': instance,
            'time': '-'.join([
                str(instance.id),
                str(instance.image.id),
                repr(time.time()).replace('.', '_')]),
        })
        return context

plugin_pool.register_plugin(CssBackgroundPlugIn)<commit_msg>fix #3 Image always is required<commit_after>from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from random import randint
import time
import models


class CssBackgroundPlugIn(CMSPluginBase):
    model = models.CssBackground
    name = 'CSS Background'
    render_template = 'css_background.html'
    raw_id_fields = ('image',)
    fieldsets = (
        (None, {
            'fields': ('bg_type', 'image', ('r', 'g', 'b', 'a')),
        }),
    )

    def render(self, context, instance, placeholder):
        context.update({
            'instance': instance,
            'time': '-'.join([
                str(instance.id),
                str(randint(0, 100000) if not instance.image else instance.image.id),
                repr(time.time()).replace('.', '_')]),
        })
        return context

plugin_pool.register_plugin(CssBackgroundPlugIn)
{'fraction_non_alphanumeric': 0.13448894202032277, 'fraction_numerical': 0.004781829049611476, 'mean_word_length': 2.539112050739958, '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': '2543075', 'n_tokens_mistral': 500, 'n_tokens_neox': 478, 'n_words': 110}