Merge remote-tracking branch 'origin/main' into nl/2136-CISA-rep-additional-details

This commit is contained in:
CocoByte 2024-06-11 13:51:44 -06:00
commit f74a8eda2b
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
11 changed files with 262 additions and 105 deletions

View file

@ -1,11 +1,15 @@
# Complete model documentation
This is an auto-generated diagram of our data models generated with the
[django-model2puml](https://github.com/sen-den/django-model2puml) library
using the command
[django-model2puml](https://github.com/sen-den/django-model2puml) library.
## How to generate the puml
1. Uncomment `puml_generator` from `INSTALLED_APPS` in settings.py and docker-compose down and up
2. Run the following command to generate a puml file
```bash
$ docker compose app ./manage.py generate_puml --include registrar
docker compose exec app ./manage.py generate_puml --include registrar
```
![Complete data models diagram](./models_diagram.svg)
@ -13,12 +17,19 @@ $ docker compose app ./manage.py generate_puml --include registrar
<details>
<summary>PlantUML source code</summary>
To regenerate this image using Docker, run
## How To regenerate the database svg image
1. Copy your puml file contents into the bottom of this file and replace the current code marked by `plantuml`
2. Run the following command
```bash
$ docker run -v $(pwd):$(pwd) -w $(pwd) -it plantuml/plantuml -tsvg models_diagram.md
docker run -v $(pwd):$(pwd) -w $(pwd) -it plantuml/plantuml -tsvg models_diagram.md
```
3. Remove the puml file from earlier (if you still have it)
4. Commit the new image and the md file
```plantuml
@startuml
class "registrar.Contact <Registrar>" as registrar.Contact #d6f4e9 {
@ -28,17 +39,97 @@ class "registrar.Contact <Registrar>" as registrar.Contact #d6f4e9 {
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
~ user (OneToOneField)
+ first_name (TextField)
+ middle_name (TextField)
+ last_name (TextField)
+ title (TextField)
+ email (TextField)
+ first_name (CharField)
+ middle_name (CharField)
+ last_name (CharField)
+ title (CharField)
+ email (EmailField)
+ phone (PhoneNumberField)
--
}
registrar.Contact -- registrar.User
class "registrar.Host <Registrar>" as registrar.Host #d6f4e9 {
host
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ name (CharField)
~ domain (ForeignKey)
--
}
registrar.Host -- registrar.Domain
class "registrar.HostIP <Registrar>" as registrar.HostIP #d6f4e9 {
host ip
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ address (CharField)
~ host (ForeignKey)
--
}
registrar.HostIP -- registrar.Host
class "registrar.PublicContact <Registrar>" as registrar.PublicContact #d6f4e9 {
public contact
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ contact_type (CharField)
+ registry_id (CharField)
~ domain (ForeignKey)
+ name (CharField)
+ org (CharField)
+ street1 (CharField)
+ street2 (CharField)
+ street3 (CharField)
+ city (CharField)
+ sp (CharField)
+ pc (CharField)
+ cc (CharField)
+ email (EmailField)
+ voice (CharField)
+ fax (CharField)
+ pw (CharField)
--
}
registrar.PublicContact -- registrar.Domain
class "registrar.Domain <Registrar>" as registrar.Domain #d6f4e9 {
domain
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ name (DomainField)
+ state (FSMField)
+ expiration_date (DateField)
+ security_contact_registry_id (TextField)
+ deleted (DateField)
+ first_ready (DateField)
--
}
class "registrar.FederalAgency <Registrar>" as registrar.FederalAgency #d6f4e9 {
Federal agency
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ agency (CharField)
--
}
class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
domain request
--
@ -46,24 +137,25 @@ class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ status (FSMField)
+ rejection_reason (TextField)
~ federal_agency (ForeignKey)
~ creator (ForeignKey)
~ investigator (ForeignKey)
+ generic_org_type (CharField)
+ is_election_board (BooleanField)
+ organization_type (CharField)
+ federally_recognized_tribe (BooleanField)
+ state_recognized_tribe (BooleanField)
+ tribe_name (TextField)
+ federal_agency (TextField)
+ tribe_name (CharField)
+ federal_type (CharField)
+ is_election_board (BooleanField)
+ organization_name (TextField)
+ address_line1 (TextField)
+ organization_name (CharField)
+ address_line1 (CharField)
+ address_line2 (CharField)
+ city (TextField)
+ city (CharField)
+ state_territory (CharField)
+ zipcode (CharField)
+ urbanization (TextField)
+ type_of_work (TextField)
+ more_organization_information (TextField)
+ urbanization (CharField)
+ about_your_organization (TextField)
~ authorizing_official (ForeignKey)
~ approved_domain (OneToOneField)
~ requested_domain (OneToOneField)
@ -71,17 +163,23 @@ class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
+ purpose (TextField)
+ no_other_contacts_rationale (TextField)
+ anything_else (TextField)
+ has_anything_else_text (BooleanField)
+ cisa_representative_email (EmailField)
+ has_cisa_representative (BooleanField)
+ is_policy_acknowledged (BooleanField)
+ submission_date (DateField)
+ notes (TextField)
# current_websites (ManyToManyField)
# alternative_domains (ManyToManyField)
# other_contacts (ManyToManyField)
--
}
registrar.DomainRequest -- registrar.FederalAgency
registrar.DomainRequest -- registrar.User
registrar.DomainRequest -- registrar.User
registrar.DomainRequest -- registrar.Contact
registrar.DomainRequest -- registrar.DraftDomain
registrar.DomainRequest -- registrar.Domain
registrar.DomainRequest -- registrar.DraftDomain
registrar.DomainRequest -- registrar.Contact
registrar.DomainRequest *--* registrar.Website
registrar.DomainRequest *--* registrar.Website
@ -94,35 +192,37 @@ class "registrar.DomainInformation <Registrar>" as registrar.DomainInformation #
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
~ federal_agency (ForeignKey)
~ creator (ForeignKey)
~ domain_request (OneToOneField)
+ generic_org_type (CharField)
+ organization_type (CharField)
+ federally_recognized_tribe (BooleanField)
+ state_recognized_tribe (BooleanField)
+ tribe_name (TextField)
+ federal_agency (TextField)
+ tribe_name (CharField)
+ federal_type (CharField)
+ is_election_board (BooleanField)
+ organization_name (TextField)
+ address_line1 (TextField)
+ organization_name (CharField)
+ address_line1 (CharField)
+ address_line2 (CharField)
+ city (TextField)
+ city (CharField)
+ state_territory (CharField)
+ zipcode (CharField)
+ urbanization (TextField)
+ type_of_work (TextField)
+ more_organization_information (TextField)
+ urbanization (CharField)
+ about_your_organization (TextField)
~ authorizing_official (ForeignKey)
~ domain (OneToOneField)
~ submitter (ForeignKey)
+ purpose (TextField)
+ no_other_contacts_rationale (TextField)
+ anything_else (TextField)
+ cisa_representative_email (EmailField)
+ is_policy_acknowledged (BooleanField)
+ security_email (EmailField)
+ notes (TextField)
# other_contacts (ManyToManyField)
--
}
registrar.DomainInformation -- registrar.FederalAgency
registrar.DomainInformation -- registrar.User
registrar.DomainInformation -- registrar.DomainRequest
registrar.DomainInformation -- registrar.Contact
@ -142,43 +242,6 @@ class "registrar.DraftDomain <Registrar>" as registrar.DraftDomain #d6f4e9 {
}
class "registrar.Domain <Registrar>" as registrar.Domain #d6f4e9 {
domain
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ name (CharField)
--
}
class "registrar.HostIP <Registrar>" as registrar.HostIP #d6f4e9 {
host ip
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ address (CharField)
~ host (ForeignKey)
--
}
registrar.HostIP -- registrar.Host
class "registrar.Host <Registrar>" as registrar.Host #d6f4e9 {
host
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ name (CharField)
~ domain (ForeignKey)
--
}
registrar.Host -- registrar.Domain
class "registrar.UserDomainRole <Registrar>" as registrar.UserDomainRole #d6f4e9 {
user domain role
--
@ -208,47 +271,49 @@ class "registrar.DomainInvitation <Registrar>" as registrar.DomainInvitation #d6
registrar.DomainInvitation -- registrar.Domain
class "registrar.Nameserver <Registrar>" as registrar.Nameserver #d6f4e9 {
nameserver
class "registrar.TransitionDomain <Registrar>" as registrar.TransitionDomain #d6f4e9 {
transition domain
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ name (CharField)
~ domain (ForeignKey)
~ host_ptr (OneToOneField)
+ username (CharField)
+ domain_name (CharField)
+ status (CharField)
+ email_sent (BooleanField)
+ processed (BooleanField)
+ generic_org_type (CharField)
+ organization_name (CharField)
+ federal_type (CharField)
+ federal_agency (CharField)
+ epp_creation_date (DateField)
+ epp_expiration_date (DateField)
+ first_name (CharField)
+ middle_name (CharField)
+ last_name (CharField)
+ title (CharField)
+ email (EmailField)
+ phone (CharField)
+ address_line (CharField)
+ city (CharField)
+ state_territory (CharField)
+ zipcode (CharField)
--
}
registrar.Nameserver -- registrar.Domain
registrar.Nameserver -- registrar.Host
class "registrar.PublicContact <Registrar>" as registrar.PublicContact #d6f4e9 {
public contact
class "registrar.VerifiedByStaff <Registrar>" as registrar.VerifiedByStaff #d6f4e9 {
verified by staff
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ contact_type (CharField)
+ registry_id (CharField)
~ domain (ForeignKey)
+ name (TextField)
+ org (TextField)
+ street1 (TextField)
+ street2 (TextField)
+ street3 (TextField)
+ city (TextField)
+ sp (TextField)
+ pc (TextField)
+ cc (TextField)
+ email (TextField)
+ voice (TextField)
+ fax (TextField)
+ pw (TextField)
+ email (EmailField)
~ requestor (ForeignKey)
+ notes (TextField)
--
}
registrar.PublicContact -- registrar.Domain
registrar.VerifiedByStaff -- registrar.User
class "registrar.User <Registrar>" as registrar.User #d6f4e9 {
@ -265,7 +330,11 @@ class "registrar.User <Registrar>" as registrar.User #d6f4e9 {
+ is_staff (BooleanField)
+ is_active (BooleanField)
+ date_joined (DateTimeField)
+ status (CharField)
+ phone (PhoneNumberField)
+ middle_name (CharField)
+ title (CharField)
+ verification_type (CharField)
# groups (ManyToManyField)
# user_permissions (ManyToManyField)
# domains (ManyToManyField)
@ -274,6 +343,17 @@ class "registrar.User <Registrar>" as registrar.User #d6f4e9 {
registrar.User *--* registrar.Domain
class "registrar.UserGroup <Registrar>" as registrar.UserGroup #d6f4e9 {
User group
--
- id (AutoField)
+ name (CharField)
~ group_ptr (OneToOneField)
# permissions (ManyToManyField)
--
}
class "registrar.Website <Registrar>" as registrar.Website #d6f4e9 {
website
--
@ -285,6 +365,29 @@ class "registrar.Website <Registrar>" as registrar.Website #d6f4e9 {
}
class "registrar.WaffleFlag <Registrar>" as registrar.WaffleFlag #d6f4e9 {
waffle flag
--
+ id (BigAutoField)
+ name (CharField)
+ everyone (BooleanField)
+ percent (DecimalField)
+ testing (BooleanField)
+ superusers (BooleanField)
+ staff (BooleanField)
+ authenticated (BooleanField)
+ languages (TextField)
+ rollout (BooleanField)
+ note (TextField)
+ created (DateTimeField)
+ modified (DateTimeField)
# groups (ManyToManyField)
# users (ManyToManyField)
--
}
registrar.WaffleFlag *--* registrar.User
@enduml
```

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Before After
Before After

View file

@ -106,6 +106,12 @@ class UserFixture:
"last_name": "Orr",
"email": "riley+320@truss.works",
},
{
"username": "76612d84-66b0-4ae9-9870-81e98b9858b6",
"first_name": "Anna",
"last_name": "Gingle",
"email": "annagingle@truss.works",
},
]
STAFF = [
@ -194,6 +200,12 @@ class UserFixture:
"last_name": "Orr-Analyst",
"email": "riley+321@truss.works",
},
{
"username": "e1e350b1-cfc1-4753-a6cb-3ae6d912f99c",
"first_name": "Anna-Analyst",
"last_name": "Gingle-Analyst",
"email": "annagingle+analyst@truss.works",
},
]
def load_users(cls, users, group_name, are_superusers=False):

