mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 10:46:06 +02:00
Add Branchchoices to constants and add in new federal type to federal agency model
This commit is contained in:
parent
102ae43310
commit
4eabb98297
9 changed files with 52 additions and 11 deletions
|
@ -24,6 +24,7 @@ from registrar.views.utility.mixins import OrderableFieldsMixin
|
|||
from django.contrib.admin.views.main import ORDER_VAR
|
||||
from registrar.widgets import NoAutocompleteFilteredSelectMultiple
|
||||
from . import models
|
||||
from .models import FederalAgency
|
||||
from auditlog.models import LogEntry # type: ignore
|
||||
from auditlog.admin import LogEntryAdmin # type: ignore
|
||||
from django_fsm import TransitionNotAllowed # type: ignore
|
||||
|
|
|
@ -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 utils.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.")},
|
||||
)
|
||||
|
|
|
@ -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 utils.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 =================
|
||||
|
|
24
src/registrar/migrations/0099_federalagency_federal_type.py
Normal file
24
src/registrar/migrations/0099_federalagency_federal_type.py
Normal 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,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -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 utils.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,
|
||||
|
|
|
@ -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 utils.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"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from .utility.time_stamped_model import TimeStampedModel
|
||||
from django.db import models
|
||||
import logging
|
||||
from utils.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}"
|
||||
|
||||
|
|
|
@ -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 utils.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.",
|
||||
|
|
7
src/utils/constants.py
Normal file
7
src/utils/constants.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class BranchChoices(models.TextChoices):
|
||||
EXECUTIVE = "executive", "Executive"
|
||||
JUDICIAL = "judicial", "Judicial"
|
||||
LEGISLATIVE = "legislative", "Legislative"
|
Loading…
Add table
Add a link
Reference in a new issue