mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-03 08:22:18 +02:00
Cleanup
This commit is contained in:
parent
cb2c3c1d1e
commit
1edc21330d
4 changed files with 7 additions and 29 deletions
|
@ -385,12 +385,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
self._make_contact_in_registry(contact=contact)
|
||||
self._update_domain_with_contact(contact, rem=False)
|
||||
|
||||
def get_default_security_contact(self):
|
||||
logger.info("getting default sec contact")
|
||||
contact = PublicContact.get_default_security()
|
||||
contact.domain = self
|
||||
return contact
|
||||
|
||||
def _update_epp_contact(self, contact: PublicContact):
|
||||
"""Sends UpdateContact to update the actual contact object,
|
||||
domain object remains unaffected
|
||||
|
@ -665,7 +659,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
return None
|
||||
|
||||
if contact_type is None:
|
||||
raise ValueError(f"contact_type is None")
|
||||
raise ValueError("contact_type is None")
|
||||
|
||||
logger.debug(f"map_epp_contact_to_public_contact contact -> {contact}")
|
||||
logger.debug(f"What is the type? {type(contact)}")
|
||||
|
@ -677,7 +671,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
addr = postal_info.addr
|
||||
streets = {}
|
||||
if addr is not None and addr.street is not None:
|
||||
# 'zips' two lists together. For instance, (('street1', 'some_value_here'), ('street2', 'some_value_here'))
|
||||
# 'zips' two lists together.
|
||||
# For instance, (('street1', 'some_value_here'), ('street2', 'some_value_here'))
|
||||
# Dict then converts this to a useable kwarg which we can pass in
|
||||
streets = dict(
|
||||
zip_longest(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from dataclasses import dataclass
|
||||
import datetime
|
||||
import os
|
||||
import logging
|
||||
|
@ -634,8 +633,6 @@ class MockEppLib(TestCase):
|
|||
return MagicMock(res_data=[self.InfoDomainWithContacts])
|
||||
elif isinstance(_request, commands.InfoContact):
|
||||
mocked_result = self.mockDataInfoContact
|
||||
l = getattr(_request, "contact_type", None)
|
||||
logger.debug(f"unuiquq {_request.__dict__}")
|
||||
if getattr(_request, "id", None) in PublicContact.ContactTypeChoices:
|
||||
desired_type = getattr(_request, "id", None)
|
||||
mocked_result = self.dummyInfoContactResultData(
|
||||
|
|
|
@ -450,20 +450,16 @@ class TestRegistrantContacts(MockEppLib):
|
|||
|
||||
def test_contact_getters_cache(self):
|
||||
"""
|
||||
Scenario: A user is grabbing a domain, which is cached, that has multiple contact objects
|
||||
Scenario: A user is grabbing a domain that has multiple contact objects
|
||||
When each contact is retrieved from cache
|
||||
Then the user retrieves the correct contact objects
|
||||
"""
|
||||
domain, _ = Domain.objects.get_or_create(name="freeman.gov")
|
||||
|
||||
# the cached contacts and hosts should be dictionaries of what is passed to them
|
||||
# expectedPublicContactDict = {'id': None, 'created_at': None, 'updated_at': None, 'contact_type': PublicContact.ContactTypeChoices.SECURITY, 'registry_id': 'freeman', 'domain_id': 2, 'name': 'Robert The Villain', 'org': 'Skim Milk', 'street1': 'Evil street1', 'street2': 'Evil street2', 'street3': 'evil street3', 'city': 'Cityofdoom', 'sp': 'sp', 'pc': 'pc', 'cc': 'cc', 'email': 'awful@skimmilk.com', 'voice': 'voice', 'fax': '+1-212-9876543', 'pw': 'fakepw'}
|
||||
|
||||
security = PublicContact.get_default_security()
|
||||
security.email = "security@mail.gov"
|
||||
security.domain = domain
|
||||
security.save()
|
||||
# expected_security_contact = PublicContact(**expectedPublicContactDict)
|
||||
expected_security_contact = security
|
||||
domain.security_contact = security
|
||||
|
||||
|
@ -498,7 +494,7 @@ class TestRegistrantContacts(MockEppLib):
|
|||
@skip("not implemented yet")
|
||||
def test_contact_getters_registry(self):
|
||||
"""
|
||||
Scenario: A user is grabbing a domain, which does not exist in cache, that has multiple contact objects
|
||||
Scenario: A user is grabbing a domain that has multiple contact objects
|
||||
When the domain is retrieved from cache
|
||||
Then the user retrieves the correct domain object
|
||||
"""
|
||||
|
|
|
@ -20,7 +20,6 @@ from registrar.models import (
|
|||
User,
|
||||
UserDomainRole,
|
||||
)
|
||||
from registrar.models.public_contact import PublicContact
|
||||
|
||||
from ..forms import (
|
||||
ContactForm,
|
||||
|
@ -251,10 +250,7 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
|||
"""The initial value for the form."""
|
||||
domain = self.get_object()
|
||||
initial = super().get_initial()
|
||||
security_email = ""
|
||||
if(domain.security_contact.email is not None):
|
||||
security_email = domain.security_contact.email
|
||||
initial["security_email"] = security_email
|
||||
initial["security_email"] = domain.security_contact.email
|
||||
return initial
|
||||
|
||||
def get_success_url(self):
|
||||
|
@ -278,13 +274,7 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
|||
new_email = form.cleaned_data.get("security_email", "")
|
||||
|
||||
domain = self.get_object()
|
||||
|
||||
contact: PublicContact
|
||||
if domain.security_contact is not None:
|
||||
contact = domain.security_contact
|
||||
else:
|
||||
contact = domain.get_default_security_contact()
|
||||
|
||||
contact = domain.security_contact
|
||||
contact.email = new_email
|
||||
contact.save()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue