prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Update Domain management permissions 
  ### Issue Description
  
  Domain management, specifically that of DNS specific information, should be reserved for approved domain requests. Currently, if an item is in the list of registered domains and the status of the associated domain request switches to something like Withdrawn/Investigating, then the user can still edit the domain information AND the domain still appears in Active domains
  
  AC
  
  1. In Active Domain Request table, do not show domain applications that are approved. 
  
  
  Suggestion: check to make sure when you change states  on an application that the domain management page doesn't show when the status shouldn't allow it.
  
  
  ### Additional Context (optional)
  
  see [slack thread](https://cisa-corp.slack.com/archives/C05BDEA3C11/p1689089565297719)
  
  ### Issue Links
  may relate to #701 
  relates to: #818 
  _No response_
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/registrar/views/index.py`
  Content:
  ```
  1 from django.db.models import F
  2 from django.shortcuts import render
  3 
  4 from registrar.models import DomainApplication
  5 
  6 
  7 def index(request):
  8     """This page is available to anyone without logging in."""
  9     context = {}
  10     if request.user.is_authenticated:
  11         applications = DomainApplication.objects.filter(creator=request.user)
  12         context["domain_applications"] = applications
  13 
  14         domains = request.user.permissions.values(
  15             "role",
  16             pk=F("domain__id"),
  17             name=F("domain__name"),
  18             created_time=F("domain__created_at"),
  19             application_status=F("domain__domain_application__status"),
  20         )
  21         context["domains"] = domains
  22     return render(request, "home.html", context)
  23
  ```
  --- 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/src/registrar/views/index.py b/src/registrar/views/index.py
  --- a/src/registrar/views/index.py
  +++ b/src/registrar/views/index.py
  @@ -9,7 +9,10 @@
       context = {}
       if request.user.is_authenticated:
           applications = DomainApplication.objects.filter(creator=request.user)
  -        context["domain_applications"] = applications
  +        # Let's exclude the approved applications since our
  +        # domain_applications context will be used to populate
  +        # the active applications table
  +        context["domain_applications"] = applications.exclude(status="approved")
   
           domains = request.user.permissions.values(
               "role",
  
verification_info: {"golden_diff": "diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py\n--- a/src/registrar/views/index.py\n+++ b/src/registrar/views/index.py\n@@ -9,7 +9,10 @@\n     context = {}\n     if request.user.is_authenticated:\n         applications = DomainApplication.objects.filter(creator=request.user)\n-        context[\"domain_applications\"] = applications\n+        # Let's exclude the approved applications since our\n+        # domain_applications context will be used to populate\n+        # the active applications table\n+        context[\"domain_applications\"] = applications.exclude(status=\"approved\")\n \n         domains = request.user.permissions.values(\n             \"role\",\n", "issue": "Update Domain management permissions \n### Issue Description\r\n\r\nDomain management, specifically that of DNS specific information, should be reserved for approved domain requests. Currently, if an item is in the list of registered domains and the status of the associated domain request switches to something like Withdrawn/Investigating, then the user can still edit the domain information AND the domain still appears in Active domains\r\n\r\nAC\r\n\r\n1. In Active Domain Request table, do not show domain applications that are approved. \r\n\r\n\r\nSuggestion: check to make sure when you change states  on an application that the domain management page doesn't show when the status shouldn't allow it.\r\n\r\n\r\n### Additional Context (optional)\r\n\r\nsee [slack thread](https://cisa-corp.slack.com/archives/C05BDEA3C11/p1689089565297719)\r\n\r\n### Issue Links\r\nmay relate to #701 \r\nrelates to: #818 \r\n_No response_\n", "before_files": [{"content": "from django.db.models import F\nfrom django.shortcuts import render\n\nfrom registrar.models import DomainApplication\n\n\ndef index(request):\n    \"\"\"This page is available to anyone without logging in.\"\"\"\n    context = {}\n    if request.user.is_authenticated:\n        applications = DomainApplication.objects.filter(creator=request.user)\n        context[\"domain_applications\"] = applications\n\n        domains = request.user.permissions.values(\n            \"role\",\n            pk=F(\"domain__id\"),\n            name=F(\"domain__name\"),\n            created_time=F(\"domain__created_at\"),\n            application_status=F(\"domain__domain_application__status\"),\n        )\n        context[\"domains\"] = domains\n    return render(request, \"home.html\", context)\n", "path": "src/registrar/views/index.py"}], "after_files": [{"content": "from django.db.models import F\nfrom django.shortcuts import render\n\nfrom registrar.models import DomainApplication\n\n\ndef index(request):\n    \"\"\"This page is available to anyone without logging in.\"\"\"\n    context = {}\n    if request.user.is_authenticated:\n        applications = DomainApplication.objects.filter(creator=request.user)\n        # Let's exclude the approved applications since our\n        # domain_applications context will be used to populate\n        # the active applications table\n        context[\"domain_applications\"] = applications.exclude(status=\"approved\")\n\n        domains = request.user.permissions.values(\n            \"role\",\n            pk=F(\"domain__id\"),\n            name=F(\"domain__name\"),\n            created_time=F(\"domain__created_at\"),\n            application_status=F(\"domain__domain_application__status\"),\n        )\n        context[\"domains\"] = domains\n    return render(request, \"home.html\", context)\n", "path": "src/registrar/views/index.py"}]}