"""Forms for dealing with jobs/posts."""

from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from taggit.models import Tag


class PostFilterForm(forms.Form):
    """Form for filtering the PostListView."""

    title = forms.CharField(required=False)
    is_job_posting = forms.BooleanField(required=False)
    is_freelance = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        super(PostFilterForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Filter'))


class JobSearchForm(forms.Form):
    """Form for filtering the JobListView."""

    search = forms.CharField(required=False)
    tag = forms.ModelChoiceField(queryset=Tag.objects.all())

    def __init__(self, *args, **kwargs):
        super(JobSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Search'))

"""Forms for dealing with jobs/posts."""

from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from taggit.models import Tag


class PostFilterForm(forms.Form):
    """Form for filtering the PostListView."""

    title = forms.CharField(required=False)
    is_job_posting = forms.BooleanField(required=False)
    is_freelance = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        super(PostFilterForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Filter'))


class JobSearchForm(forms.Form):
    """Form for filtering the JobListView."""

    search = forms.CharField(required=False)
    tag = forms.ModelChoiceField(queryset=Tag.objects.all(), required=False)

    def __init__(self, *args, **kwargs):
        super(JobSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Search'))

Tag is not required, of course
Tag is not required, of course

  """Forms for dealing with jobs/posts."""
  
  from django import forms
  
  from crispy_forms.helper import FormHelper
  from crispy_forms.layout import Submit
  from taggit.models import Tag
  
  
  class PostFilterForm(forms.Form):
      """Form for filtering the PostListView."""
  
      title = forms.CharField(required=False)
      is_job_posting = forms.BooleanField(required=False)
      is_freelance = forms.BooleanField(required=False)
  
      def __init__(self, *args, **kwargs):
          super(PostFilterForm, self).__init__(*args, **kwargs)
          self.helper = FormHelper()
          self.helper.form_class = 'form-inline'
          self.helper.form_method = 'get'
          self.helper.add_input(Submit('submit', 'Filter'))
  
  
  class JobSearchForm(forms.Form):
      """Form for filtering the JobListView."""
  
      search = forms.CharField(required=False)
-     tag = forms.ModelChoiceField(queryset=Tag.objects.all())
+     tag = forms.ModelChoiceField(queryset=Tag.objects.all(), required=False)
  
      def __init__(self, *args, **kwargs):
          super(JobSearchForm, self).__init__(*args, **kwargs)
          self.helper = FormHelper()
          self.helper.form_class = 'form-inline'
          self.helper.form_method = 'get'
          self.helper.add_input(Submit('submit', 'Search'))
  
Tag is not required, of course
## Code Before:
"""Forms for dealing with jobs/posts."""

from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from taggit.models import Tag


class PostFilterForm(forms.Form):
    """Form for filtering the PostListView."""

    title = forms.CharField(required=False)
    is_job_posting = forms.BooleanField(required=False)
    is_freelance = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        super(PostFilterForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Filter'))


class JobSearchForm(forms.Form):
    """Form for filtering the JobListView."""

    search = forms.CharField(required=False)
    tag = forms.ModelChoiceField(queryset=Tag.objects.all())

    def __init__(self, *args, **kwargs):
        super(JobSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Search'))

## Instruction:
Tag is not required, of course
## Code After:
"""Forms for dealing with jobs/posts."""

from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from taggit.models import Tag


class PostFilterForm(forms.Form):
    """Form for filtering the PostListView."""

    title = forms.CharField(required=False)
    is_job_posting = forms.BooleanField(required=False)
    is_freelance = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        super(PostFilterForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Filter'))


class JobSearchForm(forms.Form):
    """Form for filtering the JobListView."""

    search = forms.CharField(required=False)
    tag = forms.ModelChoiceField(queryset=Tag.objects.all(), required=False)

    def __init__(self, *args, **kwargs):
        super(JobSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-inline'
        self.helper.form_method = 'get'
        self.helper.add_input(Submit('submit', 'Search'))
