We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Contributors missing in editor evaluation edit form
When editing an evaluation as an editor, contributors who have already been added (by managers) and who are marked as inactive or proxy users are not shown in the form anymore because they are not included in the contributor queryset. This leads to errors when saving the form.
The queryset should always include those people already added as contributors for this evaluation.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `evap/contributor/forms.py`
Content:
```
1 from datetime import datetime, timedelta
2 import logging
3 
4 from django import forms
5 from django.conf import settings
6 from django.db.models import Q
7 from django.forms.widgets import CheckboxSelectMultiple
8 from django.utils.translation import ugettext_lazy as _
9 from evap.evaluation.forms import UserModelMultipleChoiceField, UserModelChoiceField
10 from evap.evaluation.models import Course, Evaluation, Questionnaire, UserProfile
11 from evap.evaluation.tools import date_to_datetime
12 from evap.staff.forms import ContributionForm
13 
14 logger = logging.getLogger(__name__)
15 
16 
17 class EvaluationForm(forms.ModelForm):
18     general_questionnaires = forms.ModelMultipleChoiceField(queryset=None, widget=CheckboxSelectMultiple, label=_("General questionnaires"))
19     course = forms.ModelChoiceField(Course.objects.all(), disabled=True, required=False, widget=forms.HiddenInput())
20     name_de_field = forms.CharField(label=_("Name (German)"), disabled=True, required=False)
21     name_en_field = forms.CharField(label=_("Name (English)"), disabled=True, required=False)
22 
23     class Meta:
24         model = Evaluation
25         fields = ('name_de_field', 'name_en_field', 'vote_start_datetime', 'vote_end_date', 'general_questionnaires', 'course')
26 
27     def __init__(self, *args, **kwargs):
28         super().__init__(*args, **kwargs)
29 
30         self.fields['name_de_field'].initial = self.instance.full_name_de
31         self.fields['name_en_field'].initial = self.instance.full_name_en
32 
33         self.fields['general_questionnaires'].queryset = Questionnaire.objects.general_questionnaires().filter(
34             Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.instance)).distinct()
35 
36         self.fields['vote_start_datetime'].localize = True
37         self.fields['vote_end_date'].localize = True
38 
39         if self.instance.general_contribution:
40             self.fields['general_questionnaires'].initial = [q.pk for q in self.instance.general_contribution.questionnaires.all()]
41 
42     def clean(self):
43         super().clean()
44 
45         vote_start_datetime = self.cleaned_data.get('vote_start_datetime')
46         vote_end_date = self.cleaned_data.get('vote_end_date')
47         if vote_start_datetime and vote_end_date:
48             if vote_start_datetime.date() > vote_end_date:
49                 self.add_error("vote_start_datetime", "")
50                 self.add_error("vote_end_date", _("The first day of evaluation must be before the last one."))
51 
52     def clean_vote_end_date(self):
53         vote_end_date = self.cleaned_data.get('vote_end_date')
54 
55         # The actual deadline is EVALUATION_END_OFFSET_HOURS:00 AM of the day after vote_end_date.
56         # Therefore an evaluation date 24h + EVALUATION_END_OFFSET_HOURS in the past would technically still be in the future.
57         if vote_end_date and date_to_datetime(vote_end_date) + timedelta(hours=24 + settings.EVALUATION_END_OFFSET_HOURS) < datetime.now():
58             raise forms.ValidationError(_("The last day of evaluation must be in the future."))
59         return vote_end_date
60 
61     def save(self, *args, **kw):
62         evaluation = super().save(*args, **kw)
63         evaluation.general_contribution.questionnaires.set(self.cleaned_data.get('general_questionnaires'))
64         return evaluation
65 
66 
67 class EditorContributionForm(ContributionForm):
68     def __init__(self, *args, **kwargs):
69         super().__init__(*args, **kwargs)
70 
71         self.fields['questionnaires'].queryset = Questionnaire.objects.contributor_questionnaires().filter(
72             Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.evaluation)).distinct()
73         self.fields['contributor'].queryset = UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True)
74 
75 
76 class DelegatesForm(forms.ModelForm):
77     delegates = UserModelMultipleChoiceField(queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True),
78                                              required=False)
79 
80     class Meta:
81         model = UserProfile
82         fields = ('delegates',)
83         field_classes = {
84             'delegates': UserModelMultipleChoiceField,
85         }
86 
87     def __init__(self, *args, **kwargs):
88         super().__init__(*args, **kwargs)
89 
90     def save(self, *args, **kw):
91         super().save(*args, **kw)
92         logger.info('User "{}" edited the settings.'.format(self.instance.username))
93 
94 
95 class DelegateSelectionForm(forms.Form):
96     delegate_to = UserModelChoiceField(label=_("Delegate to"),
97                                        queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True))
98
```
--- 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/evap/contributor/forms.py b/evap/contributor/forms.py
--- a/evap/contributor/forms.py
+++ b/evap/contributor/forms.py
@@ -68,9 +68,13 @@
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
+        existing_contributor_pk = self.instance.contributor.pk if self.instance.contributor else None
+
         self.fields['questionnaires'].queryset = Questionnaire.objects.contributor_questionnaires().filter(
             Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.evaluation)).distinct()
