from atom.ext.crispy_forms.forms import SingleButtonMixin
from braces.forms import UserKwargModelFormMixin
from django import forms

from .models import Case


class CaseForm(SingleButtonMixin, UserKwargModelFormMixin, forms.ModelForm):

    def __init__(self, *args, **kwargs):
        self.monitoring = kwargs.pop('monitoring', None)
        super(CaseForm, self).__init__(*args, **kwargs)

    def save(self, *args, **kwargs):
        if self.monitoring:
            self.instance.monitoring = self.monitoring
        super(CaseForm, self).save(*args, **kwargs)

    class Meta:
        model = Case
        fields = ['name', 'institution']

from atom.ext.crispy_forms.forms import SingleButtonMixin
from braces.forms import UserKwargModelFormMixin
from django import forms

from .models import Case


class CaseForm(SingleButtonMixin, UserKwargModelFormMixin, forms.ModelForm):

    def __init__(self, *args, **kwargs):
        self.monitoring = kwargs.pop('monitoring', None)
        super(CaseForm, self).__init__(*args, **kwargs)
        if self.monitoring:
            self.instance.monitoring = self.monitoring

    class Meta:
        model = Case
        fields = ['name', 'institution']

Clean up form in CaseForm
Clean up form in CaseForm

  from atom.ext.crispy_forms.forms import SingleButtonMixin
  from braces.forms import UserKwargModelFormMixin
  from django import forms
  
  from .models import Case
  
  
  class CaseForm(SingleButtonMixin, UserKwargModelFormMixin, forms.ModelForm):
  
      def __init__(self, *args, **kwargs):
          self.monitoring = kwargs.pop('monitoring', None)
          super(CaseForm, self).__init__(*args, **kwargs)
- 
-     def save(self, *args, **kwargs):
          if self.monitoring:
              self.instance.monitoring = self.monitoring
-         super(CaseForm, self).save(*args, **kwargs)
  
      class Meta:
          model = Case
          fields = ['name', 'institution']
  
Clean up form in CaseForm
## Code Before:
from atom.ext.crispy_forms.forms import SingleButtonMixin
from braces.forms import UserKwargModelFormMixin
from django import forms

from .models import Case


class CaseForm(SingleButtonMixin, UserKwargModelFormMixin, forms.ModelForm):

    def __init__(self, *args, **kwargs):
        self.monitoring = kwargs.pop('monitoring', None)
        super(CaseForm, self).__init__(*args, **kwargs)

    def save(self, *args, **kwargs):
        if self.monitoring:
            self.instance.monitoring = self.monitoring
        super(CaseForm, self).save(*args, **kwargs)

    class Meta:
        model = Case
        fields = ['name', 'institution']

## Instruction:
Clean up form in CaseForm
## Code After:
from atom.ext.crispy_forms.forms import SingleButtonMixin
from braces.forms import UserKwargModelFormMixin
from django import forms

from .models import Case


class CaseForm(SingleButtonMixin, UserKwargModelFormMixin, forms.ModelForm):

    def __init__(self, *args, **kwargs):
        self.monitoring = kwargs.pop('monitoring', None)
        super(CaseForm, self).__init__(*args, **kwargs)
        if self.monitoring:
            self.instance.monitoring = self.monitoring

    class Meta:
        model = Case
        fields = ['name', 'institution']
