<commit_before>import uuid
import re

from django import forms
from django.conf import settings
from django.utils.text import slugify

from ..users.models import User
from .models import VirtualMachine
from .helpers import call_api


class VirtualMachineForm(forms.ModelForm):
    name = forms.CharField(max_length=32, widget=forms.TextInput(attrs={"class": "form-control"}))
    description = forms.CharField(widget=forms.TextInput(attrs={"class": "form-control"}), required=False)
    users = forms.ModelMultipleChoiceField(required=False, queryset=User.objects.filter(service=False))

    class Meta:
        model = VirtualMachine
        fields = ["name", "description", "users"]


    def save(self, commit=True):
        instance = forms.ModelForm.save(self, commit=False)

        if commit:
            instance.save()
            ret = call_api("container.create", name=str(instance.uuid))
            if ret[0] == 1:
                instance.delete()
                return None<commit_msg>save manytomany<commit_after>import uuid
import re

from django import forms
from django.conf import settings
from django.utils.text import slugify

from ..users.models import User
from .models import VirtualMachine
from .helpers import call_api


class VirtualMachineForm(forms.ModelForm):
    name = forms.CharField(max_length=32, widget=forms.TextInput(attrs={"class": "form-control"}))
    description = forms.CharField(widget=forms.TextInput(attrs={"class": "form-control"}), required=False)
    users = forms.ModelMultipleChoiceField(required=False, queryset=User.objects.filter(service=False))

    class Meta:
        model = VirtualMachine
        fields = ["name", "description", "users"]


    def save(self, commit=True):
        instance = forms.ModelForm.save(self, commit=False)

        if commit:
            instance.save()
            instance.save_m2m()
            ret = call_api("container.create", name=str(instance.uuid))
            if ret[0] == 1:
                instance.delete()
                return None
{'fraction_non_alphanumeric': 0.112475442043222, 'fraction_numerical': 0.0044204322200392925, 'mean_word_length': 3.3525641025641026, 'pattern_counts': {'":': 4, '<': 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': '884814', 'n_tokens_mistral': 568, 'n_tokens_neox': 549, 'n_words': 135}