View file

@ -16,6 +16,7 @@ from registrar.forms.utility.wizard_form_helper import (
from registrar.models import Contact, DomainRequest, DraftDomain, Domain, FederalAgency
from registrar.templatetags.url_helpers import public_site_url
from registrar.utility.enums import ValidationReturnType
from registrar.utility.constants import BranchChoices
logger = logging.getLogger(__name__)
@ -67,7 +68,7 @@ class TribalGovernmentForm(RegistrarForm):
class OrganizationFederalForm(RegistrarForm):
federal_type = forms.ChoiceField(
choices=DomainRequest.BranchChoices.choices,
choices=BranchChoices.choices,
widget=forms.RadioSelect,
error_messages={"required": ("Select the part of the federal government your organization is in.")},
)

View file

@ -19,6 +19,7 @@ from registrar.models.domain_request import DomainRequest
from registrar.models.domain_information import DomainInformation
from registrar.models.user import User
from registrar.models.federal_agency import FederalAgency
from registrar.utility.constants import BranchChoices
logger = logging.getLogger(__name__)
@ -819,7 +820,7 @@ class Command(BaseCommand):
invitation.save()
valid_org_choices = [(name, value) for name, value in DomainRequest.OrganizationChoices.choices]
valid_fed_choices = [value for name, value in DomainRequest.BranchChoices.choices]
valid_fed_choices = [value for name, value in BranchChoices.choices]
valid_agency_choices = FederalAgency.objects.all()
# ======================================================
# ================= DOMAIN INFORMATION =================

View file

@ -0,0 +1,24 @@
# Generated by Django 4.2.10 on 2024-06-11 15:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("registrar", "0098_alter_domainrequest_status"),
]
operations = [
migrations.AddField(
model_name="federalagency",
name="federal_type",
field=models.CharField(
blank=True,
choices=[("executive", "Executive"), ("judicial", "Judicial"), ("legislative", "Legislative")],
help_text="Federal agency type (executive, judicial, legislative, etc.)",
max_length=20,
null=True,
),
),
]