-        self.fields['contributor'].queryset = UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True)
+        self.fields['contributor'].queryset = UserProfile.objects.filter(
+            (Q(is_active=True) & Q(is_proxy_user=False)) | Q(pk=existing_contributor_pk)
+        )
 
 
 class DelegatesForm(forms.ModelForm):

{"golden_diff": "diff --git a/evap/contributor/forms.py b/evap/contributor/forms.py\n--- a/evap/contributor/forms.py\n+++ b/evap/contributor/forms.py\n@@ -68,9 +68,13 @@\n     def __init__(self, *args, **kwargs):\n         super().__init__(*args, **kwargs)\n \n+        existing_contributor_pk = self.instance.contributor.pk if self.instance.contributor else None\n+\n         self.fields['questionnaires'].queryset = Questionnaire.objects.contributor_questionnaires().filter(\n             Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.evaluation)).distinct()\n-        self.fields['contributor'].queryset = UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True)\n+        self.fields['contributor'].queryset = UserProfile.objects.filter(\n+            (Q(is_active=True) & Q(is_proxy_user=False)) | Q(pk=existing_contributor_pk)\n+        )\n \n \n class DelegatesForm(forms.ModelForm):\n", "issue": "Contributors missing in editor evaluation edit form\nWhen editing an evaluation as an editor, contributors who have already been added (by managers) and who are marked as inactive or proxy users are not shown in the form anymore because they are not included in the contributor queryset. This leads to errors when saving the form.\r\nThe queryset should always include those people already added as contributors for this evaluation.\n", "before_files": [{"content": "from datetime import datetime, timedelta\nimport logging\n\nfrom django import forms\nfrom django.conf import settings\nfrom django.db.models import Q\nfrom django.forms.widgets import CheckboxSelectMultiple\nfrom django.utils.translation import ugettext_lazy as _\nfrom evap.evaluation.forms import UserModelMultipleChoiceField, UserModelChoiceField\nfrom evap.evaluation.models import Course, Evaluation, Questionnaire, UserProfile\nfrom evap.evaluation.tools import date_to_datetime\nfrom evap.staff.forms import ContributionForm\n\nlogger = logging.getLogger(__name__)\n\n\nclass EvaluationForm(forms.ModelForm):\n    general_questionnaires = forms.ModelMultipleChoiceField(queryset=None, widget=CheckboxSelectMultiple, label=_(\"General questionnaires\"))\n    course = forms.ModelChoiceField(Course.objects.all(), disabled=True, required=False, widget=forms.HiddenInput())\n    name_de_field = forms.CharField(label=_(\"Name (German)\"), disabled=True, required=False)\n    name_en_field = forms.CharField(label=_(\"Name (English)\"), disabled=True, required=False)\n\n    class Meta:\n        model = Evaluation\n        fields = ('name_de_field', 'name_en_field', 'vote_start_datetime', 'vote_end_date', 'general_questionnaires', 'course')\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self.fields['name_de_field'].initial = self.instance.full_name_de\n        self.fields['name_en_field'].initial = self.instance.full_name_en\n\n        self.fields['general_questionnaires'].queryset = Questionnaire.objects.general_questionnaires().filter(\n            Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.instance)).distinct()\n\n        self.fields['vote_start_datetime'].localize = True\n        self.fields['vote_end_date'].localize = True\n\n        if self.instance.general_contribution:\n            self.fields['general_questionnaires'].initial = [q.pk for q in self.instance.general_contribution.questionnaires.all()]\n\n    def clean(self):\n        super().clean()\n\n        vote_start_datetime = self.cleaned_data.get('vote_start_datetime')\n        vote_end_date = self.cleaned_data.get('vote_end_date')\n        if vote_start_datetime and vote_end_date:\n            if vote_start_datetime.date() > vote_end_date:\n                self.add_error(\"vote_start_datetime\", \"\")\n                self.add_error(\"vote_end_date\", _(\"The first day of evaluation must be before the last one.\"))\n\n    def clean_vote_end_date(self):\n        vote_end_date = self.cleaned_data.get('vote_end_date')\n\n        # The actual deadline is EVALUATION_END_OFFSET_HOURS:00 AM of the day after vote_end_date.\n        # Therefore an evaluation date 24h + EVALUATION_END_OFFSET_HOURS in the past would technically still be in the future.\n        if vote_end_date and date_to_datetime(vote_end_date) + timedelta(hours=24 + settings.EVALUATION_END_OFFSET_HOURS) < datetime.now():\n            raise forms.ValidationError(_(\"The last day of evaluation must be in the future.\"))\n        return vote_end_date\n\n    def save(self, *args, **kw):\n        evaluation = super().save(*args, **kw)\n        evaluation.general_contribution.questionnaires.set(self.cleaned_data.get('general_questionnaires'))\n        return evaluation\n\n\nclass EditorContributionForm(ContributionForm):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self.fields['questionnaires'].queryset = Questionnaire.objects.contributor_questionnaires().filter(\n            Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.evaluation)).distinct()\n        self.fields['contributor'].queryset = UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True)\n\n\nclass DelegatesForm(forms.ModelForm):\n    delegates = UserModelMultipleChoiceField(queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True),\n                                             required=False)\n\n    class Meta:\n        model = UserProfile\n        fields = ('delegates',)\n        field_classes = {\n            'delegates': UserModelMultipleChoiceField,\n        }\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n    def save(self, *args, **kw):\n        super().save(*args, **kw)\n        logger.info('User \"{}\" edited the settings.'.format(self.instance.username))\n\n\nclass DelegateSelectionForm(forms.Form):\n    delegate_to = UserModelChoiceField(label=_(\"Delegate to\"),\n                                       queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True))\n", "path": "evap/contributor/forms.py"}], "after_files": [{"content": "from datetime import datetime, timedelta\nimport logging\n\nfrom django import forms\nfrom django.conf import settings\nfrom django.db.models import Q\nfrom django.forms.widgets import CheckboxSelectMultiple\nfrom django.utils.translation import ugettext_lazy as _\nfrom evap.evaluation.forms import UserModelMultipleChoiceField, UserModelChoiceField\nfrom evap.evaluation.models import Course, Evaluation, Questionnaire, UserProfile\nfrom evap.evaluation.tools import date_to_datetime\nfrom evap.staff.forms import ContributionForm\n\nlogger = logging.getLogger(__name__)\n\n\nclass EvaluationForm(forms.ModelForm):\n    general_questionnaires = forms.ModelMultipleChoiceField(queryset=None, widget=CheckboxSelectMultiple, label=_(\"General questionnaires\"))\n    course = forms.ModelChoiceField(Course.objects.all(), disabled=True, required=False, widget=forms.HiddenInput())\n    name_de_field = forms.CharField(label=_(\"Name (German)\"), disabled=True, required=False)\n    name_en_field = forms.CharField(label=_(\"Name (English)\"), disabled=True, required=False)\n\n    class Meta:\n        model = Evaluation\n        fields = ('name_de_field', 'name_en_field', 'vote_start_datetime', 'vote_end_date', 'general_questionnaires', 'course')\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self.fields['name_de_field'].initial = self.instance.full_name_de\n        self.fields['name_en_field'].initial = self.instance.full_name_en\n\n        self.fields['general_questionnaires'].queryset = Questionnaire.objects.general_questionnaires().filter(\n            Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.instance)).distinct()\n\n        self.fields['vote_start_datetime'].localize = True\n        self.fields['vote_end_date'].localize = True\n\n        if self.instance.general_contribution:\n            self.fields['general_questionnaires'].initial = [q.pk for q in self.instance.general_contribution.questionnaires.all()]\n\n    def clean(self):\n        super().clean()\n\n        vote_start_datetime = self.cleaned_data.get('vote_start_datetime')\n        vote_end_date = self.cleaned_data.get('vote_end_date')\n        if vote_start_datetime and vote_end_date:\n            if vote_start_datetime.date() > vote_end_date:\n                self.add_error(\"vote_start_datetime\", \"\")\n                self.add_error(\"vote_end_date\", _(\"The first day of evaluation must be before the last one.\"))\n\n    def clean_vote_end_date(self):\n        vote_end_date = self.cleaned_data.get('vote_end_date')\n\n        # The actual deadline is EVALUATION_END_OFFSET_HOURS:00 AM of the day after vote_end_date.\n        # Therefore an evaluation date 24h + EVALUATION_END_OFFSET_HOURS in the past would technically still be in the future.\n        if vote_end_date and date_to_datetime(vote_end_date) + timedelta(hours=24 + settings.EVALUATION_END_OFFSET_HOURS) < datetime.now():\n            raise forms.ValidationError(_(\"The last day of evaluation must be in the future.\"))\n        return vote_end_date\n\n    def save(self, *args, **kw):\n        evaluation = super().save(*args, **kw)\n        evaluation.general_contribution.questionnaires.set(self.cleaned_data.get('general_questionnaires'))\n        return evaluation\n\n\nclass EditorContributionForm(ContributionForm):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        existing_contributor_pk = self.instance.contributor.pk if self.instance.contributor else None\n\n        self.fields['questionnaires'].queryset = Questionnaire.objects.contributor_questionnaires().filter(\n            Q(visibility=Questionnaire.EDITORS) | Q(contributions__evaluation=self.evaluation)).distinct()\n        self.fields['contributor'].queryset = UserProfile.objects.filter(\n            (Q(is_active=True) & Q(is_proxy_user=False)) | Q(pk=existing_contributor_pk)\n        )\n\n\nclass DelegatesForm(forms.ModelForm):\n    delegates = UserModelMultipleChoiceField(queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True),\n                                             required=False)\n\n    class Meta:\n        model = UserProfile\n        fields = ('delegates',)\n        field_classes = {\n            'delegates': UserModelMultipleChoiceField,\n        }\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n    def save(self, *args, **kw):\n        super().save(*args, **kw)\n        logger.info('User \"{}\" edited the settings.'.format(self.instance.username))\n\n\nclass DelegateSelectionForm(forms.Form):\n    delegate_to = UserModelChoiceField(label=_(\"Delegate to\"),\n                                       queryset=UserProfile.objects.exclude(is_active=False).exclude(is_proxy_user=True))\n", "path": "evap/contributor/forms.py"}]}