prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Users should see which avatar is theirs
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `players/views.py`
  Content:
  ```
  1 import logging
  2 
  3 from django.http import JsonResponse
  4 from django.contrib.auth.decorators import login_required
  5 from django.http import HttpResponse
  6 from django.views.generic import TemplateView
  7 
  8 import os
  9 
  10 from models import Player
  11 from . import app_settings
  12 
  13 
  14 def _post_code_success_response(message):
  15     return create_response("SUCCESS", message)
  16 
  17 
  18 def create_response(status, message):
  19     response = {
  20         "status": status,
  21         "message": message
  22     }
  23     return JsonResponse(response)
  24 
  25 
  26 @login_required
  27 def code(request):
  28     try:
  29         player = request.user.player
  30     except Player.DoesNotExist:
  31         initial_code_file_name = os.path.join(
  32             os.path.abspath(os.path.dirname(__file__)),
  33             'avatar_examples/dumb_avatar.py',
  34         )
  35         with open(initial_code_file_name) as initial_code_file:
  36             initial_code = initial_code_file.read()
  37         player = Player.objects.create(user=request.user, code=initial_code)
  38     if request.method == 'POST':
  39         player.code = request.POST['code']
  40         player.save()
  41 
  42         return _post_code_success_response("Your code was saved!")
  43     else:
  44         return HttpResponse(player.code)
  45 
  46 
  47 def games(request):
  48     response = {
  49         'main': {
  50             'parameters': [],
  51             'users': [
  52                 {
  53                     'id': player.user.pk,
  54                     'code': player.code,
  55                 } for player in Player.objects.all()
  56             ]
  57         }
  58     }
  59     return JsonResponse(response)
  60 
  61 
  62 class WatchView(TemplateView):
  63     template_name = 'players/watch.html'
  64 
  65     def get_context_data(self, **kwargs):
  66         context = super(WatchView, self).get_context_data(**kwargs)
  67         context['game_url_base'], context['game_url_path'] = app_settings.GAME_SERVER_LOCATION_FUNCTION('main')
  68         return context
  69
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/players/views.py b/players/views.py
  --- a/players/views.py
  +++ b/players/views.py
  @@ -65,4 +65,5 @@
       def get_context_data(self, **kwargs):
           context = super(WatchView, self).get_context_data(**kwargs)
           context['game_url_base'], context['game_url_path'] = app_settings.GAME_SERVER_LOCATION_FUNCTION('main')
  +        context['current_user_player_key'] = self.request.user.pk
           return context
  
verification_info: {"golden_diff": "diff --git a/players/views.py b/players/views.py\n--- a/players/views.py\n+++ b/players/views.py\n@@ -65,4 +65,5 @@\n     def get_context_data(self, **kwargs):\n         context = super(WatchView, self).get_context_data(**kwargs)\n         context['game_url_base'], context['game_url_path'] = app_settings.GAME_SERVER_LOCATION_FUNCTION('main')\n+        context['current_user_player_key'] = self.request.user.pk\n         return context\n", "issue": "Users should see which avatar is theirs\n\n", "before_files": [{"content": "import logging\n\nfrom django.http import JsonResponse\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import HttpResponse\nfrom django.views.generic import TemplateView\n\nimport os\n\nfrom models import Player\nfrom . import app_settings\n\n\ndef _post_code_success_response(message):\n    return create_response(\"SUCCESS\", message)\n\n\ndef create_response(status, message):\n    response = {\n        \"status\": status,\n        \"message\": message\n    }\n    return JsonResponse(response)\n\n\n@login_required\ndef code(request):\n    try:\n        player = request.user.player\n    except Player.DoesNotExist:\n        initial_code_file_name = os.path.join(\n            os.path.abspath(os.path.dirname(__file__)),\n            'avatar_examples/dumb_avatar.py',\n        )\n        with open(initial_code_file_name) as initial_code_file:\n            initial_code = initial_code_file.read()\n        player = Player.objects.create(user=request.user, code=initial_code)\n    if request.method == 'POST':\n        player.code = request.POST['code']\n        player.save()\n\n        return _post_code_success_response(\"Your code was saved!\")\n    else:\n        return HttpResponse(player.code)\n\n\ndef games(request):\n    response = {\n        'main': {\n            'parameters': [],\n            'users': [\n                {\n                    'id': player.user.pk,\n                    'code': player.code,\n                } for player in Player.objects.all()\n            ]\n        }\n    }\n    return JsonResponse(response)\n\n\nclass WatchView(TemplateView):\n    template_name = 'players/watch.html'\n\n    def get_context_data(self, **kwargs):\n        context = super(WatchView, self).get_context_data(**kwargs)\n        context['game_url_base'], context['game_url_path'] = app_settings.GAME_SERVER_LOCATION_FUNCTION('main')\n        return context\n", "path": "players/views.py"}], "after_files": [{"content": "import logging\n\nfrom django.http import JsonResponse\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import HttpResponse\nfrom django.views.generic import TemplateView\n\nimport os\n\nfrom models import Player\nfrom . import app_settings\n\n\ndef _post_code_success_response(message):\n    return create_response(\"SUCCESS\", message)\n\n\ndef create_response(status, message):\n    response = {\n        \"status\": status,\n        \"message\": message\n    }\n    return JsonResponse(response)\n\n\n@login_required\ndef code(request):\n    try:\n        player = request.user.player\n    except Player.DoesNotExist:\n        initial_code_file_name = os.path.join(\n            os.path.abspath(os.path.dirname(__file__)),\n            'avatar_examples/dumb_avatar.py',\n        )\n        with open(initial_code_file_name) as initial_code_file:\n            initial_code = initial_code_file.read()\n        player = Player.objects.create(user=request.user, code=initial_code)\n    if request.method == 'POST':\n        player.code = request.POST['code']\n        player.save()\n\n        return _post_code_success_response(\"Your code was saved!\")\n    else:\n        return HttpResponse(player.code)\n\n\ndef games(request):\n    response = {\n        'main': {\n            'parameters': [],\n            'users': [\n                {\n                    'id': player.user.pk,\n                    'code': player.code,\n                } for player in Player.objects.all()\n            ]\n        }\n    }\n    return JsonResponse(response)\n\n\nclass WatchView(TemplateView):\n    template_name = 'players/watch.html'\n\n    def get_context_data(self, **kwargs):\n        context = super(WatchView, self).get_context_data(**kwargs)\n        context['game_url_base'], context['game_url_path'] = app_settings.GAME_SERVER_LOCATION_FUNCTION('main')\n        context['current_user_player_key'] = self.request.user.pk\n        return context\n", "path": "players/views.py"}]}