mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 20:48:40 +02:00
Implement reformatting nameservers from model to views
This commit is contained in:
parent
1c99101c18
commit
eeaa4bfc27
2 changed files with 7 additions and 42 deletions
|
@ -229,44 +229,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@Cache
|
|
||||||
def format_nameservers(self):
|
|
||||||
"""
|
|
||||||
Formatting nameservers for display for this domain.
|
|
||||||
|
|
||||||
Hosts are provided as a list of tuples, e.g.
|
|
||||||
|
|
||||||
[("ns1.example.com",), ("ns1.example.gov", ["0.0.0.0"])]
|
|
||||||
|
|
||||||
We want to display as:
|
|
||||||
ns1.example.gov
|
|
||||||
ns1.example.gov (0.0.0.0)
|
|
||||||
|
|
||||||
Subordinate hosts (something.your-domain.gov) MUST have IP addresses,
|
|
||||||
while non-subordinate hosts MUST NOT.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
hosts = self._get_property("hosts")
|
|
||||||
except Exception as err:
|
|
||||||
# Do not raise error when missing nameservers
|
|
||||||
# this is a standard occurence when a domain
|
|
||||||
# is first created
|
|
||||||
logger.info("Domain is missing nameservers %s" % err)
|
|
||||||
return []
|
|
||||||
|
|
||||||
hostList = []
|
|
||||||
for host in hosts:
|
|
||||||
# can remove str conversion when EPP.IP address display
|
|
||||||
# changes from IP object -> IP address
|
|
||||||
host_addrs_stringified = [str(addr) for addr in host["addrs"]]
|
|
||||||
host_addrs_str = f'({", ".join(obj for obj in host_addrs_stringified)})'
|
|
||||||
host_info_str = f'{host["name"]} \
|
|
||||||
{host_addrs_str if len(host["addrs"]) > 0 else ""}'
|
|
||||||
hostList.append(host_info_str)
|
|
||||||
return hostList
|
|
||||||
|
|
||||||
@Cache
|
@Cache
|
||||||
def nameservers(self) -> list[tuple[str, list]]:
|
def nameservers(self) -> list[tuple[str, list]]:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -57,11 +57,14 @@
|
||||||
{% if users %}
|
{% if users %}
|
||||||
<li>{{ item.user.email }}</li>
|
<li>{{ item.user.email }}</li>
|
||||||
{% elif domains %}
|
{% elif domains %}
|
||||||
<li>{{ item.0 }}
|
<li>
|
||||||
|
{{ item.0 }}
|
||||||
{% if item.1 %}
|
{% if item.1 %}
|
||||||
({% for addr in item.1 %}
|
({% spaceless %}
|
||||||
{{addr}}
|
{% for addr in item.1 %}
|
||||||
{% endfor %})
|
{{addr}}{% if not forloop.last %}, {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endspaceless %})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue