From 1b2f34935ab66f13c3f00f5376cecac82f2edaff Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 8 Jan 2024 18:52:35 -0800 Subject: [PATCH 1/3] added hosts to be viewable on admin for non-analysts --- src/registrar/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 364ae81f6..a90ede5c4 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -400,7 +400,8 @@ class HostIPInline(admin.StackedInline): class MyHostAdmin(AuditedAdmin): """Custom host admin class to use our inlines.""" - + search_fields = ["name","domain__name"] + search_help_text = "Search by domain or hostname." inlines = [HostIPInline] @@ -1252,7 +1253,7 @@ class DraftDomainAdmin(ListHeaderAdmin): admin.site.register(models.DraftDomain, DraftDomainAdmin) # Host and HostIP removed from django admin because changes in admin # do not propogate to registry and logic not applied -# admin.site.register(models.Host, MyHostAdmin) +admin.site.register(models.Host, MyHostAdmin) admin.site.register(models.Website, WebsiteAdmin) admin.site.register(models.PublicContact, AuditedAdmin) admin.site.register(models.DomainApplication, DomainApplicationAdmin) From 5fed6d581086456973337194e47d823ccb06d64e Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 8 Jan 2024 18:52:59 -0800 Subject: [PATCH 2/3] updated host object to not be unique --- .../migrations/0062_alter_host_name.py | 17 +++++++++++++++++ src/registrar/models/host.py | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/registrar/migrations/0062_alter_host_name.py diff --git a/src/registrar/migrations/0062_alter_host_name.py b/src/registrar/migrations/0062_alter_host_name.py new file mode 100644 index 000000000..9bdb72209 --- /dev/null +++ b/src/registrar/migrations/0062_alter_host_name.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.7 on 2024-01-09 02:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0061_domain_security_contact_registry_id"), + ] + + operations = [ + migrations.AlterField( + model_name="host", + name="name", + field=models.CharField(default=None, help_text="Fully qualified domain name", max_length=253), + ), + ] diff --git a/src/registrar/models/host.py b/src/registrar/models/host.py index 2d756111e..3b966832f 100644 --- a/src/registrar/models/host.py +++ b/src/registrar/models/host.py @@ -20,7 +20,7 @@ class Host(TimeStampedModel): null=False, blank=False, default=None, # prevent saving without a value - unique=True, + unique=False, help_text="Fully qualified domain name", ) @@ -30,3 +30,6 @@ class Host(TimeStampedModel): related_name="host", # access this Host via the Domain as `domain.host` help_text="Domain to which this host belongs", ) + + def __str__(self): + return f"{self.domain.name} {self.name}" From 409615b125fb7be6eee42a790351d236521d406b Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 8 Jan 2024 19:12:45 -0800 Subject: [PATCH 3/3] linting --- src/registrar/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index a90ede5c4..e041ef728 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -400,7 +400,8 @@ class HostIPInline(admin.StackedInline): class MyHostAdmin(AuditedAdmin): """Custom host admin class to use our inlines.""" - search_fields = ["name","domain__name"] + + search_fields = ["name", "domain__name"] search_help_text = "Search by domain or hostname." inlines = [HostIPInline]