We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Modify contact_us api to fetch name and email, if the user is logged in.
This issue is related to #853 as discussed with @deshraj .

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `apps/web/views.py`
Content:
```
1 from django.contrib.auth.models import User
2 from django.shortcuts import render
3 
4 from .models import Team
5 
6 from rest_framework import permissions, status
7 from rest_framework.decorators import (api_view,
8                                        permission_classes,
9                                        throttle_classes,)
10 from rest_framework.response import Response
11 from rest_framework.throttling import AnonRateThrottle
12 
13 from .serializers import ContactSerializer, TeamSerializer
14 
15 
16 def home(request, template_name="index.html"):
17     """
18     Home Page View
19     """
20     return render(request, template_name)
21 
22 
23 def page_not_found(request):
24     response = render(request, 'error404.html',
25                       )
26     response.status_code = 404
27     return response
28 
29 
30 def internal_server_error(request):
31     response = render(request, 'error500.html',
32                       )
33     response.status_code = 500
34     return response
35 
36 
37 @throttle_classes([AnonRateThrottle, ])
38 @api_view(['POST', ])
39 @permission_classes((permissions.AllowAny,))
40 def contact_us(request):
41     try:
42         user = User.objects.get(username=request.user)
43         name = user.username
44         email = user.email
45         request_data = {"name": name, "email": email}
46         request_data['message'] = request.data['message']
47         serializer = ContactSerializer(data=request_data)
48         if serializer.is_valid():
49             serializer.save()
50             response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}
51             return Response(response_data, status=status.HTTP_201_CREATED)
52         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
53     except:
54         serializer = ContactSerializer(data=request.data)
55         if serializer.is_valid():
56             serializer.save()
57             response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}
58             return Response(response_data, status=status.HTTP_201_CREATED)
59         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
60 
61 
62 @throttle_classes([AnonRateThrottle])
63 @api_view(['GET', 'POST'])
64 @permission_classes((permissions.AllowAny,))
65 def our_team(request):
66     if request.method == 'GET':
67         teams = Team.objects.all()
68         serializer = TeamSerializer(teams, many=True, context={'request': request})
69         response_data = serializer.data
70         return Response(response_data, status=status.HTTP_200_OK)
71     elif request.method == 'POST':
72         # team_type is set to Team.CONTRIBUTOR by default and can be overridden by the requester
73         request.data['team_type'] = request.data.get('team_type', Team.CONTRIBUTOR)
74         serializer = TeamSerializer(data=request.data)
75         if serializer.is_valid():
76             serializer.save()
77             response_data = {'message', 'Successfully added the contributor.'}
78             return Response(response_data, status=status.HTTP_201_CREATED)
79         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
80
```
--- 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/apps/web/views.py b/apps/web/views.py
--- a/apps/web/views.py
+++ b/apps/web/views.py
@@ -35,29 +35,33 @@
 
 
 @throttle_classes([AnonRateThrottle, ])
-@api_view(['POST', ])
+@api_view(['GET', 'POST'])
 @permission_classes((permissions.AllowAny,))
 def contact_us(request):
+    user_does_not_exist = False
     try:
         user = User.objects.get(username=request.user)
         name = user.username
         email = user.email
-        request_data = {"name": name, "email": email}
-        request_data['message'] = request.data['message']
-        serializer = ContactSerializer(data=request_data)
-        if serializer.is_valid():
-            serializer.save()
-            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}
-            return Response(response_data, status=status.HTTP_201_CREATED)
-        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+        request_data = {'name': name, 'email': email}
     except:
-        serializer = ContactSerializer(data=request.data)
+        request_data = request.data
+        user_does_not_exist = True
+
+    if request.method == 'POST' or user_does_not_exist:
+        if request.POST.get('message'):
+            request_data['message'] = request.POST.get('message')
+        serializer = ContactSerializer(data=request_data)
         if serializer.is_valid():
             serializer.save()