View file

@ -3,6 +3,8 @@ from django.db import transaction
from registrar.models.utility.domain_helper import DomainHelper
from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper
from registrar.utility.constants import BranchChoices
from .domain_request import DomainRequest
from .utility.time_stamped_model import TimeStampedModel
@ -37,8 +39,6 @@ class DomainInformation(TimeStampedModel):
# use the short names in Django admin
OrganizationChoices = DomainRequest.OrganizationChoices
BranchChoices = DomainRequest.BranchChoices
federal_agency = models.ForeignKey(
"registrar.FederalAgency",
on_delete=models.PROTECT,

View file

@ -12,6 +12,7 @@ from registrar.models.domain import Domain
from registrar.models.federal_agency import FederalAgency
from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
from registrar.utility.constants import BranchChoices
from .utility.time_stamped_model import TimeStampedModel
from ..utility.email import send_templated_email, EmailSendingError
@ -234,11 +235,6 @@ class DomainRequest(TimeStampedModel):
"School district: a school district that is not part of a local government",
)
class BranchChoices(models.TextChoices):
EXECUTIVE = "executive", "Executive"
JUDICIAL = "judicial", "Judicial"
LEGISLATIVE = "legislative", "Legislative"
class RejectionReasons(models.TextChoices):
DOMAIN_PURPOSE = "purpose_not_met", "Purpose requirements not met"
REQUESTOR = "requestor_not_eligible", "Requestor not eligible to make request"
@ -1086,6 +1082,8 @@ class DomainRequest(TimeStampedModel):
is_complete = self._is_city_complete()
case DomainRequest.OrganizationChoices.SPECIAL_DISTRICT:
is_complete = self._is_special_district_complete()
case DomainRequest.OrganizationChoices.SCHOOL_DISTRICT:
is_complete = True
case _:
# NOTE: Shouldn't happen, this is only if somehow they didn't choose an org type
is_complete = False

