prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Problème avec les liens vers les auteur.ic.es des suggestions
  Quand quelqu'un fait une suggestion depuis le site, le lien pour avoir le nom de la personne ne fonctionne pas.
  
  </issue>
  <code>
  [start of server/apps/home/forms.py]
  1 from django import forms
  2 
  3 class SuggestionForm(forms.Form):
  4     title = forms.CharField(max_length=50, required=True)
  5     description = forms.CharField(widget=forms.Textarea)
  6
  [end of server/apps/home/forms.py]
  [start of server/apps/utils/github.py]
  1 import requests
  2 from django.conf import settings
  3 
  4 
  5 def create_issue(title: str, body: str):
  6     issue = {
  7         'title': title,
  8         'body': body
  9     }
  10     resp = requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues',
  11                          json=issue, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))
  12     if resp.status_code != 201:
  13         raise Exception(f'Error while posting issue to Github: {resp.reason}')
  14     return resp.json()['number']
  15 
  16 
  17 def close_issue(number: int):
  18     """Function to close an issue in the repo."""
  19     update = {'state': 'closed'}
  20     requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues/{number}',
  21                   json=update, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))
  22
  [end of server/apps/utils/github.py]
  [start of server/apps/home/views.py]
  1 from datetime import *
  2 from typing import List
  3 from django.contrib.sites.shortcuts import get_current_site
  4 from django.db.models.query import QuerySet
  5 from django.shortcuts import render, redirect
  6 from django.views.generic import TemplateView, FormView
  7 from django.contrib import messages
  8 from django.contrib.auth.mixins import LoginRequiredMixin
  9 
  10 from apps.event.models import BaseEvent
  11 from apps.post.models import Post
  12 from apps.utils.github import create_issue
  13 
  14 from .forms import SuggestionForm
  15 
  16 
  17 class HomeView(LoginRequiredMixin, TemplateView):
  18     template_name = 'home/home.html'
  19 
  20     def get_context_data(self, **kwargs):
  21         # Call the base implementation first to get a context
  22         context = super().get_context_data(**kwargs)
  23         posts: List[Post] = Post.objects.filter(
  24             publication_date__gte=date.today()-timedelta(days=10)).order_by('-publication_date')
  25         context['posts'] = [
  26             post for post in posts if post.can_view(self.request.user)]
  27         return context
  28 
  29 
  30 class SuggestionView(LoginRequiredMixin, FormView):
  31     template_name = 'home/suggestions.html'
  32     form_class = SuggestionForm
  33 
  34     def form_valid(self, form):
  35         create_issue(
  36             title=form.cleaned_data['title'],
  37             body=f"{form.cleaned_data['description']} <br/> <a href='http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url}'>Clique pour découvrir qui propose ça.</a>"
  38         )
  39         messages.success(
  40             self.request, 'Votre suggestion a été enregistrée merci')
  41         return redirect('home:home')
  42 
  43 
  44 def handler404(request, *args, **argv):
  45     response = render(request, '404.html', context={}, status=404)
  46     return response
  47 
  48 
  49 def handler500(request, *args, **argv):
  50     response = render(request, '500.html', context={},
  51                       status=500)
  52     return response
  53 
  54 
  55 def event_sort(events, request):
  56     tri = {}
  57     jours = ["Lundi", "Mardi", "Mercredi",
  58              "Jeudi", "Vendredi", "Samedi", "Dimanche"]
  59     mois = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
  60             "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"]
  61     for event in events:
  62         if event.date.date() == date.today():
  63             if "Aujourd'hui" in tri:
  64                 tri["Aujourd'hui"].append(
  65                     (event, event.is_participating(request.user)))
  66             else:
  67                 tri["Aujourd'hui"] = list()
  68                 tri["Aujourd'hui"].append(
  69                     (event, event.is_participating(request.user)))
  70         elif event.date.date() == (date.today()+timedelta(days=1)):
  71             if "Demain" in tri:
  72                 tri["Demain"].append(
  73                     (event, event.is_participating(request.user)))
  74             else:
  75                 tri["Demain"] = list()
  76                 tri["Demain"].append(
  77                     (event, event.is_participating(request.user)))
  78         else:
  79             written_date = jours[event.date.weekday(
  80             )] + " " + str(event.date.day) + " " + mois[event.date.month-1]
  81             if written_date in tri:
  82                 tri[written_date].append(
  83                     (event, event.is_participating(request.user)))
  84             else:
  85                 tri[written_date] = list()
  86                 tri[written_date].append(
  87                     (event, event.is_participating(request.user)))
  88     return tri
  89
  [end of server/apps/home/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/server/apps/home/forms.py b/server/apps/home/forms.py
  --- a/server/apps/home/forms.py
  +++ b/server/apps/home/forms.py
  @@ -1,5 +1,14 @@
   from django import forms
   
  +TYPE_CHOICES = (
  +    (1, ("Bug")),
  +    (2, ("Suggestion"))
  +)
  +
  +
   class SuggestionForm(forms.Form):
       title = forms.CharField(max_length=50, required=True)
       description = forms.CharField(widget=forms.Textarea)
  +    suggestionOrBug = forms.ChoiceField(label="Type",
  +                                        choices=TYPE_CHOICES,
  +                                        required=True)
  diff --git a/server/apps/home/views.py b/server/apps/home/views.py
  --- a/server/apps/home/views.py
  +++ b/server/apps/home/views.py
  @@ -34,7 +34,8 @@
       def form_valid(self, form):
           create_issue(
               title=form.cleaned_data['title'],
  -            body=f"{form.cleaned_data['description']} <br/> <a href='http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url}'>Clique pour découvrir qui propose ça.</a>"
  +            body=f"{form.cleaned_data['description']} <br/> [Clique pour découvrir qui propose ça.](http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url()})",
  +            label=form.cleaned_data['suggestionOrBug']
           )
           messages.success(
               self.request, 'Votre suggestion a été enregistrée merci')
  diff --git a/server/apps/utils/github.py b/server/apps/utils/github.py
  --- a/server/apps/utils/github.py
  +++ b/server/apps/utils/github.py
  @@ -2,15 +2,18 @@
   from django.conf import settings
   
   
  -def create_issue(title: str, body: str):
  +def create_issue(title: str, body: str, label):
  +    label = "bug" if int(label) == 1 else "suggestion"
       issue = {
           'title': title,
  -        'body': body
  +        'body': body,
  +        'labels': [label]
       }
       resp = requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues',
                            json=issue, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))
       if resp.status_code != 201:
  -        raise Exception(f'Error while posting issue to Github: {resp.reason}')
  +        raise Exception(
  +            f'Error while posting issue to Github: {resp.reason}')
       return resp.json()['number']
  
