<commit_before># coding: utf-8

from __future__ import unicode_literals
from django.forms import ModelForm, BooleanField
from mptt.forms import MPTTAdminForm
from tinymce.widgets import TinyMCE
from .models import DossierDEvenements


class DossierDEvenementsForm(MPTTAdminForm):
    statique = BooleanField(required=False)

    class Meta(object):
        model = DossierDEvenements
        widgets = {
            'contenu': TinyMCE,
        }

    class Media(object):
        css = {
            'all': ('css/custom_admin.css',),
        }

    def __init__(self, *args, **kwargs):
        if 'instance' in kwargs:
            initial = kwargs.get('initial', {})
            initial['statique'] = kwargs['instance'].evenements.exists()
            kwargs['initial'] = initial
        super(DossierDEvenementsForm, self).__init__(*args, **kwargs)

    def clean(self):
        cleaned_data = super(DossierDEvenementsForm, self).clean()
        if cleaned_data['statique']:
            cleaned_data['evenements'] = self.instance.get_queryset()
            self.instance.evenements.add(*cleaned_data['evenements'])
            for k in ('debut', 'fin', 'lieux', 'oeuvres', 'auteurs',
                      'circonstance'):
                del cleaned_data[k]
        return cleaned_data
<commit_msg>Retire un bout de code inutile.<commit_after># coding: utf-8

from __future__ import unicode_literals
from django.forms import ModelForm, BooleanField
from mptt.forms import MPTTAdminForm
from tinymce.widgets import TinyMCE
from .models import DossierDEvenements


class DossierDEvenementsForm(MPTTAdminForm):
    statique = BooleanField(required=False)

    class Meta(object):
        model = DossierDEvenements
        widgets = {
            'contenu': TinyMCE,
        }

    class Media(object):
        css = {
            'all': ('css/custom_admin.css',),
        }

    def __init__(self, *args, **kwargs):
        if 'instance' in kwargs:
            initial = kwargs.get('initial', {})
            initial['statique'] = kwargs['instance'].evenements.exists()
            kwargs['initial'] = initial
        super(DossierDEvenementsForm, self).__init__(*args, **kwargs)

    def clean(self):
        cleaned_data = super(DossierDEvenementsForm, self).clean()
        if cleaned_data['statique']:
            cleaned_data['evenements'] = self.instance.get_queryset()
            self.instance.evenements.add(*cleaned_data['evenements'])
        return cleaned_data

{'fraction_non_alphanumeric': 0.1127728375101051, 'fraction_numerical': 0.0008084074373484236, 'mean_word_length': 2.8076923076923075, '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': '608898', 'n_tokens_mistral': 732, 'n_tokens_neox': 710, 'n_words': 154}