We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
On Century Detail pages, sometimes unpublished sources are listed
Visiting century/3863 while not logged in, there's a link to source/672452. When I click on it, I get a 403 Access Denied error. We need to ensure that links to sources that are inaccessible to a user are never displayed.

This bug occurs on both staging and production.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `django/cantusdb_project/main_app/views/century.py`
Content:
```
1 from django.views.generic import DetailView
2 from main_app.models import Century
3 
4 class CenturyDetailView(DetailView):
5     model = Century
6     context_object_name = "century"
7     template_name = "century_detail.html"
8
```
--- 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/django/cantusdb_project/main_app/views/century.py b/django/cantusdb_project/main_app/views/century.py
--- a/django/cantusdb_project/main_app/views/century.py
+++ b/django/cantusdb_project/main_app/views/century.py
@@ -1,7 +1,20 @@
 from django.views.generic import DetailView
-from main_app.models import Century
+from main_app.models import Century, Source
+from typing import Any
 
 class CenturyDetailView(DetailView):
     model = Century
     context_object_name = "century"
     template_name = "century_detail.html"
+
+    def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
+        context = super().get_context_data(**kwargs)
+        century = self.get_object()
+        user = self.request.user
+        display_unpublished = user.is_authenticated
+        sources = Source.objects.filter(century=century)
+        if not display_unpublished:
+            sources = sources.filter(published=True)
+        sources=sources.only("title", "id")
+        context["sources"] = sources
+        return context
\ No newline at end of file

{"golden_diff": "diff --git a/django/cantusdb_project/main_app/views/century.py b/django/cantusdb_project/main_app/views/century.py\n--- a/django/cantusdb_project/main_app/views/century.py\n+++ b/django/cantusdb_project/main_app/views/century.py\n@@ -1,7 +1,20 @@\n from django.views.generic import DetailView\n-from main_app.models import Century\n+from main_app.models import Century, Source\n+from typing import Any\n \n class CenturyDetailView(DetailView):\n     model = Century\n     context_object_name = \"century\"\n     template_name = \"century_detail.html\"\n+\n+    def get_context_data(self, **kwargs: Any) -> dict[str, Any]:\n+        context = super().get_context_data(**kwargs)\n+        century = self.get_object()\n+        user = self.request.user\n+        display_unpublished = user.is_authenticated\n+        sources = Source.objects.filter(century=century)\n+        if not display_unpublished:\n+            sources = sources.filter(published=True)\n+        sources=sources.only(\"title\", \"id\")\n+        context[\"sources\"] = sources\n+        return context\n\\ No newline at end of file\n", "issue": "On Century Detail pages, sometimes unpublished sources are listed\nVisiting century/3863 while not logged in, there's a link to source/672452. When I click on it, I get a 403 Access Denied error. We need to ensure that links to sources that are inaccessible to a user are never displayed.\r\n\r\nThis bug occurs on both staging and production.\n", "before_files": [{"content": "from django.views.generic import DetailView\nfrom main_app.models import Century\n\nclass CenturyDetailView(DetailView):\n    model = Century\n    context_object_name = \"century\"\n    template_name = \"century_detail.html\"\n", "path": "django/cantusdb_project/main_app/views/century.py"}], "after_files": [{"content": "from django.views.generic import DetailView\nfrom main_app.models import Century, Source\nfrom typing import Any\n\nclass CenturyDetailView(DetailView):\n    model = Century\n    context_object_name = \"century\"\n    template_name = \"century_detail.html\"\n\n    def get_context_data(self, **kwargs: Any) -> dict[str, Any]:\n        context = super().get_context_data(**kwargs)\n        century = self.get_object()\n        user = self.request.user\n        display_unpublished = user.is_authenticated\n        sources = Source.objects.filter(century=century)\n        if not display_unpublished:\n            sources = sources.filter(published=True)\n        sources=sources.only(\"title\", \"id\")\n        context[\"sources\"] = sources\n        return context", "path": "django/cantusdb_project/main_app/views/century.py"}]}