verification_info: {"golden_diff": "diff --git a/server/apps/home/forms.py b/server/apps/home/forms.py\n--- a/server/apps/home/forms.py\n+++ b/server/apps/home/forms.py\n@@ -1,5 +1,14 @@\n from django import forms\n \n+TYPE_CHOICES = (\n+    (1, (\"Bug\")),\n+    (2, (\"Suggestion\"))\n+)\n+\n+\n class SuggestionForm(forms.Form):\n     title = forms.CharField(max_length=50, required=True)\n     description = forms.CharField(widget=forms.Textarea)\n+    suggestionOrBug = forms.ChoiceField(label=\"Type\",\n+                                        choices=TYPE_CHOICES,\n+                                        required=True)\ndiff --git a/server/apps/home/views.py b/server/apps/home/views.py\n--- a/server/apps/home/views.py\n+++ b/server/apps/home/views.py\n@@ -34,7 +34,8 @@\n     def form_valid(self, form):\n         create_issue(\n             title=form.cleaned_data['title'],\n-            body=f\"{form.cleaned_data['description']} <br/> <a href='http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url}'>Clique pour d\u00e9couvrir qui propose \u00e7a.</a>\"\n+            body=f\"{form.cleaned_data['description']} <br/> [Clique pour d\u00e9couvrir qui propose \u00e7a.](http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url()})\",\n+            label=form.cleaned_data['suggestionOrBug']\n         )\n         messages.success(\n             self.request, 'Votre suggestion a \u00e9t\u00e9 enregistr\u00e9e merci')\ndiff --git a/server/apps/utils/github.py b/server/apps/utils/github.py\n--- a/server/apps/utils/github.py\n+++ b/server/apps/utils/github.py\n@@ -2,15 +2,18 @@\n from django.conf import settings\n \n \n-def create_issue(title: str, body: str):\n+def create_issue(title: str, body: str, label):\n+    label = \"bug\" if int(label) == 1 else \"suggestion\"\n     issue = {\n         'title': title,\n-        'body': body\n+        'body': body,\n+        'labels': [label]\n     }\n     resp = requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues',\n                          json=issue, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))\n     if resp.status_code != 201:\n-        raise Exception(f'Error while posting issue to Github: {resp.reason}')\n+        raise Exception(\n+            f'Error while posting issue to Github: {resp.reason}')\n     return resp.json()['number']\n", "issue": "Probl\u00e8me avec les liens vers les auteur.ic.es des suggestions\nQuand quelqu'un fait une suggestion depuis le site, le lien pour avoir le nom de la personne ne fonctionne pas.\n", "before_files": [{"content": "from django import forms\n\nclass SuggestionForm(forms.Form):\n    title = forms.CharField(max_length=50, required=True)\n    description = forms.CharField(widget=forms.Textarea)\n", "path": "server/apps/home/forms.py"}, {"content": "import requests\nfrom django.conf import settings\n\n\ndef create_issue(title: str, body: str):\n    issue = {\n        'title': title,\n        'body': body\n    }\n    resp = requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues',\n                         json=issue, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))\n    if resp.status_code != 201:\n        raise Exception(f'Error while posting issue to Github: {resp.reason}')\n    return resp.json()['number']\n\n\ndef close_issue(number: int):\n    \"\"\"Function to close an issue in the repo.\"\"\"\n    update = {'state': 'closed'}\n    requests.post(f'https://api.github.com/repos/{settings.GITHUB_REPO}/issues/{number}',\n                  json=update, auth=(settings.GITHUB_USER, settings.GITHUB_TOKEN))\n", "path": "server/apps/utils/github.py"}, {"content": "from datetime import *\nfrom typing import List\nfrom django.contrib.sites.shortcuts import get_current_site\nfrom django.db.models.query import QuerySet\nfrom django.shortcuts import render, redirect\nfrom django.views.generic import TemplateView, FormView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\n\nfrom apps.event.models import BaseEvent\nfrom apps.post.models import Post\nfrom apps.utils.github import create_issue\n\nfrom .forms import SuggestionForm\n\n\nclass HomeView(LoginRequiredMixin, TemplateView):\n    template_name = 'home/home.html'\n\n    def get_context_data(self, **kwargs):\n        # Call the base implementation first to get a context\n        context = super().get_context_data(**kwargs)\n        posts: List[Post] = Post.objects.filter(\n            publication_date__gte=date.today()-timedelta(days=10)).order_by('-publication_date')\n        context['posts'] = [\n            post for post in posts if post.can_view(self.request.user)]\n        return context\n\n\nclass SuggestionView(LoginRequiredMixin, FormView):\n    template_name = 'home/suggestions.html'\n    form_class = SuggestionForm\n\n    def form_valid(self, form):\n        create_issue(\n            title=form.cleaned_data['title'],\n            body=f\"{form.cleaned_data['description']} <br/> <a href='http://{get_current_site(self.request)}{self.request.user.student.get_absolute_url}'>Clique pour d\u00e9couvrir qui propose \u00e7a.</a>\"\n        )\n        messages.success(\n            self.request, 'Votre suggestion a \u00e9t\u00e9 enregistr\u00e9e merci')\n        return redirect('home:home')\n\n\ndef handler404(request, *args, **argv):\n    response = render(request, '404.html', context={}, status=404)\n    return response\n\n\ndef handler500(request, *args, **argv):\n    response = render(request, '500.html', context={},\n                      status=500)\n    return response\n\n\ndef event_sort(events, request):\n    tri = {}\n    jours = [\"Lundi\", \"Mardi\", \"Mercredi\",\n             \"Jeudi\", \"Vendredi\", \"Samedi\", \"Dimanche\"]\n    mois = [\"Janvier\", \"F\u00e9vrier\", \"Mars\", \"Avril\", \"Mai\", \"Juin\",\n            \"Juillet\", \"Ao\u00fbt\", \"Septembre\", \"Octobre\", \"Novembre\", \"D\u00e9cembre\"]\n    for event in events:\n        if event.date.date() == date.today():\n            if \"Aujourd'hui\" in tri:\n                tri[\"Aujourd'hui\"].append(\n                    (event, event.is_participating(request.user)))\n            else:\n                tri[\"Aujourd'hui\"] = list()\n                tri[\"Aujourd'hui\"].append(\n                    (event, event.is_participating(request.user)))\n        elif event.date.date() == (date.today()+timedelta(days=1)):\n            if \"Demain\" in tri:\n                tri[\"Demain\"].append(\n                    (event, event.is_participating(request.user)))\n            else:\n                tri[\"Demain\"] = list()\n                tri[\"Demain\"].append(\n                    (event, event.is_participating(request.user)))\n        else:\n            written_date = jours[event.date.weekday(\n            )] + \" \" + str(event.date.day) + \" \" + mois[event.date.month-1]\n            if written_date in tri:\n                tri[written_date].append(\n                    (event, event.is_participating(request.user)))\n            else:\n                tri[written_date] = list()\n                tri[written_date].append(\n                    (event, event.is_participating(request.user)))\n    return tri\n", "path": "server/apps/home/views.py"}]}