mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 17:28:31 +02:00
Small changes
This commit is contained in:
parent
80d37777c0
commit
7abc9bdf7d
2 changed files with 14 additions and 42 deletions
|
@ -114,12 +114,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
# the state is indeterminate
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
# the ready state for a domain object
|
||||
READY = "ready"
|
||||
|
||||
# when a domain is on hold
|
||||
ONHOLD = "onhold"
|
||||
|
||||
class Cache(property):
|
||||
"""
|
||||
Python descriptor to turn class methods into properties.
|
||||
|
@ -317,17 +311,13 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
"""Time to renew. Not implemented."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@transition(field="state", source=[State.READY], target=State.ONHOLD)
|
||||
def place_client_hold(self):
|
||||
"""This domain should not be active."""
|
||||
# This method is changing the state of the domain in registrar
|
||||
# TODO: implement EPP call
|
||||
raise NotImplementedError("This is not implemented yet.")
|
||||
|
||||
@transition(field="state", source=[State.ONHOLD], target=State.READY)
|
||||
def remove_client_hold(self):
|
||||
"""This domain is okay to be active."""
|
||||
# This method is changing the state of the domain in registrar
|
||||
# TODO: implement EPP call
|
||||
raise NotImplementedError()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
@ -482,10 +472,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
""" Gets the default security contact. """
|
||||
contact = PublicContact.get_default_security()
|
||||
contact.domain = self
|
||||
# if you invert the logic in get_contact_default
|
||||
# such that the match statement calls from PublicContact,
|
||||
# you can reduce these to one liners:
|
||||
# self.get_contact_default(PublicContact.ContactTypeChoices.SECURITY)
|
||||
return contact
|
||||
|
||||
def get_default_administrative_contact(self):
|
||||
|
@ -506,30 +492,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
contact.domain = self
|
||||
return contact
|
||||
|
||||
def get_contact_default(self, contact_type_choice: PublicContact.ContactTypeChoices) -> PublicContact:
|
||||
""" Returns a default contact based off the contact_type_choice.
|
||||
Used
|
||||
|
||||
contact_type_choice is a literal in PublicContact.ContactTypeChoices,
|
||||
for instance: PublicContact.ContactTypeChoices.SECURITY.
|
||||
|
||||
If you wanted to get the default contact for Security, you would call:
|
||||
get_contact_default(PublicContact.ContactTypeChoices.SECURITY),
|
||||
or get_contact_default("security")
|
||||
"""
|
||||
choices = PublicContact.ContactTypeChoices
|
||||
contact: PublicContact
|
||||
match(contact_type_choice):
|
||||
case choices.ADMINISTRATIVE:
|
||||
contact = self.get_default_administrative_contact()
|
||||
case choices.SECURITY:
|
||||
contact = self.get_default_security_contact()
|
||||
case choices.TECHNICAL:
|
||||
contact = self.get_default_technical_contact()
|
||||
case choices.REGISTRANT:
|
||||
contact = self.get_default_registrant_contact()
|
||||
return contact
|
||||
|
||||
def grab_contact_in_keys(self, contacts, check_type, get_from_registry=True):
|
||||
""" Grabs a contact object.
|
||||
Returns None if nothing is found.
|
||||
|
|
|
@ -20,6 +20,7 @@ from registrar.models import (
|
|||
User,
|
||||
UserDomainRole,
|
||||
)
|
||||
from registrar.models.public_contact import PublicContact
|
||||
|
||||
from ..forms import (
|
||||
ContactForm,
|
||||
|
@ -246,7 +247,10 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
|||
"""The initial value for the form."""
|
||||
domain = self.get_object()
|
||||
initial = super().get_initial()
|
||||
initial["security_email"] = domain.security_contact.email
|
||||
security_email = ""
|
||||
if(domain.security_contact.email is not None):
|
||||
security_email = domain.security_contact.email
|
||||
initial["security_email"] = security_email
|
||||
return initial
|
||||
|
||||
def get_success_url(self):
|
||||
|
@ -269,7 +273,13 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
|
|||
# Set the security email from the form
|
||||
new_email = form.cleaned_data.get("security_email", "")
|
||||
domain = self.get_object()
|
||||
contact = domain.security_contact
|
||||
|
||||
contact: PublicContact
|
||||
if domain.security_contact is not None:
|
||||
contact = domain.security_contact
|
||||
else:
|
||||
contact = domain.get_default_security_contact()
|
||||
|
||||
contact.email = new_email
|
||||
contact.save()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue