We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Adopting a projected as gold user fails
### How to reproduce it

1. sign up as Gold member
1. go to https://readthedocs.org/accounts/gold/subscription/
1. select the project that you want to adopt

### Expected Result

Adopts the project.

###  Actual Result

Fails with a 500.

https://sentry.io/read-the-docs/readthedocs-org/issues/587668658/

### The problem

This line

https://github.com/rtfd/readthedocs.org/blob/44e02def230b937e4eca396864de9fc81f4ef33f/readthedocs/gold/views.py#L109

cause the problem since we are receiving a "project name" and using it as "project slug".

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `readthedocs/gold/forms.py`
Content:
```
1 """Gold subscription forms."""
2 
3 from __future__ import absolute_import
4 
5 from builtins import object
6 from django import forms
7 
8 from readthedocs.payments.forms import StripeModelForm, StripeResourceMixin
9 
10 from .models import LEVEL_CHOICES, GoldUser
11 
12 
13 class GoldSubscriptionForm(StripeResourceMixin, StripeModelForm):
14 
15     """
16     Gold subscription payment form.
17 
18     This extends the common base form for handling Stripe subscriptions. Credit
19     card fields for card number, expiry, and CVV are extended from
20     :py:class:`StripeModelForm`, with additional methods from
21     :py:class:`StripeResourceMixin` for common operations against the Stripe API.
22     """
23 
24     class Meta(object):
25         model = GoldUser
26         fields = ['last_4_card_digits', 'level']
27 
28     last_4_card_digits = forms.CharField(
29         required=True,
30         min_length=4,
31         max_length=4,
32         widget=forms.HiddenInput(attrs={
33             'data-bind': 'valueInit: last_4_card_digits, value: last_4_card_digits',
34         })
35     )
36 
37     level = forms.ChoiceField(
38         required=True,
39         choices=LEVEL_CHOICES,
40     )
41 
42     def clean(self):
43         self.instance.user = self.customer
44         return super(GoldSubscriptionForm, self).clean()
45 
46     def validate_stripe(self):
47         subscription = self.get_subscription()
48         self.instance.stripe_id = subscription.customer
49         self.instance.subscribed = True
50 
51     def get_customer_kwargs(self):
52         return {
53             'description': self.customer.get_full_name() or self.customer.username,
54             'email': self.customer.email,
55             'id': self.instance.stripe_id or None
56         }
57 
58     def get_subscription(self):
59         customer = self.get_customer()
60 
61         # TODO get the first subscription more intelligently
62         subscriptions = customer.subscriptions.all(limit=5)
63         if subscriptions.data:
64             # Update an existing subscription - Stripe prorates by default
65             subscription = subscriptions.data[0]
66             subscription.plan = self.cleaned_data['level']
67             if 'stripe_token' in self.cleaned_data and self.cleaned_data['stripe_token']:
68                 # Optionally update the card
69                 subscription.source = self.cleaned_data['stripe_token']
70             subscription.save()
71         else:
72             # Add a new subscription
73             subscription = customer.subscriptions.create(
74                 plan=self.cleaned_data['level'],
75                 source=self.cleaned_data['stripe_token']
76             )
77 
78         return subscription
79 
80 
81 class GoldProjectForm(forms.Form):
82     project = forms.CharField(
83         required=True,
84     )
85 
86     def __init__(self, *args, **kwargs):
87         self.user = kwargs.pop('user', None)
88         self.projects = kwargs.pop('projects', None)
89         super(GoldProjectForm, self).__init__(*args, **kwargs)
90 
91     def clean(self):
92         cleaned_data = super(GoldProjectForm, self).clean()
93         if self.projects.count() < self.user.num_supported_projects:
94             return cleaned_data
95 
96         self.add_error(None, 'You already have the max number of supported projects.')
97
```
--- 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()

