prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  EMR release form shows inactive records
  The EMR release model has a column for `is_active`, but it's not being considered when querying the list of EMR releases in the form. 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `atmo/clusters/queries.py`
  Content:
  ```
  1 # This Source Code Form is subject to the terms of the Mozilla Public
  2 # License, v. 2.0. If a copy of the MPL was not distributed with this
  3 # file, you can obtain one at http://mozilla.org/MPL/2.0/.
  4 from django.db import models
  5 
  6 
  7 class EMRReleaseQuerySet(models.QuerySet):
  8 
  9     def stable(self):
  10         return self.filter(
  11             is_experimental=False,
  12             is_deprecated=False,
  13             is_active=True,
  14         )
  15 
  16     def experimental(self):
  17         return self.filter(
  18             is_experimental=True,
  19             is_active=True,
  20         )
  21 
  22     def deprecated(self):
  23         return self.filter(
  24             is_deprecated=True,
  25             is_active=True,
  26         )
  27 
  28 
  29 class ClusterQuerySet(models.QuerySet):
  30 
  31     def active(self):
  32         return self.filter(
  33             most_recent_status__in=self.model.ACTIVE_STATUS_LIST,
  34         )
  35 
  36     def terminated(self):
  37         return self.filter(
  38             most_recent_status__in=self.model.TERMINATED_STATUS_LIST,
  39         )
  40 
  41     def failed(self):
  42         return self.filter(
  43             most_recent_status__in=self.model.FAILED_STATUS_LIST,
  44         )
  45
  ```
  
  Path: `atmo/clusters/forms.py`
  Content:
  ```
  1 # This Source Code Form is subject to the terms of the Mozilla Public
  2 # License, v. 2.0. If a copy of the MPL was not distributed with this
  3 # file, you can obtain one at http://mozilla.org/MPL/2.0/.
  4 from django import forms
  5 from django.conf import settings
  6 from django.core.urlresolvers import reverse
  7 
  8 from . import models
  9 from ..forms.mixins import AutoClassFormMixin, CreatedByModelFormMixin
  10 from ..keys.models import SSHKey
  11 
  12 
  13 class EMRReleaseChoiceField(forms.ModelChoiceField):
  14     def __init__(self, *args, **kwargs):
  15         super().__init__(
  16             label='EMR release',
  17             queryset=models.EMRRelease.objects.all(),
  18             required=True,
  19             empty_label=None,
  20             widget=forms.RadioSelect(attrs={
  21                 'required': 'required',
  22                 'class': 'radioset',
  23             }),
  24             help_text=models.Cluster.EMR_RELEASE_HELP,
  25         )
  26 
  27     def label_from_instance(self, obj):
  28         label = obj.version
  29         extra = []
  30         if obj.is_experimental:
  31             extra.append('experimental')
  32         elif obj.is_deprecated:
  33             extra.append('deprecated')
  34         if extra:
  35             label = '%s (%s)' % (label, ', '.join(extra))
  36         return label
  37 
  38 
  39 class NewClusterForm(AutoClassFormMixin, CreatedByModelFormMixin,
  40                      forms.ModelForm):
  41     prefix = 'new'
  42 
  43     identifier = forms.RegexField(
  44         required=True,
  45         label='Identifier',
  46         regex=r'^[a-z0-9-]{1,100}$',
  47         widget=forms.TextInput(attrs={
  48             'pattern': r'[a-z0-9-]{1,100}',
  49             'data-parsley-pattern-message': 'Identifier contains invalid characters.',
  50         }),
  51         help_text='A unique identifier for your cluster, visible in '
  52                   'the AWS management console. (Lowercase, use hyphens '
  53                   'instead of spaces.)'
  54     )
  55     size = forms.IntegerField(
  56         label='Size',
  57         required=True,
  58         min_value=1,
  59         max_value=settings.AWS_CONFIG['MAX_CLUSTER_SIZE'],
  60         widget=forms.NumberInput(attrs={
  61             'min': '1',
  62             'max': str(settings.AWS_CONFIG['MAX_CLUSTER_SIZE']),
  63         }),
  64         help_text=('Number of workers to use in the cluster, between 1 and %s. '
  65                    'For testing or development 1 is recommended.' %
  66                    settings.AWS_CONFIG['MAX_CLUSTER_SIZE'])
  67     )
  68     lifetime = forms.IntegerField(
  69         label='Lifetime',
  70         required=True,
  71         min_value=2,
  72         max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],
  73         widget=forms.NumberInput(attrs={
  74             'min': '2',
  75             'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),
  76         }),
  77         help_text=('Lifetime in hours after which the cluster is automatically '
  78                    'terminated, between 2 and %s.' %
  79                    settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])
  80     )
  81     ssh_key = forms.ModelChoiceField(
  82         label='SSH key',
  83         queryset=SSHKey.objects.all(),
  84         required=True,
  85         empty_label=None,
  86     )
  87     emr_release = EMRReleaseChoiceField()
  88 
  89     class Meta:
  90         model = models.Cluster
  91         fields = ['identifier', 'size', 'lifetime', 'ssh_key', 'emr_release']
  92 
  93     def __init__(self, *args, **kwargs):
  94         super().__init__(*args, **kwargs)
  95         user_sshkeys = self.created_by.created_sshkeys.all()
  96         self.fields['ssh_key'].queryset = user_sshkeys.all()
  97         self.fields['ssh_key'].help_text = (
  98             'The SSH key to deploy to the cluster. '
  99             'See <a href="%s">your keys</a> or '
  100             '<a href="%s">add a new one</a>.' %
  101             (reverse('keys-list'), reverse('keys-new'))
  102         )
  103         # if there are fewer options we just show radio select buttons
  104         if user_sshkeys.count() <= 6:
  105             self.fields['ssh_key'].widget = forms.RadioSelect(
  106                 choices=self.fields['ssh_key'].choices,
  107                 attrs={
  108                     'class': 'radioset',
  109                 },
  110             )
  111 
  112 
  113 class ExtendClusterForm(AutoClassFormMixin, forms.Form):
  114     prefix = 'extend'
  115     extension = forms.IntegerField(
  116         label='Lifetime extension in hours',
  117         required=True,
  118         min_value=2,
  119         max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],
  120         widget=forms.NumberInput(attrs={
  121             'min': '2',
  122             'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),
  123         }),
  124         help_text=("Number of hours to extend the cluster's lifetime with, between 2 and %s." %
  125                    settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])
  126     )
  127
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/atmo/clusters/forms.py b/atmo/clusters/forms.py
  --- a/atmo/clusters/forms.py
  +++ b/atmo/clusters/forms.py
  @@ -4,6 +4,7 @@
   from django import forms
   from django.conf import settings
   from django.core.urlresolvers import reverse
  +from django.utils.safestring import mark_safe
   
   from . import models
   from ..forms.mixins import AutoClassFormMixin, CreatedByModelFormMixin
  @@ -14,7 +15,7 @@
       def __init__(self, *args, **kwargs):
           super().__init__(
               label='EMR release',
  -            queryset=models.EMRRelease.objects.all(),
  +            queryset=models.EMRRelease.objects.active(),
               required=True,
               empty_label=None,
               widget=forms.RadioSelect(attrs={
  @@ -28,11 +29,11 @@
           label = obj.version
           extra = []
           if obj.is_experimental:
  -            extra.append('experimental')
  +            extra.append('<span class="label label-info">experimental</span>')
           elif obj.is_deprecated:
  -            extra.append('deprecated')
  +            extra.append('<span class="label label-warning">deprecated</span>')
           if extra:
  -            label = '%s (%s)' % (label, ', '.join(extra))
  +            label = mark_safe('%s %s' % (label, ''.join(extra)))
           return label
   
   
  diff --git a/atmo/clusters/queries.py b/atmo/clusters/queries.py
  --- a/atmo/clusters/queries.py
  +++ b/atmo/clusters/queries.py
  @@ -6,6 +6,11 @@
   
   class EMRReleaseQuerySet(models.QuerySet):
   
  +    def active(self):
  +        return self.filter(
  +            is_active=True,
  +        )
  +
       def stable(self):
           return self.filter(
               is_experimental=False,
  
verification_info: {"golden_diff": "diff --git a/atmo/clusters/forms.py b/atmo/clusters/forms.py\n--- a/atmo/clusters/forms.py\n+++ b/atmo/clusters/forms.py\n@@ -4,6 +4,7 @@\n from django import forms\n from django.conf import settings\n from django.core.urlresolvers import reverse\n+from django.utils.safestring import mark_safe\n \n from . import models\n from ..forms.mixins import AutoClassFormMixin, CreatedByModelFormMixin\n@@ -14,7 +15,7 @@\n     def __init__(self, *args, **kwargs):\n         super().__init__(\n             label='EMR release',\n-            queryset=models.EMRRelease.objects.all(),\n+            queryset=models.EMRRelease.objects.active(),\n             required=True,\n             empty_label=None,\n             widget=forms.RadioSelect(attrs={\n@@ -28,11 +29,11 @@\n         label = obj.version\n         extra = []\n         if obj.is_experimental:\n-            extra.append('experimental')\n+            extra.append('<span class=\"label label-info\">experimental</span>')\n         elif obj.is_deprecated:\n-            extra.append('deprecated')\n+            extra.append('<span class=\"label label-warning\">deprecated</span>')\n         if extra:\n-            label = '%s (%s)' % (label, ', '.join(extra))\n+            label = mark_safe('%s %s' % (label, ''.join(extra)))\n         return label\n \n \ndiff --git a/atmo/clusters/queries.py b/atmo/clusters/queries.py\n--- a/atmo/clusters/queries.py\n+++ b/atmo/clusters/queries.py\n@@ -6,6 +6,11 @@\n \n class EMRReleaseQuerySet(models.QuerySet):\n \n+    def active(self):\n+        return self.filter(\n+            is_active=True,\n+        )\n+\n     def stable(self):\n         return self.filter(\n             is_experimental=False,\n", "issue": "EMR release form shows inactive records\nThe EMR release model has a column for `is_active`, but it's not being considered when querying the list of EMR releases in the form. \n", "before_files": [{"content": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, you can obtain one at http://mozilla.org/MPL/2.0/.\nfrom django.db import models\n\n\nclass EMRReleaseQuerySet(models.QuerySet):\n\n    def stable(self):\n        return self.filter(\n            is_experimental=False,\n            is_deprecated=False,\n            is_active=True,\n        )\n\n    def experimental(self):\n        return self.filter(\n            is_experimental=True,\n            is_active=True,\n        )\n\n    def deprecated(self):\n        return self.filter(\n            is_deprecated=True,\n            is_active=True,\n        )\n\n\nclass ClusterQuerySet(models.QuerySet):\n\n    def active(self):\n        return self.filter(\n            most_recent_status__in=self.model.ACTIVE_STATUS_LIST,\n        )\n\n    def terminated(self):\n        return self.filter(\n            most_recent_status__in=self.model.TERMINATED_STATUS_LIST,\n        )\n\n    def failed(self):\n        return self.filter(\n            most_recent_status__in=self.model.FAILED_STATUS_LIST,\n        )\n", "path": "atmo/clusters/queries.py"}, {"content": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, you can obtain one at http://mozilla.org/MPL/2.0/.\nfrom django import forms\nfrom django.conf import settings\nfrom django.core.urlresolvers import reverse\n\nfrom . import models\nfrom ..forms.mixins import AutoClassFormMixin, CreatedByModelFormMixin\nfrom ..keys.models import SSHKey\n\n\nclass EMRReleaseChoiceField(forms.ModelChoiceField):\n    def __init__(self, *args, **kwargs):\n        super().__init__(\n            label='EMR release',\n            queryset=models.EMRRelease.objects.all(),\n            required=True,\n            empty_label=None,\n            widget=forms.RadioSelect(attrs={\n                'required': 'required',\n                'class': 'radioset',\n            }),\n            help_text=models.Cluster.EMR_RELEASE_HELP,\n        )\n\n    def label_from_instance(self, obj):\n        label = obj.version\n        extra = []\n        if obj.is_experimental:\n            extra.append('experimental')\n        elif obj.is_deprecated:\n            extra.append('deprecated')\n        if extra:\n            label = '%s (%s)' % (label, ', '.join(extra))\n        return label\n\n\nclass NewClusterForm(AutoClassFormMixin, CreatedByModelFormMixin,\n                     forms.ModelForm):\n    prefix = 'new'\n\n    identifier = forms.RegexField(\n        required=True,\n        label='Identifier',\n        regex=r'^[a-z0-9-]{1,100}$',\n        widget=forms.TextInput(attrs={\n            'pattern': r'[a-z0-9-]{1,100}',\n            'data-parsley-pattern-message': 'Identifier contains invalid characters.',\n        }),\n        help_text='A unique identifier for your cluster, visible in '\n                  'the AWS management console. (Lowercase, use hyphens '\n                  'instead of spaces.)'\n    )\n    size = forms.IntegerField(\n        label='Size',\n        required=True,\n        min_value=1,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_SIZE'],\n        widget=forms.NumberInput(attrs={\n            'min': '1',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_SIZE']),\n        }),\n        help_text=('Number of workers to use in the cluster, between 1 and %s. '\n                   'For testing or development 1 is recommended.' %\n                   settings.AWS_CONFIG['MAX_CLUSTER_SIZE'])\n    )\n    lifetime = forms.IntegerField(\n        label='Lifetime',\n        required=True,\n        min_value=2,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],\n        widget=forms.NumberInput(attrs={\n            'min': '2',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),\n        }),\n        help_text=('Lifetime in hours after which the cluster is automatically '\n                   'terminated, between 2 and %s.' %\n                   settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])\n    )\n    ssh_key = forms.ModelChoiceField(\n        label='SSH key',\n        queryset=SSHKey.objects.all(),\n        required=True,\n        empty_label=None,\n    )\n    emr_release = EMRReleaseChoiceField()\n\n    class Meta:\n        model = models.Cluster\n        fields = ['identifier', 'size', 'lifetime', 'ssh_key', 'emr_release']\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        user_sshkeys = self.created_by.created_sshkeys.all()\n        self.fields['ssh_key'].queryset = user_sshkeys.all()\n        self.fields['ssh_key'].help_text = (\n            'The SSH key to deploy to the cluster. '\n            'See <a href=\"%s\">your keys</a> or '\n            '<a href=\"%s\">add a new one</a>.' %\n            (reverse('keys-list'), reverse('keys-new'))\n        )\n        # if there are fewer options we just show radio select buttons\n        if user_sshkeys.count() <= 6:\n            self.fields['ssh_key'].widget = forms.RadioSelect(\n                choices=self.fields['ssh_key'].choices,\n                attrs={\n                    'class': 'radioset',\n                },\n            )\n\n\nclass ExtendClusterForm(AutoClassFormMixin, forms.Form):\n    prefix = 'extend'\n    extension = forms.IntegerField(\n        label='Lifetime extension in hours',\n        required=True,\n        min_value=2,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],\n        widget=forms.NumberInput(attrs={\n            'min': '2',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),\n        }),\n        help_text=(\"Number of hours to extend the cluster's lifetime with, between 2 and %s.\" %\n                   settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])\n    )\n", "path": "atmo/clusters/forms.py"}], "after_files": [{"content": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, you can obtain one at http://mozilla.org/MPL/2.0/.\nfrom django.db import models\n\n\nclass EMRReleaseQuerySet(models.QuerySet):\n\n    def active(self):\n        return self.filter(\n            is_active=True,\n        )\n\n    def stable(self):\n        return self.filter(\n            is_experimental=False,\n            is_deprecated=False,\n            is_active=True,\n        )\n\n    def experimental(self):\n        return self.filter(\n            is_experimental=True,\n            is_active=True,\n        )\n\n    def deprecated(self):\n        return self.filter(\n            is_deprecated=True,\n            is_active=True,\n        )\n\n\nclass ClusterQuerySet(models.QuerySet):\n\n    def active(self):\n        return self.filter(\n            most_recent_status__in=self.model.ACTIVE_STATUS_LIST,\n        )\n\n    def terminated(self):\n        return self.filter(\n            most_recent_status__in=self.model.TERMINATED_STATUS_LIST,\n        )\n\n    def failed(self):\n        return self.filter(\n            most_recent_status__in=self.model.FAILED_STATUS_LIST,\n        )\n", "path": "atmo/clusters/queries.py"}, {"content": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, you can obtain one at http://mozilla.org/MPL/2.0/.\nfrom django import forms\nfrom django.conf import settings\nfrom django.core.urlresolvers import reverse\nfrom django.utils.safestring import mark_safe\n\nfrom . import models\nfrom ..forms.mixins import AutoClassFormMixin, CreatedByModelFormMixin\nfrom ..keys.models import SSHKey\n\n\nclass EMRReleaseChoiceField(forms.ModelChoiceField):\n    def __init__(self, *args, **kwargs):\n        super().__init__(\n            label='EMR release',\n            queryset=models.EMRRelease.objects.active(),\n            required=True,\n            empty_label=None,\n            widget=forms.RadioSelect(attrs={\n                'required': 'required',\n                'class': 'radioset',\n            }),\n            help_text=models.Cluster.EMR_RELEASE_HELP,\n        )\n\n    def label_from_instance(self, obj):\n        label = obj.version\n        extra = []\n        if obj.is_experimental:\n            extra.append('<span class=\"label label-info\">experimental</span>')\n        elif obj.is_deprecated:\n            extra.append('<span class=\"label label-warning\">deprecated</span>')\n        if extra:\n            label = mark_safe('%s %s' % (label, ''.join(extra)))\n        return label\n\n\nclass NewClusterForm(AutoClassFormMixin, CreatedByModelFormMixin,\n                     forms.ModelForm):\n    prefix = 'new'\n\n    identifier = forms.RegexField(\n        required=True,\n        label='Identifier',\n        regex=r'^[a-z0-9-]{1,100}$',\n        widget=forms.TextInput(attrs={\n            'pattern': r'[a-z0-9-]{1,100}',\n            'data-parsley-pattern-message': 'Identifier contains invalid characters.',\n        }),\n        help_text='A unique identifier for your cluster, visible in '\n                  'the AWS management console. (Lowercase, use hyphens '\n                  'instead of spaces.)'\n    )\n    size = forms.IntegerField(\n        label='Size',\n        required=True,\n        min_value=1,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_SIZE'],\n        widget=forms.NumberInput(attrs={\n            'min': '1',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_SIZE']),\n        }),\n        help_text=('Number of workers to use in the cluster, between 1 and %s. '\n                   'For testing or development 1 is recommended.' %\n                   settings.AWS_CONFIG['MAX_CLUSTER_SIZE'])\n    )\n    lifetime = forms.IntegerField(\n        label='Lifetime',\n        required=True,\n        min_value=2,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],\n        widget=forms.NumberInput(attrs={\n            'min': '2',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),\n        }),\n        help_text=('Lifetime in hours after which the cluster is automatically '\n                   'terminated, between 2 and %s.' %\n                   settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])\n    )\n    ssh_key = forms.ModelChoiceField(\n        label='SSH key',\n        queryset=SSHKey.objects.all(),\n        required=True,\n        empty_label=None,\n    )\n    emr_release = EMRReleaseChoiceField()\n\n    class Meta:\n        model = models.Cluster\n        fields = ['identifier', 'size', 'lifetime', 'ssh_key', 'emr_release']\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        user_sshkeys = self.created_by.created_sshkeys.all()\n        self.fields['ssh_key'].queryset = user_sshkeys.all()\n        self.fields['ssh_key'].help_text = (\n            'The SSH key to deploy to the cluster. '\n            'See <a href=\"%s\">your keys</a> or '\n            '<a href=\"%s\">add a new one</a>.' %\n            (reverse('keys-list'), reverse('keys-new'))\n        )\n        # if there are fewer options we just show radio select buttons\n        if user_sshkeys.count() <= 6:\n            self.fields['ssh_key'].widget = forms.RadioSelect(\n                choices=self.fields['ssh_key'].choices,\n                attrs={\n                    'class': 'radioset',\n                },\n            )\n\n\nclass ExtendClusterForm(AutoClassFormMixin, forms.Form):\n    prefix = 'extend'\n    extension = forms.IntegerField(\n        label='Lifetime extension in hours',\n        required=True,\n        min_value=2,\n        max_value=settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'],\n        widget=forms.NumberInput(attrs={\n            'min': '2',\n            'max': str(settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME']),\n        }),\n        help_text=(\"Number of hours to extend the cluster's lifetime with, between 2 and %s.\" %\n                   settings.AWS_CONFIG['MAX_CLUSTER_LIFETIME'])\n    )\n", "path": "atmo/clusters/forms.py"}]}