<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django import forms

from core.models import Investigation, Project, ProjectTracking


class TrackProjectForm(forms.ModelForm):
    project = forms.ModelChoiceField(queryset=Project.active_objects.all())

    def save(self, **kwargs):
        commit = kwargs.pop('commit', True)
        user = kwargs.pop('user', None)

        instance = super(TrackProjectForm, self).save(commit=False)
        instance.user = user

        if commit:
            instance.save()

        return instance

    class Meta:
        model = ProjectTracking
        fields = ('project', 'is_owner',)


class CreateProjectForm(forms.ModelForm):

    class Meta:
        model = Project
        fields = ('name', 'description',)

    def clean_name(self):
        name = self.cleaned_data['name']
        reserved_names = [
            'create',
            'track',
        ]
        if name in reserved_names:
            self.add_error('name',
                'Project name "{}" is reserved, please choose another'.format(name))
        return name


class CreateInvestigationForm(forms.ModelForm):

    class Meta:
        model = Investigation
        fields = ('name', 'description',)

    def clean_name(self):
        name = self.cleaned_data['name']
        reserved_names = [
            'activate',
            'deactivate',
            'add-investigation'<commit_msg>Added 'all' to reserved names for project<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django import forms

from core.models import Investigation, Project, ProjectTracking


class TrackProjectForm(forms.ModelForm):
    project = forms.ModelChoiceField(queryset=Project.active_objects.all())

    def save(self, **kwargs):
        commit = kwargs.pop('commit', True)
        user = kwargs.pop('user', None)

        instance = super(TrackProjectForm, self).save(commit=False)
        instance.user = user

        if commit:
            instance.save()

        return instance

    class Meta:
        model = ProjectTracking
        fields = ('project', 'is_owner',)


class CreateProjectForm(forms.ModelForm):

    class Meta:
        model = Project
        fields = ('name', 'description',)

    def clean_name(self):
        name = self.cleaned_data['name']
        reserved_names = [
            'create',
            'track',
            'all'
        ]
        if name in reserved_names:
            self.add_error('name',
                'Project name "{}" is reserved, please choose another'.format(name))
        return name


class CreateInvestigationForm(forms.ModelForm):

    class Meta:
        model = Investigation
        fields = ('name', 'description',)

    def clean_name(self):
        name = self.cleaned_data['name']
        reserved_names = [
            'activate',
            'deactivate',
            'add-investigation'
{'fraction_non_alphanumeric': 0.10856372218476062, 'fraction_numerical': 0.0006743088334457181, 'mean_word_length': 2.3412162162162162, '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': '4771377', 'n_tokens_mistral': 812, 'n_tokens_neox': 777, 'n_words': 196}