```

diff --git a/readthedocs/gold/forms.py b/readthedocs/gold/forms.py
--- a/readthedocs/gold/forms.py
+++ b/readthedocs/gold/forms.py
@@ -5,7 +5,10 @@
 from builtins import object
 from django import forms
 
+from django.utils.translation import ugettext_lazy as _
+
 from readthedocs.payments.forms import StripeModelForm, StripeResourceMixin
+from readthedocs.projects.models import Project
 
 from .models import LEVEL_CHOICES, GoldUser
 
@@ -88,6 +91,14 @@
         self.projects = kwargs.pop('projects', None)
         super(GoldProjectForm, self).__init__(*args, **kwargs)
 
+    def clean_project(self):
+        project_slug = self.cleaned_data.get('project', '')
+        project_instance = Project.objects.filter(slug=project_slug)
+        if not project_instance.exists():
+            raise forms.ValidationError(_('No project found.'))
+        else:
+            return project_slug
+
     def clean(self):
         cleaned_data = super(GoldProjectForm, self).clean()
         if self.projects.count() < self.user.num_supported_projects:

{"golden_diff": "diff --git a/readthedocs/gold/forms.py b/readthedocs/gold/forms.py\n--- a/readthedocs/gold/forms.py\n+++ b/readthedocs/gold/forms.py\n@@ -5,7 +5,10 @@\n from builtins import object\n from django import forms\n \n+from django.utils.translation import ugettext_lazy as _\n+\n from readthedocs.payments.forms import StripeModelForm, StripeResourceMixin\n+from readthedocs.projects.models import Project\n \n from .models import LEVEL_CHOICES, GoldUser\n \n@@ -88,6 +91,14 @@\n         self.projects = kwargs.pop('projects', None)\n         super(GoldProjectForm, self).__init__(*args, **kwargs)\n \n+    def clean_project(self):\n+        project_slug = self.cleaned_data.get('project', '')\n+        project_instance = Project.objects.filter(slug=project_slug)\n+        if not project_instance.exists():\n+            raise forms.ValidationError(_('No project found.'))\n+        else:\n+            return project_slug\n+\n     def clean(self):\n         cleaned_data = super(GoldProjectForm, self).clean()\n         if self.projects.count() < self.user.num_supported_projects:\n", "issue": "Adopting a projected as gold user fails\n### How to reproduce it\r\n\r\n1. sign up as Gold member\r\n1. go to https://readthedocs.org/accounts/gold/subscription/\r\n1. select the project that you want to adopt\r\n\r\n### Expected Result\r\n\r\nAdopts the project.\r\n\r\n###  Actual Result\r\n\r\nFails with a 500.\r\n\r\nhttps://sentry.io/read-the-docs/readthedocs-org/issues/587668658/\r\n\r\n### The problem\r\n\r\nThis line\r\n\r\nhttps://github.com/rtfd/readthedocs.org/blob/44e02def230b937e4eca396864de9fc81f4ef33f/readthedocs/gold/views.py#L109\r\n\r\ncause the problem since we are receiving a \"project name\" and using it as \"project slug\".\n", "before_files": [{"content": "\"\"\"Gold subscription forms.\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom builtins import object\nfrom django import forms\n\nfrom readthedocs.payments.forms import StripeModelForm, StripeResourceMixin\n\nfrom .models import LEVEL_CHOICES, GoldUser\n\n\nclass GoldSubscriptionForm(StripeResourceMixin, StripeModelForm):\n\n    \"\"\"\n    Gold subscription payment form.\n\n    This extends the common base form for handling Stripe subscriptions. Credit\n    card fields for card number, expiry, and CVV are extended from\n    :py:class:`StripeModelForm`, with additional methods from\n    :py:class:`StripeResourceMixin` for common operations against the Stripe API.\n    \"\"\"\n\n    class Meta(object):\n        model = GoldUser\n        fields = ['last_4_card_digits', 'level']\n\n    last_4_card_digits = forms.CharField(\n        required=True,\n        min_length=4,\n        max_length=4,\n        widget=forms.HiddenInput(attrs={\n            'data-bind': 'valueInit: last_4_card_digits, value: last_4_card_digits',\n        })\n    )\n\n    level = forms.ChoiceField(\n        required=True,\n        choices=LEVEL_CHOICES,\n    )\n\n    def clean(self):\n        self.instance.user = self.customer\n        return super(GoldSubscriptionForm, self).clean()\n\n    def validate_stripe(self):\n        subscription = self.get_subscription()\n        self.instance.stripe_id = subscription.customer\n        self.instance.subscribed = True\n\n    def get_customer_kwargs(self):\n        return {\n            'description': self.customer.get_full_name() or self.customer.username,\n            'email': self.customer.email,\n            'id': self.instance.stripe_id or None\n        }\n\n    def get_subscription(self):\n        customer = self.get_customer()\n\n        # TODO get the first subscription more intelligently\n        subscriptions = customer.subscriptions.all(limit=5)\n        if subscriptions.data:\n            # Update an existing subscription - Stripe prorates by default\n            subscription = subscriptions.data[0]\n            subscription.plan = self.cleaned_data['level']\n            if 'stripe_token' in self.cleaned_data and self.cleaned_data['stripe_token']:\n                # Optionally update the card\n                subscription.source = self.cleaned_data['stripe_token']\n            subscription.save()\n        else:\n            # Add a new subscription\n            subscription = customer.subscriptions.create(\n                plan=self.cleaned_data['level'],\n                source=self.cleaned_data['stripe_token']\n            )\n\n        return subscription\n\n\nclass GoldProjectForm(forms.Form):\n    project = forms.CharField(\n        required=True,\n    )\n\n    def __init__(self, *args, **kwargs):\n        self.user = kwargs.pop('user', None)\n        self.projects = kwargs.pop('projects', None)\n        super(GoldProjectForm, self).__init__(*args, **kwargs)\n\n    def clean(self):\n        cleaned_data = super(GoldProjectForm, self).clean()\n        if self.projects.count() < self.user.num_supported_projects:\n            return cleaned_data\n\n        self.add_error(None, 'You already have the max number of supported projects.')\n", "path": "readthedocs/gold/forms.py"}], "after_files": [{"content": "\"\"\"Gold subscription forms.\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom builtins import object\nfrom django import forms\n\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom readthedocs.payments.forms import StripeModelForm, StripeResourceMixin\nfrom readthedocs.projects.models import Project\n\nfrom .models import LEVEL_CHOICES, GoldUser\n\n\nclass GoldSubscriptionForm(StripeResourceMixin, StripeModelForm):\n\n    \"\"\"\n    Gold subscription payment form.\n\n    This extends the common base form for handling Stripe subscriptions. Credit\n    card fields for card number, expiry, and CVV are extended from\n    :py:class:`StripeModelForm`, with additional methods from\n    :py:class:`StripeResourceMixin` for common operations against the Stripe API.\n    \"\"\"\n\n    class Meta(object):\n        model = GoldUser\n        fields = ['last_4_card_digits', 'level']\n\n    last_4_card_digits = forms.CharField(\n        required=True,\n        min_length=4,\n        max_length=4,\n        widget=forms.HiddenInput(attrs={\n            'data-bind': 'valueInit: last_4_card_digits, value: last_4_card_digits',\n        })\n    )\n\n    level = forms.ChoiceField(\n        required=True,\n        choices=LEVEL_CHOICES,\n    )\n\n    def clean(self):\n        self.instance.user = self.customer\n        return super(GoldSubscriptionForm, self).clean()\n\n    def validate_stripe(self):\n        subscription = self.get_subscription()\n        self.instance.stripe_id = subscription.customer\n        self.instance.subscribed = True\n\n    def get_customer_kwargs(self):\n        return {\n            'description': self.customer.get_full_name() or self.customer.username,\n            'email': self.customer.email,\n            'id': self.instance.stripe_id or None\n        }\n\n    def get_subscription(self):\n        customer = self.get_customer()\n\n        # TODO get the first subscription more intelligently\n        subscriptions = customer.subscriptions.all(limit=5)\n        if subscriptions.data:\n            # Update an existing subscription - Stripe prorates by default\n            subscription = subscriptions.data[0]\n            subscription.plan = self.cleaned_data['level']\n            if 'stripe_token' in self.cleaned_data and self.cleaned_data['stripe_token']:\n                # Optionally update the card\n                subscription.source = self.cleaned_data['stripe_token']\n            subscription.save()\n        else:\n            # Add a new subscription\n            subscription = customer.subscriptions.create(\n                plan=self.cleaned_data['level'],\n                source=self.cleaned_data['stripe_token']\n            )\n\n        return subscription\n\n\nclass GoldProjectForm(forms.Form):\n    project = forms.CharField(\n        required=True,\n    )\n\n    def __init__(self, *args, **kwargs):\n        self.user = kwargs.pop('user', None)\n        self.projects = kwargs.pop('projects', None)\n        super(GoldProjectForm, self).__init__(*args, **kwargs)\n\n    def clean_project(self):\n        project_slug = self.cleaned_data.get('project', '')\n        project_instance = Project.objects.filter(slug=project_slug)\n        if not project_instance.exists():\n            raise forms.ValidationError(_('No project found.'))\n        else:\n            return project_slug\n\n    def clean(self):\n        cleaned_data = super(GoldProjectForm, self).clean()\n        if self.projects.count() < self.user.num_supported_projects:\n            return cleaned_data\n\n        self.add_error(None, 'You already have the max number of supported projects.')\n", "path": "readthedocs/gold/forms.py"}]}