prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Documents page broken
  Steps to reproduce:
  1. Go to https://thalia.nu/association/documents/
  
  
  Sentry Issue: [CONCREXIT-4E](https://sentry.io/organizations/thalia/issues/2020405926/?referrer=github_integration)
  
  ```
  FieldError: Cannot resolve keyword 'name_en' into field. Choices are: annualdocument, category, created, event, eventdocument, file, generalmeeting, id, last_updated, members_only, minutes, name
  (5 additional frame(s) were not displayed)
  ...
    File "documents/views.py", line 54, in get_context_data
      "association_documents": AssociationDocument.objects.order_by(
    File "django/db/models/manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "django/db/models/query.py", line 1134, in order_by
      obj.query.add_ordering(*field_names)
    File "django/db/models/sql/query.py", line 1919, in add_ordering
      self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)
    File "django/db/models/sql/query.py", line 1481, in names_to_path
      raise FieldError("Cannot resolve keyword '%s' into field. "
  ```
  
  </issue>
  <code>
  [start of website/documents/views.py]
  1 """Views provided by the documents package"""
  2 import os
  3 
  4 from django.conf import settings
  5 from django.core.exceptions import PermissionDenied
  6 from django.http import Http404, HttpResponse
  7 from django.shortcuts import redirect
  8 from django.utils import timezone
  9 from django.utils.text import slugify
  10 from django.utils.translation import get_language
  11 from django.views.generic import TemplateView, DetailView
  12 from django_sendfile import sendfile
  13 
  14 from documents.models import (
  15     AnnualDocument,
  16     AssociationDocument,
  17     GeneralMeeting,
  18     Document,
  19 )
  20 from utils.snippets import datetime_to_lectureyear
  21 
  22 
  23 class DocumentsIndexView(TemplateView):
  24     """
  25     View that renders the documents index page
  26     """
  27 
  28     template_name = "documents/index.html"
  29 
  30     def get_context_data(self, **kwargs) -> dict:
  31         lecture_year = datetime_to_lectureyear(timezone.now())
  32 
  33         years = {x: {} for x in reversed(range(1990, lecture_year + 1))}
  34         for year in years:
  35             years[year] = {
  36                 "documents": {"policy": None, "report": None, "financial": None},
  37                 "general_meetings": [],
  38             }
  39 
  40         for document in AnnualDocument.objects.filter(subcategory="policy"):
  41             years[document.year]["documents"]["policy"] = document
  42         for document in AnnualDocument.objects.filter(subcategory="report"):
  43             years[document.year]["documents"]["report"] = document
  44         for document in AnnualDocument.objects.filter(subcategory="financial"):
  45             years[document.year]["documents"]["financial"] = document
  46 
  47         for obj in GeneralMeeting.objects.all():
  48             meeting_year = datetime_to_lectureyear(obj.datetime)
  49             years[meeting_year]["general_meetings"].append(obj)
  50 
  51         context = super().get_context_data(**kwargs)
  52         context.update(
  53             {
  54                 "association_documents": AssociationDocument.objects.order_by(
  55                     f"name_{get_language()}"
  56                 ).all(),
  57                 "years": list(years.items()),
  58             }
  59         )
  60         return context
  61 
  62 
  63 class DocumentDownloadView(DetailView):
  64     """
  65     View that allows you to download a specific document based on it's and your
  66     permissions settings
  67     """
  68 
  69     model = Document
  70 
  71     def get(self, request, *args, **kwargs) -> HttpResponse:
  72         """
  73         :return: either a 302 redirect to the login page or
  74         a 200 with the document
  75         """
  76         response = super().get(request, *args, **kwargs)
  77         document = response.context_data["document"]
  78 
  79         if document.members_only and not request.user.is_authenticated:
  80             return redirect("{}?next={}".format(settings.LOGIN_URL, request.path))
  81         if document.members_only and not request.member.has_active_membership():
  82             raise PermissionDenied
  83 
  84         lang = request.GET.get("language")
  85         try:
  86             if lang == "en":
  87                 file = document.file_en
  88             else:  # Fall back on language detection
  89                 file = document.file
  90         except ValueError as e:
  91             raise Http404("This document does not exist.") from e
  92 
  93         ext = os.path.splitext(file.path)[1]
  94 
  95         return sendfile(
  96             request,
  97             file.path,
  98             attachment=True,
  99             attachment_filename=slugify(document.name) + ext,
  100         )
  101
  [end of website/documents/views.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/website/documents/views.py b/website/documents/views.py
  --- a/website/documents/views.py
  +++ b/website/documents/views.py
  @@ -7,7 +7,6 @@
   from django.shortcuts import redirect
   from django.utils import timezone
   from django.utils.text import slugify
  -from django.utils.translation import get_language
   from django.views.generic import TemplateView, DetailView
   from django_sendfile import sendfile
   
  @@ -52,7 +51,7 @@
           context.update(
               {
                   "association_documents": AssociationDocument.objects.order_by(
  -                    f"name_{get_language()}"
  +                    "name"
                   ).all(),
                   "years": list(years.items()),
               }
  @@ -81,12 +80,8 @@
           if document.members_only and not request.member.has_active_membership():
               raise PermissionDenied
   
  -        lang = request.GET.get("language")
           try:
  -            if lang == "en":
  -                file = document.file_en
  -            else:  # Fall back on language detection
  -                file = document.file
  +            file = document.file
           except ValueError as e:
               raise Http404("This document does not exist.") from e
  
verification_info: {"golden_diff": "diff --git a/website/documents/views.py b/website/documents/views.py\n--- a/website/documents/views.py\n+++ b/website/documents/views.py\n@@ -7,7 +7,6 @@\n from django.shortcuts import redirect\n from django.utils import timezone\n from django.utils.text import slugify\n-from django.utils.translation import get_language\n from django.views.generic import TemplateView, DetailView\n from django_sendfile import sendfile\n \n@@ -52,7 +51,7 @@\n         context.update(\n             {\n                 \"association_documents\": AssociationDocument.objects.order_by(\n-                    f\"name_{get_language()}\"\n+                    \"name\"\n                 ).all(),\n                 \"years\": list(years.items()),\n             }\n@@ -81,12 +80,8 @@\n         if document.members_only and not request.member.has_active_membership():\n             raise PermissionDenied\n \n-        lang = request.GET.get(\"language\")\n         try:\n-            if lang == \"en\":\n-                file = document.file_en\n-            else:  # Fall back on language detection\n-                file = document.file\n+            file = document.file\n         except ValueError as e:\n             raise Http404(\"This document does not exist.\") from e\n", "issue": "Documents page broken\nSteps to reproduce:\n1. Go to https://thalia.nu/association/documents/\n\n\nSentry Issue: [CONCREXIT-4E](https://sentry.io/organizations/thalia/issues/2020405926/?referrer=github_integration)\n\n```\nFieldError: Cannot resolve keyword 'name_en' into field. Choices are: annualdocument, category, created, event, eventdocument, file, generalmeeting, id, last_updated, members_only, minutes, name\n(5 additional frame(s) were not displayed)\n...\n  File \"documents/views.py\", line 54, in get_context_data\n    \"association_documents\": AssociationDocument.objects.order_by(\n  File \"django/db/models/manager.py\", line 85, in manager_method\n    return getattr(self.get_queryset(), name)(*args, **kwargs)\n  File \"django/db/models/query.py\", line 1134, in order_by\n    obj.query.add_ordering(*field_names)\n  File \"django/db/models/sql/query.py\", line 1919, in add_ordering\n    self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)\n  File \"django/db/models/sql/query.py\", line 1481, in names_to_path\n    raise FieldError(\"Cannot resolve keyword '%s' into field. \"\n```\n", "before_files": [{"content": "\"\"\"Views provided by the documents package\"\"\"\nimport os\n\nfrom django.conf import settings\nfrom django.core.exceptions import PermissionDenied\nfrom django.http import Http404, HttpResponse\nfrom django.shortcuts import redirect\nfrom django.utils import timezone\nfrom django.utils.text import slugify\nfrom django.utils.translation import get_language\nfrom django.views.generic import TemplateView, DetailView\nfrom django_sendfile import sendfile\n\nfrom documents.models import (\n    AnnualDocument,\n    AssociationDocument,\n    GeneralMeeting,\n    Document,\n)\nfrom utils.snippets import datetime_to_lectureyear\n\n\nclass DocumentsIndexView(TemplateView):\n    \"\"\"\n    View that renders the documents index page\n    \"\"\"\n\n    template_name = \"documents/index.html\"\n\n    def get_context_data(self, **kwargs) -> dict:\n        lecture_year = datetime_to_lectureyear(timezone.now())\n\n        years = {x: {} for x in reversed(range(1990, lecture_year + 1))}\n        for year in years:\n            years[year] = {\n                \"documents\": {\"policy\": None, \"report\": None, \"financial\": None},\n                \"general_meetings\": [],\n            }\n\n        for document in AnnualDocument.objects.filter(subcategory=\"policy\"):\n            years[document.year][\"documents\"][\"policy\"] = document\n        for document in AnnualDocument.objects.filter(subcategory=\"report\"):\n            years[document.year][\"documents\"][\"report\"] = document\n        for document in AnnualDocument.objects.filter(subcategory=\"financial\"):\n            years[document.year][\"documents\"][\"financial\"] = document\n\n        for obj in GeneralMeeting.objects.all():\n            meeting_year = datetime_to_lectureyear(obj.datetime)\n            years[meeting_year][\"general_meetings\"].append(obj)\n\n        context = super().get_context_data(**kwargs)\n        context.update(\n            {\n                \"association_documents\": AssociationDocument.objects.order_by(\n                    f\"name_{get_language()}\"\n                ).all(),\n                \"years\": list(years.items()),\n            }\n        )\n        return context\n\n\nclass DocumentDownloadView(DetailView):\n    \"\"\"\n    View that allows you to download a specific document based on it's and your\n    permissions settings\n    \"\"\"\n\n    model = Document\n\n    def get(self, request, *args, **kwargs) -> HttpResponse:\n        \"\"\"\n        :return: either a 302 redirect to the login page or\n        a 200 with the document\n        \"\"\"\n        response = super().get(request, *args, **kwargs)\n        document = response.context_data[\"document\"]\n\n        if document.members_only and not request.user.is_authenticated:\n            return redirect(\"{}?next={}\".format(settings.LOGIN_URL, request.path))\n        if document.members_only and not request.member.has_active_membership():\n            raise PermissionDenied\n\n        lang = request.GET.get(\"language\")\n        try:\n            if lang == \"en\":\n                file = document.file_en\n            else:  # Fall back on language detection\n                file = document.file\n        except ValueError as e:\n            raise Http404(\"This document does not exist.\") from e\n\n        ext = os.path.splitext(file.path)[1]\n\n        return sendfile(\n            request,\n            file.path,\n            attachment=True,\n            attachment_filename=slugify(document.name) + ext,\n        )\n", "path": "website/documents/views.py"}]}