Merge pull request #1610 from cisagov/ab/hotfix-staging-unique-hosts

HOTFIX- staging  changing host names to not be unique
This commit is contained in:
Alysia Broddrick 2024-01-09 19:58:53 -08:00 committed by GitHub
commit 8b06b38dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -401,6 +401,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 +1254,7 @@ admin.site.register(models.Domain, DomainAdmin)
admin.site.register(models.DraftDomain, DraftDomainAdmin)
# Host and HostIP removed from django admin because changes in admin
# do not propagate 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)

View file

@ -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),
),
]

View file

@ -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}"