View file

@ -1,6 +1,7 @@
from .utility.time_stamped_model import TimeStampedModel
from django.db import models
import logging
from registrar.utility.constants import BranchChoices
logger = logging.getLogger(__name__)
@ -16,6 +17,14 @@ class FederalAgency(TimeStampedModel):
help_text="Federal agency",
)
federal_type = models.CharField(
max_length=20,
choices=BranchChoices.choices,
null=True,
blank=True,
help_text="Federal agency type (executive, judicial, legislative, etc.)",
)
def __str__(self) -> str:
return f"{self.agency}"

View file

@ -19,6 +19,8 @@ from registrar.models import (
import boto3_mocking
from registrar.models.transition_domain import TransitionDomain
from registrar.models.verified_by_staff import VerifiedByStaff # type: ignore
from registrar.utility.constants import BranchChoices
from .common import MockSESClient, less_console_noise, completed_domain_request, set_domain_request_investigators
from django_fsm import TransitionNotAllowed
@ -124,7 +126,7 @@ class TestDomainRequest(TestCase):
creator=user,
investigator=user,
generic_org_type=DomainRequest.OrganizationChoices.FEDERAL,
federal_type=DomainRequest.BranchChoices.EXECUTIVE,
federal_type=BranchChoices.EXECUTIVE,
is_election_board=False,
organization_name="Test",
address_line1="100 Main St.",
@ -152,7 +154,7 @@ class TestDomainRequest(TestCase):
information = DomainInformation.objects.create(
creator=user,
generic_org_type=DomainInformation.OrganizationChoices.FEDERAL,
federal_type=DomainInformation.BranchChoices.EXECUTIVE,
federal_type=BranchChoices.EXECUTIVE,
is_election_board=False,
organization_name="Test",
address_line1="100 Main St.",

View file

@ -0,0 +1,7 @@
from django.db import models
class BranchChoices(models.TextChoices):
EXECUTIVE = "executive", "Executive"
JUDICIAL = "judicial", "Judicial"
LEGISLATIVE = "legislative", "Legislative"