-            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}
+            response_data = {'message': 'We have received your request and will contact you shortly.'}
             return Response(response_data, status=status.HTTP_201_CREATED)
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
 
+    elif request.method == 'GET':
+        response_data = {"name": name, "email": email}
+        return Response(response_data, status=status.HTTP_200_OK)
+
 
 @throttle_classes([AnonRateThrottle])
 @api_view(['GET', 'POST'])

{"golden_diff": "diff --git a/apps/web/views.py b/apps/web/views.py\n--- a/apps/web/views.py\n+++ b/apps/web/views.py\n@@ -35,29 +35,33 @@\n \n \n @throttle_classes([AnonRateThrottle, ])\n-@api_view(['POST', ])\n+@api_view(['GET', 'POST'])\n @permission_classes((permissions.AllowAny,))\n def contact_us(request):\n+    user_does_not_exist = False\n     try:\n         user = User.objects.get(username=request.user)\n         name = user.username\n         email = user.email\n-        request_data = {\"name\": name, \"email\": email}\n-        request_data['message'] = request.data['message']\n-        serializer = ContactSerializer(data=request_data)\n-        if serializer.is_valid():\n-            serializer.save()\n-            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}\n-            return Response(response_data, status=status.HTTP_201_CREATED)\n-        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n+        request_data = {'name': name, 'email': email}\n     except:\n-        serializer = ContactSerializer(data=request.data)\n+        request_data = request.data\n+        user_does_not_exist = True\n+\n+    if request.method == 'POST' or user_does_not_exist:\n+        if request.POST.get('message'):\n+            request_data['message'] = request.POST.get('message')\n+        serializer = ContactSerializer(data=request_data)\n         if serializer.is_valid():\n             serializer.save()\n-            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}\n+            response_data = {'message': 'We have received your request and will contact you shortly.'}\n             return Response(response_data, status=status.HTTP_201_CREATED)\n         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n \n+    elif request.method == 'GET':\n+        response_data = {\"name\": name, \"email\": email}\n+        return Response(response_data, status=status.HTTP_200_OK)\n+\n \n @throttle_classes([AnonRateThrottle])\n @api_view(['GET', 'POST'])\n", "issue": "Modify contact_us api to fetch name and email, if the user is logged in.\nThis issue is related to #853 as discussed with @deshraj .\n", "before_files": [{"content": "from django.contrib.auth.models import User\nfrom django.shortcuts import render\n\nfrom .models import Team\n\nfrom rest_framework import permissions, status\nfrom rest_framework.decorators import (api_view,\n                                       permission_classes,\n                                       throttle_classes,)\nfrom rest_framework.response import Response\nfrom rest_framework.throttling import AnonRateThrottle\n\nfrom .serializers import ContactSerializer, TeamSerializer\n\n\ndef home(request, template_name=\"index.html\"):\n    \"\"\"\n    Home Page View\n    \"\"\"\n    return render(request, template_name)\n\n\ndef page_not_found(request):\n    response = render(request, 'error404.html',\n                      )\n    response.status_code = 404\n    return response\n\n\ndef internal_server_error(request):\n    response = render(request, 'error500.html',\n                      )\n    response.status_code = 500\n    return response\n\n\n@throttle_classes([AnonRateThrottle, ])\n@api_view(['POST', ])\n@permission_classes((permissions.AllowAny,))\ndef contact_us(request):\n    try:\n        user = User.objects.get(username=request.user)\n        name = user.username\n        email = user.email\n        request_data = {\"name\": name, \"email\": email}\n        request_data['message'] = request.data['message']\n        serializer = ContactSerializer(data=request_data)\n        if serializer.is_valid():\n            serializer.save()\n            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}\n            return Response(response_data, status=status.HTTP_201_CREATED)\n        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n    except:\n        serializer = ContactSerializer(data=request.data)\n        if serializer.is_valid():\n            serializer.save()\n            response_data = {'message': 'Your message has been successfully recorded. We will contact you shortly.'}\n            return Response(response_data, status=status.HTTP_201_CREATED)\n        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n\n\n@throttle_classes([AnonRateThrottle])\n@api_view(['GET', 'POST'])\n@permission_classes((permissions.AllowAny,))\ndef our_team(request):\n    if request.method == 'GET':\n        teams = Team.objects.all()\n        serializer = TeamSerializer(teams, many=True, context={'request': request})\n        response_data = serializer.data\n        return Response(response_data, status=status.HTTP_200_OK)\n    elif request.method == 'POST':\n        # team_type is set to Team.CONTRIBUTOR by default and can be overridden by the requester\n        request.data['team_type'] = request.data.get('team_type', Team.CONTRIBUTOR)\n        serializer = TeamSerializer(data=request.data)\n        if serializer.is_valid():\n            serializer.save()\n            response_data = {'message', 'Successfully added the contributor.'}\n            return Response(response_data, status=status.HTTP_201_CREATED)\n        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n", "path": "apps/web/views.py"}], "after_files": [{"content": "from django.contrib.auth.models import User\nfrom django.shortcuts import render\n\nfrom .models import Team\n\nfrom rest_framework import permissions, status\nfrom rest_framework.decorators import (api_view,\n                                       permission_classes,\n                                       throttle_classes,)\nfrom rest_framework.response import Response\nfrom rest_framework.throttling import AnonRateThrottle\n\nfrom .serializers import ContactSerializer, TeamSerializer\n\n\ndef home(request, template_name=\"index.html\"):\n    \"\"\"\n    Home Page View\n    \"\"\"\n    return render(request, template_name)\n\n\ndef page_not_found(request):\n    response = render(request, 'error404.html',\n                      )\n    response.status_code = 404\n    return response\n\n\ndef internal_server_error(request):\n    response = render(request, 'error500.html',\n                      )\n    response.status_code = 500\n    return response\n\n\n@throttle_classes([AnonRateThrottle, ])\n@api_view(['GET', 'POST'])\n@permission_classes((permissions.AllowAny,))\ndef contact_us(request):\n    user_does_not_exist = False\n    try:\n        user = User.objects.get(username=request.user)\n        name = user.username\n        email = user.email\n        request_data = {'name': name, 'email': email}\n    except:\n        request_data = request.data\n        user_does_not_exist = True\n\n    if request.method == 'POST' or user_does_not_exist:\n        if request.POST.get('message'):\n            request_data['message'] = request.POST.get('message')\n        serializer = ContactSerializer(data=request_data)\n        if serializer.is_valid():\n            serializer.save()\n            response_data = {'message': 'We have received your request and will contact you shortly.'}\n            return Response(response_data, status=status.HTTP_201_CREATED)\n        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n\n    elif request.method == 'GET':\n        response_data = {\"name\": name, \"email\": email}\n        return Response(response_data, status=status.HTTP_200_OK)\n\n\n@throttle_classes([AnonRateThrottle])\n@api_view(['GET', 'POST'])\n@permission_classes((permissions.AllowAny,))\ndef our_team(request):\n    if request.method == 'GET':\n        teams = Team.objects.all()\n        serializer = TeamSerializer(teams, many=True, context={'request': request})\n        response_data = serializer.data\n        return Response(response_data, status=status.HTTP_200_OK)\n    elif request.method == 'POST':\n        # team_type is set to Team.CONTRIBUTOR by default and can be overridden by the requester\n        request.data['team_type'] = request.data.get('team_type', Team.CONTRIBUTOR)\n        serializer = TeamSerializer(data=request.data)\n        if serializer.is_valid():\n            serializer.save()\n            response_data = {'message', 'Successfully added the contributor.'}\n            return Response(response_data, status=status.HTTP_201_CREATED)\n        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)\n", "path": "apps/web/views.py"}]}