We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Include badge & badge date in member view 
In the member view [such as this](https://amy.software-carpentry.org/fiscal/membership/121/), we see a list of instructor training seats with the columns Event, Person, and Task.

Can we also have two more columns in this view: Badge (SWC, DC, and/or LC) and Date Badged?

Task appears to be a concatenation of Event, Person, and Role. If Role is always going to be Learner, we can remove this column to make room for the new columns suggested above.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `amy/fiscal/views.py`
Content:
```
1 from django.contrib.auth.mixins import (
2     PermissionRequiredMixin,
3 )
4 from django.db.models import (
5     F,
6     Q,
7     Count,
8     Prefetch,
9 )
10 from django.db.models.functions import Now
11 from django.urls import reverse, reverse_lazy
12 
13 from fiscal.filters import (
14     OrganizationFilter,
15     MembershipFilter,
16 )
17 from fiscal.forms import (
18     OrganizationForm,
19     OrganizationCreateForm,
20     MembershipForm,
21     MembershipCreateForm,
22     SponsorshipForm,
23 )
24 from workshops.base_views import (
25     AMYCreateView,
26     AMYUpdateView,
27     AMYDeleteView,
28     AMYListView,
29     RedirectSupportMixin,
30     PrepopulationSupportMixin,
31     AMYDetailView,
32 )
33 from workshops.models import (
34     Organization,
35     Membership,
36     Sponsorship,
37 )
38 from workshops.util import (
39     OnlyForAdminsMixin,
40 )
41 
42 
43 # ------------------------------------------------------------
44 # Organization related views
45 # ------------------------------------------------------------
46 
47 class AllOrganizations(OnlyForAdminsMixin, AMYListView):
48     context_object_name = 'all_organizations'
49     template_name = 'fiscal/all_organizations.html'
50     filter_class = OrganizationFilter
51     queryset = Organization.objects.prefetch_related(Prefetch(
52         'membership_set',
53         to_attr='current_memberships',
54         queryset=Membership.objects.filter(
55             agreement_start__lte=Now(),
56             agreement_end__gte=Now(),
57         )
58     ))
59     title = 'All Organizations'
60 
61 
62 class OrganizationDetails(OnlyForAdminsMixin, AMYDetailView):
63     queryset = Organization.objects.all()
64     context_object_name = 'organization'
65     template_name = 'fiscal/organization.html'
66     slug_field = 'domain'
67     slug_url_kwarg = 'org_domain'
68 
69     def get_context_data(self, **kwargs):
70         context = super().get_context_data(**kwargs)
71         context['title'] = 'Organization {0}'.format(self.object)
72         return context
73 
74 
75 class OrganizationCreate(OnlyForAdminsMixin, PermissionRequiredMixin,
76                          AMYCreateView):
77     permission_required = 'workshops.add_organization'
78     model = Organization
79     form_class = OrganizationCreateForm
80 
81 
82 class OrganizationUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,
83                          AMYUpdateView):
84     permission_required = 'workshops.change_organization'
85     model = Organization
86     form_class = OrganizationForm
87     slug_field = 'domain'
88     slug_url_kwarg = 'org_domain'
89     template_name = 'generic_form_with_comments.html'
90 
91 
92 class OrganizationDelete(OnlyForAdminsMixin, PermissionRequiredMixin,
93                          AMYDeleteView):
94     model = Organization
95     slug_field = 'domain'
96     slug_url_kwarg = 'org_domain'
97     permission_required = 'workshops.delete_organization'
98     success_url = reverse_lazy('all_organizations')
99 
100 
101 # ------------------------------------------------------------
102 # Membership related views
103 # ------------------------------------------------------------
104 
105 class AllMemberships(OnlyForAdminsMixin, AMYListView):
106     context_object_name = 'all_memberships'
107     template_name = 'fiscal/all_memberships.html'
108     filter_class = MembershipFilter
109     queryset = Membership.objects.annotate(
110         instructor_training_seats_total=(
111             F('seats_instructor_training') +
112             F('additional_instructor_training_seats')
113         ),
114         # for future reference, in case someone would want to implement
115         # this annotation
116         # instructor_training_seats_utilized=(
117         #     Count('task', filter=Q(task__role__name='learner'))
118         # ),
119         instructor_training_seats_remaining=(
120             F('seats_instructor_training') +
121             F('additional_instructor_training_seats') -
122             Count('task', filter=Q(task__role__name='learner'))
123         ),
124     )
125     title = 'All Memberships'
126 
127 
128 class MembershipDetails(OnlyForAdminsMixin, AMYDetailView):
129     queryset = (
130         Membership.objects
131                   .select_related('organization')
132                   .prefetch_related('task_set')
133     )
134     context_object_name = 'membership'
135     template_name = 'fiscal/membership.html'
136     pk_url_kwarg = 'membership_id'
137 
138     def get_context_data(self, **kwargs):
139         context = super().get_context_data(**kwargs)
140         context['title'] = '{0}'.format(self.object)
141         return context
142 
143 
144 class MembershipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,
145                        PrepopulationSupportMixin, AMYCreateView):
146     permission_required = [
147         'workshops.add_membership',
148         'workshops.change_organization',
149     ]
150     model = Membership
151     form_class = MembershipCreateForm
152     populate_fields = ['organization']
153 
154 
155 class MembershipUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,
156                        RedirectSupportMixin, AMYUpdateView):
157     permission_required = 'workshops.change_membership'
158     model = Membership
159     form_class = MembershipForm
160     pk_url_kwarg = 'membership_id'
161     template_name = 'generic_form_with_comments.html'
162 
163 
164 class MembershipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,
165                        AMYDeleteView):
166     model = Membership
167     permission_required = 'workshops.delete_membership'
168     pk_url_kwarg = 'membership_id'
169 
170     def get_success_url(self):
171         return reverse('organization_details', args=[
172             self.get_object().organization.domain])
173 
174 
175 # ------------------------------------------------------------
176 # Sponsorship related views
177 # ------------------------------------------------------------
178 
179 class SponsorshipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,
180                         AMYCreateView):
181     model = Sponsorship
182     permission_required = 'workshops.add_sponsorship'
183     form_class = SponsorshipForm
184 
185     def get_success_url(self):
186         return reverse('event_edit', args=[self.object.event.slug]) + \
187             '#sponsors'
188 
189 
190 class SponsorshipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,
191                         AMYDeleteView):
192     model = Sponsorship
193     permission_required = 'workshops.delete_sponsorship'
194 
195     def get_success_url(self):
196         return reverse('event_edit', args=[self.get_object().event.slug]) + \
197             '#sponsors'
198
```
--- 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/amy/fiscal/views.py b/amy/fiscal/views.py
--- a/amy/fiscal/views.py
+++ b/amy/fiscal/views.py
@@ -34,6 +34,8 @@
     Organization,
     Membership,
     Sponsorship,
+    Task,
+    Award,
 )
 from workshops.util import (
     OnlyForAdminsMixin,
@@ -126,11 +128,16 @@
 
 
 class MembershipDetails(OnlyForAdminsMixin, AMYDetailView):
-    queryset = (
-        Membership.objects
-                  .select_related('organization')
-                  .prefetch_related('task_set')
-    )
+    prefetch_awards = Prefetch('person__award_set',
+                               queryset=Award.objects.select_related('badge'))
+    queryset = Membership.objects.select_related('organization') \
+        .prefetch_related(
+            Prefetch(
+                'task_set',
+                queryset=Task.objects.select_related('event', 'person')
+                                     .prefetch_related(prefetch_awards)
+            )
+        )
     context_object_name = 'membership'
     template_name = 'fiscal/membership.html'
     pk_url_kwarg = 'membership_id'

{"golden_diff": "diff --git a/amy/fiscal/views.py b/amy/fiscal/views.py\n--- a/amy/fiscal/views.py\n+++ b/amy/fiscal/views.py\n@@ -34,6 +34,8 @@\n     Organization,\n     Membership,\n     Sponsorship,\n+    Task,\n+    Award,\n )\n from workshops.util import (\n     OnlyForAdminsMixin,\n@@ -126,11 +128,16 @@\n \n \n class MembershipDetails(OnlyForAdminsMixin, AMYDetailView):\n-    queryset = (\n-        Membership.objects\n-                  .select_related('organization')\n-                  .prefetch_related('task_set')\n-    )\n+    prefetch_awards = Prefetch('person__award_set',\n+                               queryset=Award.objects.select_related('badge'))\n+    queryset = Membership.objects.select_related('organization') \\\n+        .prefetch_related(\n+            Prefetch(\n+                'task_set',\n+                queryset=Task.objects.select_related('event', 'person')\n+                                     .prefetch_related(prefetch_awards)\n+            )\n+        )\n     context_object_name = 'membership'\n     template_name = 'fiscal/membership.html'\n     pk_url_kwarg = 'membership_id'\n", "issue": "Include badge & badge date in member view \nIn the member view [such as this](https://amy.software-carpentry.org/fiscal/membership/121/), we see a list of instructor training seats with the columns Event, Person, and Task.\r\n\r\nCan we also have two more columns in this view: Badge (SWC, DC, and/or LC) and Date Badged?\r\n\r\nTask appears to be a concatenation of Event, Person, and Role. If Role is always going to be Learner, we can remove this column to make room for the new columns suggested above.\n", "before_files": [{"content": "from django.contrib.auth.mixins import (\n    PermissionRequiredMixin,\n)\nfrom django.db.models import (\n    F,\n    Q,\n    Count,\n    Prefetch,\n)\nfrom django.db.models.functions import Now\nfrom django.urls import reverse, reverse_lazy\n\nfrom fiscal.filters import (\n    OrganizationFilter,\n    MembershipFilter,\n)\nfrom fiscal.forms import (\n    OrganizationForm,\n    OrganizationCreateForm,\n    MembershipForm,\n    MembershipCreateForm,\n    SponsorshipForm,\n)\nfrom workshops.base_views import (\n    AMYCreateView,\n    AMYUpdateView,\n    AMYDeleteView,\n    AMYListView,\n    RedirectSupportMixin,\n    PrepopulationSupportMixin,\n    AMYDetailView,\n)\nfrom workshops.models import (\n    Organization,\n    Membership,\n    Sponsorship,\n)\nfrom workshops.util import (\n    OnlyForAdminsMixin,\n)\n\n\n# ------------------------------------------------------------\n# Organization related views\n# ------------------------------------------------------------\n\nclass AllOrganizations(OnlyForAdminsMixin, AMYListView):\n    context_object_name = 'all_organizations'\n    template_name = 'fiscal/all_organizations.html'\n    filter_class = OrganizationFilter\n    queryset = Organization.objects.prefetch_related(Prefetch(\n        'membership_set',\n        to_attr='current_memberships',\n        queryset=Membership.objects.filter(\n            agreement_start__lte=Now(),\n            agreement_end__gte=Now(),\n        )\n    ))\n    title = 'All Organizations'\n\n\nclass OrganizationDetails(OnlyForAdminsMixin, AMYDetailView):\n    queryset = Organization.objects.all()\n    context_object_name = 'organization'\n    template_name = 'fiscal/organization.html'\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['title'] = 'Organization {0}'.format(self.object)\n        return context\n\n\nclass OrganizationCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYCreateView):\n    permission_required = 'workshops.add_organization'\n    model = Organization\n    form_class = OrganizationCreateForm\n\n\nclass OrganizationUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYUpdateView):\n    permission_required = 'workshops.change_organization'\n    model = Organization\n    form_class = OrganizationForm\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n    template_name = 'generic_form_with_comments.html'\n\n\nclass OrganizationDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYDeleteView):\n    model = Organization\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n    permission_required = 'workshops.delete_organization'\n    success_url = reverse_lazy('all_organizations')\n\n\n# ------------------------------------------------------------\n# Membership related views\n# ------------------------------------------------------------\n\nclass AllMemberships(OnlyForAdminsMixin, AMYListView):\n    context_object_name = 'all_memberships'\n    template_name = 'fiscal/all_memberships.html'\n    filter_class = MembershipFilter\n    queryset = Membership.objects.annotate(\n        instructor_training_seats_total=(\n            F('seats_instructor_training') +\n            F('additional_instructor_training_seats')\n        ),\n        # for future reference, in case someone would want to implement\n        # this annotation\n        # instructor_training_seats_utilized=(\n        #     Count('task', filter=Q(task__role__name='learner'))\n        # ),\n        instructor_training_seats_remaining=(\n            F('seats_instructor_training') +\n            F('additional_instructor_training_seats') -\n            Count('task', filter=Q(task__role__name='learner'))\n        ),\n    )\n    title = 'All Memberships'\n\n\nclass MembershipDetails(OnlyForAdminsMixin, AMYDetailView):\n    queryset = (\n        Membership.objects\n                  .select_related('organization')\n                  .prefetch_related('task_set')\n    )\n    context_object_name = 'membership'\n    template_name = 'fiscal/membership.html'\n    pk_url_kwarg = 'membership_id'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['title'] = '{0}'.format(self.object)\n        return context\n\n\nclass MembershipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       PrepopulationSupportMixin, AMYCreateView):\n    permission_required = [\n        'workshops.add_membership',\n        'workshops.change_organization',\n    ]\n    model = Membership\n    form_class = MembershipCreateForm\n    populate_fields = ['organization']\n\n\nclass MembershipUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       RedirectSupportMixin, AMYUpdateView):\n    permission_required = 'workshops.change_membership'\n    model = Membership\n    form_class = MembershipForm\n    pk_url_kwarg = 'membership_id'\n    template_name = 'generic_form_with_comments.html'\n\n\nclass MembershipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       AMYDeleteView):\n    model = Membership\n    permission_required = 'workshops.delete_membership'\n    pk_url_kwarg = 'membership_id'\n\n    def get_success_url(self):\n        return reverse('organization_details', args=[\n            self.get_object().organization.domain])\n\n\n# ------------------------------------------------------------\n# Sponsorship related views\n# ------------------------------------------------------------\n\nclass SponsorshipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                        AMYCreateView):\n    model = Sponsorship\n    permission_required = 'workshops.add_sponsorship'\n    form_class = SponsorshipForm\n\n    def get_success_url(self):\n        return reverse('event_edit', args=[self.object.event.slug]) + \\\n            '#sponsors'\n\n\nclass SponsorshipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                        AMYDeleteView):\n    model = Sponsorship\n    permission_required = 'workshops.delete_sponsorship'\n\n    def get_success_url(self):\n        return reverse('event_edit', args=[self.get_object().event.slug]) + \\\n            '#sponsors'\n", "path": "amy/fiscal/views.py"}], "after_files": [{"content": "from django.contrib.auth.mixins import (\n    PermissionRequiredMixin,\n)\nfrom django.db.models import (\n    F,\n    Q,\n    Count,\n    Prefetch,\n)\nfrom django.db.models.functions import Now\nfrom django.urls import reverse, reverse_lazy\n\nfrom fiscal.filters import (\n    OrganizationFilter,\n    MembershipFilter,\n)\nfrom fiscal.forms import (\n    OrganizationForm,\n    OrganizationCreateForm,\n    MembershipForm,\n    MembershipCreateForm,\n    SponsorshipForm,\n)\nfrom workshops.base_views import (\n    AMYCreateView,\n    AMYUpdateView,\n    AMYDeleteView,\n    AMYListView,\n    RedirectSupportMixin,\n    PrepopulationSupportMixin,\n    AMYDetailView,\n)\nfrom workshops.models import (\n    Organization,\n    Membership,\n    Sponsorship,\n    Task,\n    Award,\n)\nfrom workshops.util import (\n    OnlyForAdminsMixin,\n)\n\n\n# ------------------------------------------------------------\n# Organization related views\n# ------------------------------------------------------------\n\nclass AllOrganizations(OnlyForAdminsMixin, AMYListView):\n    context_object_name = 'all_organizations'\n    template_name = 'fiscal/all_organizations.html'\n    filter_class = OrganizationFilter\n    queryset = Organization.objects.prefetch_related(Prefetch(\n        'membership_set',\n        to_attr='current_memberships',\n        queryset=Membership.objects.filter(\n            agreement_start__lte=Now(),\n            agreement_end__gte=Now(),\n        )\n    ))\n    title = 'All Organizations'\n\n\nclass OrganizationDetails(OnlyForAdminsMixin, AMYDetailView):\n    queryset = Organization.objects.all()\n    context_object_name = 'organization'\n    template_name = 'fiscal/organization.html'\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['title'] = 'Organization {0}'.format(self.object)\n        return context\n\n\nclass OrganizationCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYCreateView):\n    permission_required = 'workshops.add_organization'\n    model = Organization\n    form_class = OrganizationCreateForm\n\n\nclass OrganizationUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYUpdateView):\n    permission_required = 'workshops.change_organization'\n    model = Organization\n    form_class = OrganizationForm\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n    template_name = 'generic_form_with_comments.html'\n\n\nclass OrganizationDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                         AMYDeleteView):\n    model = Organization\n    slug_field = 'domain'\n    slug_url_kwarg = 'org_domain'\n    permission_required = 'workshops.delete_organization'\n    success_url = reverse_lazy('all_organizations')\n\n\n# ------------------------------------------------------------\n# Membership related views\n# ------------------------------------------------------------\n\nclass AllMemberships(OnlyForAdminsMixin, AMYListView):\n    context_object_name = 'all_memberships'\n    template_name = 'fiscal/all_memberships.html'\n    filter_class = MembershipFilter\n    queryset = Membership.objects.annotate(\n        instructor_training_seats_total=(\n            F('seats_instructor_training') +\n            F('additional_instructor_training_seats')\n        ),\n        # for future reference, in case someone would want to implement\n        # this annotation\n        # instructor_training_seats_utilized=(\n        #     Count('task', filter=Q(task__role__name='learner'))\n        # ),\n        instructor_training_seats_remaining=(\n            F('seats_instructor_training') +\n            F('additional_instructor_training_seats') -\n            Count('task', filter=Q(task__role__name='learner'))\n        ),\n    )\n    title = 'All Memberships'\n\n\nclass MembershipDetails(OnlyForAdminsMixin, AMYDetailView):\n    prefetch_awards = Prefetch('person__award_set',\n                               queryset=Award.objects.select_related('badge'))\n    queryset = Membership.objects.select_related('organization') \\\n        .prefetch_related(\n            Prefetch(\n                'task_set',\n                queryset=Task.objects.select_related('event', 'person')\n                                     .prefetch_related(prefetch_awards)\n            )\n        )\n    context_object_name = 'membership'\n    template_name = 'fiscal/membership.html'\n    pk_url_kwarg = 'membership_id'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['title'] = '{0}'.format(self.object)\n        return context\n\n\nclass MembershipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       PrepopulationSupportMixin, AMYCreateView):\n    permission_required = [\n        'workshops.add_membership',\n        'workshops.change_organization',\n    ]\n    model = Membership\n    form_class = MembershipCreateForm\n    populate_fields = ['organization']\n\n\nclass MembershipUpdate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       RedirectSupportMixin, AMYUpdateView):\n    permission_required = 'workshops.change_membership'\n    model = Membership\n    form_class = MembershipForm\n    pk_url_kwarg = 'membership_id'\n    template_name = 'generic_form_with_comments.html'\n\n\nclass MembershipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                       AMYDeleteView):\n    model = Membership\n    permission_required = 'workshops.delete_membership'\n    pk_url_kwarg = 'membership_id'\n\n    def get_success_url(self):\n        return reverse('organization_details', args=[\n            self.get_object().organization.domain])\n\n\n# ------------------------------------------------------------\n# Sponsorship related views\n# ------------------------------------------------------------\n\nclass SponsorshipCreate(OnlyForAdminsMixin, PermissionRequiredMixin,\n                        AMYCreateView):\n    model = Sponsorship\n    permission_required = 'workshops.add_sponsorship'\n    form_class = SponsorshipForm\n\n    def get_success_url(self):\n        return reverse('event_edit', args=[self.object.event.slug]) + \\\n            '#sponsors'\n\n\nclass SponsorshipDelete(OnlyForAdminsMixin, PermissionRequiredMixin,\n                        AMYDeleteView):\n    model = Sponsorship\n    permission_required = 'workshops.delete_sponsorship'\n\n    def get_success_url(self):\n        return reverse('event_edit', args=[self.get_object().event.slug]) + \\\n            '#sponsors'\n", "path": "amy/fiscal/views.py"}]}