From 1d1b1a22b4f2b70c98039398f1b9603b637e77d7 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Fri, 20 Dec 2024 08:57:45 -0600 Subject: [PATCH] Add link to project on admin page --- projects/admin.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/admin.py b/projects/admin.py index 5e3b532c..0b0c804a 100644 --- a/projects/admin.py +++ b/projects/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin from django.utils.html import format_html +from django.urls import reverse from allocations.models import Allocation from projects.models import ( @@ -218,7 +219,24 @@ class ProjectAdmin(admin.ModelAdmin): list_display = ["charge_code", "pi", "nickname", "title"] search_fields = ["charge_code", "pi__username", "pi__email", "nickname", "title"] list_filter = ["tag"] - readonly_fields = ["charge_code", "automatically_tagged", "join_url"] + readonly_fields = [ + "charge_code_link", + "automatically_tagged", + "join_url", + ] + fields = [ + "charge_code_link", + "title", + "nickname", + "description", + "pi", + "join_url", + ] + + def charge_code_link(self, obj): + return format_html( + f'{obj.charge_code}' + ) def join_url(self, obj): return format_html(