Skip to content

Commit

Permalink
Merge pull request #1610 from cisagov/ab/hotfix-staging-unique-hosts
Browse files Browse the repository at this point in the history
HOTFIX- staging  changing host names to not be unique
  • Loading branch information
abroddrick authored Jan 10, 2024
2 parents 124b3e2 + 8585756 commit 8b06b38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down Expand Up @@ -1252,7 +1254,7 @@ class DraftDomainAdmin(ListHeaderAdmin):
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)
Expand Down
17 changes: 17 additions & 0 deletions src/registrar/migrations/0062_alter_host_name.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
5 changes: 4 additions & 1 deletion src/registrar/models/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

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

0 comments on commit 8b06b38

Please sign in to comment.