mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-03 08:22:18 +02:00
Merge remote-tracking branch 'origin/main' into nl/2239-additional-details-required-messaging
This commit is contained in:
commit
1e00586d7b
40 changed files with 1595 additions and 355 deletions
|
@ -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
|
||||
```
|
||||
|
||||

|
||||
|
@ -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 |
|
@ -217,6 +217,7 @@ class DomainRequestAdminForm(forms.ModelForm):
|
|||
status = cleaned_data.get("status")
|
||||
investigator = cleaned_data.get("investigator")
|
||||
rejection_reason = cleaned_data.get("rejection_reason")
|
||||
action_needed_reason = cleaned_data.get("action_needed_reason")
|
||||
|
||||
# Get the old status
|
||||
initial_status = self.initial.get("status", None)
|
||||
|
@ -240,6 +241,8 @@ class DomainRequestAdminForm(forms.ModelForm):
|
|||
# If the status is rejected, a rejection reason must exist
|
||||
if status == DomainRequest.DomainRequestStatus.REJECTED:
|
||||
self._check_for_valid_rejection_reason(rejection_reason)
|
||||
elif status == DomainRequest.DomainRequestStatus.ACTION_NEEDED:
|
||||
self._check_for_valid_action_needed_reason(action_needed_reason)
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
@ -263,6 +266,18 @@ class DomainRequestAdminForm(forms.ModelForm):
|
|||
|
||||
return is_valid
|
||||
|
||||
def _check_for_valid_action_needed_reason(self, action_needed_reason) -> bool:
|
||||
"""
|
||||
Checks if the action_needed_reason field is not none.
|
||||
Adds form errors on failure.
|
||||
"""
|
||||
is_valid = action_needed_reason is not None and action_needed_reason != ""
|
||||
if not is_valid:
|
||||
error_message = FSMDomainRequestError.get_error_message(FSMErrorCodes.NO_ACTION_NEEDED_REASON)
|
||||
self.add_error("action_needed_reason", error_message)
|
||||
|
||||
return is_valid
|
||||
|
||||
def _check_for_valid_investigator(self, investigator) -> bool:
|
||||
"""
|
||||
Checks if the investigator field is not none, and is staff.
|
||||
|
@ -1166,6 +1181,8 @@ class DomainInvitationAdmin(ListHeaderAdmin):
|
|||
# error.
|
||||
readonly_fields = ["status"]
|
||||
|
||||
autocomplete_fields = ["domain"]
|
||||
|
||||
change_form_template = "django/admin/email_clipboard_change_form.html"
|
||||
|
||||
# Select domain invitations to change -> Domain invitations
|
||||
|
@ -1466,6 +1483,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"fields": [
|
||||
"status",
|
||||
"rejection_reason",
|
||||
"action_needed_reason",
|
||||
"investigator",
|
||||
"creator",
|
||||
"submitter",
|
||||
|
@ -1482,6 +1500,8 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"authorizing_official",
|
||||
"other_contacts",
|
||||
"no_other_contacts_rationale",
|
||||
"cisa_representative_first_name",
|
||||
"cisa_representative_last_name",
|
||||
"cisa_representative_email",
|
||||
]
|
||||
},
|
||||
|
@ -1557,6 +1577,8 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"no_other_contacts_rationale",
|
||||
"anything_else",
|
||||
"is_policy_acknowledged",
|
||||
"cisa_representative_first_name",
|
||||
"cisa_representative_last_name",
|
||||
"cisa_representative_email",
|
||||
]
|
||||
autocomplete_fields = [
|
||||
|
@ -1668,6 +1690,8 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
# The opposite of this condition is acceptable (rejected -> other status and rejection_reason)
|
||||
# because we clean up the rejection reason in the transition in the model.
|
||||
error_message = FSMDomainRequestError.get_error_message(FSMErrorCodes.NO_REJECTION_REASON)
|
||||
elif obj.status == models.DomainRequest.DomainRequestStatus.ACTION_NEEDED and not obj.action_needed_reason:
|
||||
error_message = FSMDomainRequestError.get_error_message(FSMErrorCodes.NO_ACTION_NEEDED_REASON)
|
||||
else:
|
||||
# This is an fsm in model which will throw an error if the
|
||||
# transition condition is violated, so we roll back the
|
||||
|
|
|
@ -300,42 +300,66 @@ function initializeWidgetOnList(list, parentId) {
|
|||
*/
|
||||
(function (){
|
||||
let rejectionReasonFormGroup = document.querySelector('.field-rejection_reason')
|
||||
let actionNeededReasonFormGroup = document.querySelector('.field-action_needed_reason');
|
||||
|
||||
if (rejectionReasonFormGroup) {
|
||||
if (rejectionReasonFormGroup && actionNeededReasonFormGroup) {
|
||||
let statusSelect = document.getElementById('id_status')
|
||||
let isRejected = statusSelect.value == "rejected"
|
||||
let isActionNeeded = statusSelect.value == "action needed"
|
||||
|
||||
// Initial handling of rejectionReasonFormGroup display
|
||||
if (statusSelect.value != 'rejected')
|
||||
rejectionReasonFormGroup.style.display = 'none';
|
||||
showOrHideObject(rejectionReasonFormGroup, show=isRejected)
|
||||
showOrHideObject(actionNeededReasonFormGroup, show=isActionNeeded)
|
||||
|
||||
// Listen to change events and handle rejectionReasonFormGroup display, then save status to session storage
|
||||
statusSelect.addEventListener('change', function() {
|
||||
if (statusSelect.value == 'rejected') {
|
||||
rejectionReasonFormGroup.style.display = 'block';
|
||||
sessionStorage.removeItem('hideRejectionReason');
|
||||
} else {
|
||||
rejectionReasonFormGroup.style.display = 'none';
|
||||
sessionStorage.setItem('hideRejectionReason', 'true');
|
||||
}
|
||||
// Show the rejection reason field if the status is rejected.
|
||||
// Then track if its shown or hidden in our session cache.
|
||||
isRejected = statusSelect.value == "rejected"
|
||||
showOrHideObject(rejectionReasonFormGroup, show=isRejected)
|
||||
addOrRemoveSessionBoolean("showRejectionReason", add=isRejected)
|
||||
|
||||
isActionNeeded = statusSelect.value == "action needed"
|
||||
showOrHideObject(actionNeededReasonFormGroup, show=isActionNeeded)
|
||||
addOrRemoveSessionBoolean("showActionNeededReason", add=isActionNeeded)
|
||||
});
|
||||
|
||||
// Listen to Back/Forward button navigation and handle rejectionReasonFormGroup display based on session storage
|
||||
|
||||
// When you navigate using forward/back after changing status but not saving, when you land back on the DA page the
|
||||
// status select will say (for example) Rejected but the selected option can be something else. To manage the show/hide
|
||||
// accurately for this edge case, we use cache and test for the back/forward navigation.
|
||||
const observer = new PerformanceObserver((list) => {
|
||||
list.getEntries().forEach((entry) => {
|
||||
if (entry.type === "back_forward") {
|
||||
let showRejectionReason = sessionStorage.getItem("showRejectionReason") !== null
|
||||
showOrHideObject(rejectionReasonFormGroup, show=showRejectionReason)
|
||||
|
||||
let showActionNeededReason = sessionStorage.getItem("showActionNeededReason") !== null
|
||||
showOrHideObject(actionNeededReasonFormGroup, show=showActionNeededReason)
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe({ type: "navigation" });
|
||||
}
|
||||
|
||||
// Listen to Back/Forward button navigation and handle rejectionReasonFormGroup display based on session storage
|
||||
// Adds or removes the display-none class to object depending on the value of boolean show
|
||||
function showOrHideObject(object, show){
|
||||
if (show){
|
||||
object.classList.remove("display-none");
|
||||
}else {
|
||||
object.classList.add("display-none");
|
||||
}
|
||||
}
|
||||
|
||||
// When you navigate using forward/back after changing status but not saving, when you land back on the DA page the
|
||||
// status select will say (for example) Rejected but the selected option can be something else. To manage the show/hide
|
||||
// accurately for this edge case, we use cache and test for the back/forward navigation.
|
||||
const observer = new PerformanceObserver((list) => {
|
||||
list.getEntries().forEach((entry) => {
|
||||
if (entry.type === "back_forward") {
|
||||
if (sessionStorage.getItem('hideRejectionReason'))
|
||||
document.querySelector('.field-rejection_reason').style.display = 'none';
|
||||
else
|
||||
document.querySelector('.field-rejection_reason').style.display = 'block';
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe({ type: "navigation" });
|
||||
// Adds or removes a boolean from our session
|
||||
function addOrRemoveSessionBoolean(name, add){
|
||||
if (add) {
|
||||
sessionStorage.setItem(name, "true");
|
||||
}else {
|
||||
sessionStorage.removeItem(name);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/** An IIFE for toggling the submit bar on domain request forms
|
||||
|
|
|
@ -773,3 +773,12 @@ div.dja__model-description{
|
|||
.module caption, .inline-group h2 {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.wrapped-button-group {
|
||||
// This button group has too many items
|
||||
flex-wrap: wrap;
|
||||
// Fix a weird spacing issue with USWDS a buttons in DJA
|
||||
a.button {
|
||||
padding: 6px 8px 10px 8px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ from registrar.views.admin_views import (
|
|||
ExportDataType,
|
||||
ExportDataUnmanagedDomains,
|
||||
AnalyticsView,
|
||||
ExportDomainRequestDataFull,
|
||||
)
|
||||
|
||||
from registrar.views.domain_request import Step
|
||||
|
@ -66,6 +67,11 @@ urlpatterns = [
|
|||
ExportDataType.as_view(),
|
||||
name="export_data_type",
|
||||
),
|
||||
path(
|
||||
"admin/analytics/export_data_domain_requests_full/",
|
||||
ExportDomainRequestDataFull.as_view(),
|
||||
name="export_data_domain_requests_full",
|
||||
),
|
||||
path(
|
||||
"admin/analytics/export_data_full/",
|
||||
ExportDataFull.as_view(),
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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.")},
|
||||
)
|
||||
|
@ -647,20 +648,27 @@ class NoOtherContactsForm(BaseDeletableRegistrarForm):
|
|||
|
||||
|
||||
class CisaRepresentativeForm(BaseDeletableRegistrarForm):
|
||||
cisa_representative_first_name = forms.CharField(
|
||||
label="First name / given name",
|
||||
error_messages={"required": "Enter the first name / given name of the CISA regional representative."},
|
||||
)
|
||||
cisa_representative_last_name = forms.CharField(
|
||||
label="Last name / family name",
|
||||
error_messages={"required": "Enter the last name / family name of the CISA regional representative."},
|
||||
)
|
||||
cisa_representative_email = forms.EmailField(
|
||||
required=True,
|
||||
label="Your representative’s email (optional)",
|
||||
max_length=None,
|
||||
label="Your representative’s email",
|
||||
required=False,
|
||||
error_messages={
|
||||
"invalid": ("Enter your representative’s email address in the required format, like name@example.com."),
|
||||
},
|
||||
validators=[
|
||||
MaxLengthValidator(
|
||||
320,
|
||||
message="Response must be less than 320 characters.",
|
||||
)
|
||||
],
|
||||
error_messages={
|
||||
"invalid": ("Enter your email address in the required format, like name@example.com."),
|
||||
"required": ("Enter the email address of your CISA regional representative."),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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 =================
|
||||
|
|
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,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 4.2.10 on 2024-06-12 14:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("registrar", "0099_federalagency_federal_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="domainrequest",
|
||||
name="action_needed_reason",
|
||||
field=models.TextField(
|
||||
blank=True,
|
||||
choices=[
|
||||
("eligibility_unclear", "Unclear organization eligibility"),
|
||||
("questionable_authorizing_official", "Questionable authorizing official"),
|
||||
("already_has_domains", "Already has domains"),
|
||||
("bad_name", "Doesn’t meet naming requirements"),
|
||||
("other", "Other (no auto-email sent)"),
|
||||
],
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,69 @@
|
|||
# Generated by Django 4.2.10 on 2024-06-12 20:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("registrar", "0100_domainrequest_action_needed_reason"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="cisa_representative_first_name",
|
||||
field=models.CharField(
|
||||
blank=True, db_index=True, null=True, verbose_name="CISA regional representative first name"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="cisa_representative_last_name",
|
||||
field=models.CharField(
|
||||
blank=True, db_index=True, null=True, verbose_name="CISA regional representative last name"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="has_anything_else_text",
|
||||
field=models.BooleanField(
|
||||
blank=True, help_text="Determines if the user has a anything_else or not", null=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="has_cisa_representative",
|
||||
field=models.BooleanField(
|
||||
blank=True, help_text="Determines if the user has a representative email or not", null=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domainrequest",
|
||||
name="cisa_representative_first_name",
|
||||
field=models.CharField(
|
||||
blank=True, db_index=True, null=True, verbose_name="CISA regional representative first name"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domainrequest",
|
||||
name="cisa_representative_last_name",
|
||||
field=models.CharField(
|
||||
blank=True, db_index=True, null=True, verbose_name="CISA regional representative last name"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domaininformation",
|
||||
name="cisa_representative_email",
|
||||
field=models.EmailField(
|
||||
blank=True, max_length=320, null=True, verbose_name="CISA regional representative email"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domainrequest",
|
||||
name="cisa_representative_email",
|
||||
field=models.EmailField(
|
||||
blank=True, max_length=320, null=True, verbose_name="CISA regional representative email"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -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,
|
||||
|
@ -214,13 +214,45 @@ class DomainInformation(TimeStampedModel):
|
|||
verbose_name="Additional details",
|
||||
)
|
||||
|
||||
# This is a drop-in replacement for a has_anything_else_text() function.
|
||||
# In order to track if the user has clicked the yes/no field (while keeping a none default), we need
|
||||
# a tertiary state. We should not display this in /admin.
|
||||
has_anything_else_text = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Determines if the user has a anything_else or not",
|
||||
)
|
||||
|
||||
cisa_representative_email = models.EmailField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative",
|
||||
verbose_name="CISA regional representative email",
|
||||
max_length=320,
|
||||
)
|
||||
|
||||
cisa_representative_first_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative first name",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
cisa_representative_last_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative last name",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
# This is a drop-in replacement for an has_cisa_representative() function.
|
||||
# In order to track if the user has clicked the yes/no field (while keeping a none default), we need
|
||||
# a tertiary state. We should not display this in /admin.
|
||||
has_cisa_representative = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Determines if the user has a representative email or not",
|
||||
)
|
||||
|
||||
is_policy_acknowledged = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
@ -241,6 +273,30 @@ class DomainInformation(TimeStampedModel):
|
|||
except Exception:
|
||||
return ""
|
||||
|
||||
def sync_yes_no_form_fields(self):
|
||||
"""Some yes/no forms use a db field to track whether it was checked or not.
|
||||
We handle that here for def save().
|
||||
"""
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
||||
self.has_cisa_representative = (
|
||||
self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
||||
)
|
||||
|
||||
# This check is required to ensure that the form doesn't start out checked
|
||||
if self.has_cisa_representative is not None:
|
||||
self.has_cisa_representative = (
|
||||
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
||||
) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
||||
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
if self.anything_else is not None:
|
||||
self.has_anything_else_text = self.anything_else != ""
|
||||
|
||||
# This check is required to ensure that the form doesn't start out checked.
|
||||
if self.has_anything_else_text is not None:
|
||||
self.has_anything_else_text = self.anything_else != "" and self.anything_else is not None
|
||||
|
||||
def sync_organization_type(self):
|
||||
"""
|
||||
Updates the organization_type (without saving) to match
|
||||
|
@ -275,6 +331,7 @@ class DomainInformation(TimeStampedModel):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Save override for custom properties"""
|
||||
self.sync_yes_no_form_fields()
|
||||
self.sync_organization_type()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
from typing import Union
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
|
@ -12,6 +11,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
|
||||
|
@ -52,6 +52,11 @@ class DomainRequest(TimeStampedModel):
|
|||
WITHDRAWN = "withdrawn", "Withdrawn"
|
||||
STARTED = "started", "Started"
|
||||
|
||||
@classmethod
|
||||
def get_status_label(cls, status_name: str):
|
||||
"""Returns the associated label for a given status name"""
|
||||
return cls(status_name).label if status_name else None
|
||||
|
||||
class StateTerritoryChoices(models.TextChoices):
|
||||
ALABAMA = "AL", "Alabama (AL)"
|
||||
ALASKA = "AK", "Alaska (AK)"
|
||||
|
@ -133,6 +138,14 @@ class DomainRequest(TimeStampedModel):
|
|||
SPECIAL_DISTRICT = "special_district", "Special district"
|
||||
SCHOOL_DISTRICT = "school_district", "School district"
|
||||
|
||||
@classmethod
|
||||
def get_org_label(cls, org_name: str):
|
||||
"""Returns the associated label for a given org name"""
|
||||
org_names = org_name.split("_election")
|
||||
if len(org_names) > 0:
|
||||
org_name = org_names[0]
|
||||
return cls(org_name).label if org_name else None
|
||||
|
||||
class OrgChoicesElectionOffice(models.TextChoices):
|
||||
"""
|
||||
Primary organization choices for Django admin:
|
||||
|
@ -234,11 +247,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"
|
||||
|
@ -254,6 +262,15 @@ class DomainRequest(TimeStampedModel):
|
|||
NAMING_REQUIREMENTS = "naming_not_met", "Naming requirements not met"
|
||||
OTHER = "other", "Other/Unspecified"
|
||||
|
||||
class ActionNeededReasons(models.TextChoices):
|
||||
"""Defines common action needed reasons for domain requests"""
|
||||
|
||||
ELIGIBILITY_UNCLEAR = ("eligibility_unclear", "Unclear organization eligibility")
|
||||
QUESTIONABLE_AUTHORIZING_OFFICIAL = ("questionable_authorizing_official", "Questionable authorizing official")
|
||||
ALREADY_HAS_DOMAINS = ("already_has_domains", "Already has domains")
|
||||
BAD_NAME = ("bad_name", "Doesn’t meet naming requirements")
|
||||
OTHER = ("other", "Other (no auto-email sent)")
|
||||
|
||||
# #### Internal fields about the domain request #####
|
||||
status = FSMField(
|
||||
choices=DomainRequestStatus.choices, # possible states as an array of constants
|
||||
|
@ -267,6 +284,12 @@ class DomainRequest(TimeStampedModel):
|
|||
blank=True,
|
||||
)
|
||||
|
||||
action_needed_reason = models.TextField(
|
||||
choices=ActionNeededReasons.choices,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
federal_agency = models.ForeignKey(
|
||||
"registrar.FederalAgency",
|
||||
on_delete=models.PROTECT,
|
||||
|
@ -467,10 +490,24 @@ class DomainRequest(TimeStampedModel):
|
|||
cisa_representative_email = models.EmailField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative",
|
||||
verbose_name="CISA regional representative email",
|
||||
max_length=320,
|
||||
)
|
||||
|
||||
cisa_representative_first_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative first name",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
cisa_representative_last_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="CISA regional representative last name",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
# This is a drop-in replacement for an has_cisa_representative() function.
|
||||
# In order to track if the user has clicked the yes/no field (while keeping a none default), we need
|
||||
# a tertiary state. We should not display this in /admin.
|
||||
|
@ -529,6 +566,16 @@ class DomainRequest(TimeStampedModel):
|
|||
# Actually updates the organization_type field
|
||||
org_type_helper.create_or_update_organization_type()
|
||||
|
||||
def _cache_status_and_action_needed_reason(self):
|
||||
"""Maintains a cache of properties so we can avoid a DB call"""
|
||||
self._cached_action_needed_reason = self.action_needed_reason
|
||||
self._cached_status = self.status
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Store original values for caching purposes. Used to compare them on save.
|
||||
self._cache_status_and_action_needed_reason()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Save override for custom properties"""
|
||||
self.sync_organization_type()
|
||||
|
@ -536,20 +583,38 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# Handle the action needed email. We send one when moving to action_needed,
|
||||
# but we don't send one when we are _already_ in the state and change the reason.
|
||||
self.sync_action_needed_reason()
|
||||
|
||||
# Update the cached values after saving
|
||||
self._cache_status_and_action_needed_reason()
|
||||
|
||||
def sync_action_needed_reason(self):
|
||||
"""Checks if we need to send another action needed email"""
|
||||
was_already_action_needed = self._cached_status == self.DomainRequestStatus.ACTION_NEEDED
|
||||
reason_exists = self._cached_action_needed_reason is not None and self.action_needed_reason is not None
|
||||
reason_changed = self._cached_action_needed_reason != self.action_needed_reason
|
||||
if was_already_action_needed and (reason_exists and reason_changed):
|
||||
# We don't send emails out in state "other"
|
||||
if self.action_needed_reason != self.ActionNeededReasons.OTHER:
|
||||
self._send_action_needed_reason_email()
|
||||
|
||||
def sync_yes_no_form_fields(self):
|
||||
"""Some yes/no forms use a db field to track whether it was checked or not.
|
||||
We handle that here for def save().
|
||||
"""
|
||||
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
if self.cisa_representative_email is not None:
|
||||
self.has_cisa_representative = self.cisa_representative_email != ""
|
||||
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
||||
self.has_cisa_representative = (
|
||||
self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
||||
)
|
||||
|
||||
# This check is required to ensure that the form doesn't start out checked
|
||||
if self.has_cisa_representative is not None:
|
||||
self.has_cisa_representative = (
|
||||
self.cisa_representative_email != "" and self.cisa_representative_email is not None
|
||||
)
|
||||
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
||||
) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
||||
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
if self.anything_else is not None:
|
||||
|
@ -587,7 +652,7 @@ class DomainRequest(TimeStampedModel):
|
|||
logger.error(f"Can't query an approved domain while attempting {called_from}")
|
||||
|
||||
def _send_status_update_email(
|
||||
self, new_status, email_template, email_template_subject, send_email=True, bcc_address=""
|
||||
self, new_status, email_template, email_template_subject, send_email=True, bcc_address="", wrap_email=False
|
||||
):
|
||||
"""Send a status update email to the submitter.
|
||||
|
||||
|
@ -614,6 +679,7 @@ class DomainRequest(TimeStampedModel):
|
|||
self.submitter.email,
|
||||
context={"domain_request": self},
|
||||
bcc_address=bcc_address,
|
||||
wrap_email=wrap_email,
|
||||
)
|
||||
logger.info(f"The {new_status} email sent to: {self.submitter.email}")
|
||||
except EmailSendingError:
|
||||
|
@ -697,9 +763,10 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
if self.status == self.DomainRequestStatus.APPROVED:
|
||||
self.delete_and_clean_up_domain("in_review")
|
||||
|
||||
if self.status == self.DomainRequestStatus.REJECTED:
|
||||
elif self.status == self.DomainRequestStatus.REJECTED:
|
||||
self.rejection_reason = None
|
||||
elif self.status == self.DomainRequestStatus.ACTION_NEEDED:
|
||||
self.action_needed_reason = None
|
||||
|
||||
literal = DomainRequest.DomainRequestStatus.IN_REVIEW
|
||||
# Check if the tuple exists, then grab its value
|
||||
|
@ -717,7 +784,7 @@ class DomainRequest(TimeStampedModel):
|
|||
target=DomainRequestStatus.ACTION_NEEDED,
|
||||
conditions=[domain_is_not_active, investigator_exists_and_is_staff],
|
||||
)
|
||||
def action_needed(self):
|
||||
def action_needed(self, send_email=True):
|
||||
"""Send back an domain request that is under investigation or rejected.
|
||||
|
||||
This action is logged.
|
||||
|
@ -729,8 +796,7 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
if self.status == self.DomainRequestStatus.APPROVED:
|
||||
self.delete_and_clean_up_domain("reject_with_prejudice")
|
||||
|
||||
if self.status == self.DomainRequestStatus.REJECTED:
|
||||
elif self.status == self.DomainRequestStatus.REJECTED:
|
||||
self.rejection_reason = None
|
||||
|
||||
literal = DomainRequest.DomainRequestStatus.ACTION_NEEDED
|
||||
|
@ -738,6 +804,46 @@ class DomainRequest(TimeStampedModel):
|
|||
action_needed = literal if literal is not None else "Action Needed"
|
||||
logger.info(f"A status change occurred. {self} was changed to '{action_needed}'")
|
||||
|
||||
# Send out an email if an action needed reason exists
|
||||
if self.action_needed_reason and self.action_needed_reason != self.ActionNeededReasons.OTHER:
|
||||
self._send_action_needed_reason_email(send_email)
|
||||
|
||||
def _send_action_needed_reason_email(self, send_email=True):
|
||||
"""Sends out an automatic email for each valid action needed reason provided"""
|
||||
|
||||
# Store the filenames of the template and template subject
|
||||
email_template_name: str = ""
|
||||
email_template_subject_name: str = ""
|
||||
|
||||
# Check for the "type" of action needed reason.
|
||||
can_send_email = True
|
||||
match self.action_needed_reason:
|
||||
# Add to this match if you need to pass in a custom filename for these templates.
|
||||
case self.ActionNeededReasons.OTHER, _:
|
||||
# Unknown and other are default cases - do nothing
|
||||
can_send_email = False
|
||||
|
||||
# Assumes that the template name matches the action needed reason if nothing is specified.
|
||||
# This is so you can override if you need, or have this taken care of for you.
|
||||
if not email_template_name and not email_template_subject_name:
|
||||
email_template_name = f"{self.action_needed_reason}.txt"
|
||||
email_template_subject_name = f"{self.action_needed_reason}_subject.txt"
|
||||
|
||||
bcc_address = ""
|
||||
if settings.IS_PRODUCTION:
|
||||
bcc_address = settings.DEFAULT_FROM_EMAIL
|
||||
|
||||
# If we can, try to send out an email as long as send_email=True
|
||||
if can_send_email:
|
||||
self._send_status_update_email(
|
||||
new_status="action needed",
|
||||
email_template=f"emails/action_needed_reasons/{email_template_name}",
|
||||
email_template_subject=f"emails/action_needed_reasons/{email_template_subject_name}",
|
||||
send_email=send_email,
|
||||
bcc_address=bcc_address,
|
||||
wrap_email=True,
|
||||
)
|
||||
|
||||
@transition(
|
||||
field="status",
|
||||
source=[
|
||||
|
@ -786,6 +892,8 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
if self.status == self.DomainRequestStatus.REJECTED:
|
||||
self.rejection_reason = None
|
||||
elif self.status == self.DomainRequestStatus.ACTION_NEEDED:
|
||||
self.action_needed_reason = None
|
||||
|
||||
# == Send out an email == #
|
||||
self._send_status_update_email(
|
||||
|
@ -904,11 +1012,12 @@ class DomainRequest(TimeStampedModel):
|
|||
def has_additional_details(self) -> bool:
|
||||
"""Combines the has_anything_else_text and has_cisa_representative fields,
|
||||
then returns if this domain request has either of them."""
|
||||
# Split out for linter
|
||||
has_details = False
|
||||
if self.has_anything_else_text or self.has_cisa_representative:
|
||||
has_details = True
|
||||
|
||||
# Split out for linter
|
||||
has_details = True
|
||||
|
||||
if self.has_anything_else_text is None or self.has_cisa_representative is None:
|
||||
has_details = False
|
||||
return has_details
|
||||
|
||||
def is_federal(self) -> Union[bool, None]:
|
||||
|
@ -1017,14 +1126,19 @@ class DomainRequest(TimeStampedModel):
|
|||
return True
|
||||
return False
|
||||
|
||||
def _cisa_rep_and_email_check(self):
|
||||
# Has a CISA rep + email is NOT empty or NOT an empty string OR doesn't have CISA rep
|
||||
return (
|
||||
def _cisa_rep_check(self):
|
||||
# Either does not have a CISA rep, OR has a CISA rep + both first name
|
||||
# and last name are NOT empty and are NOT an empty string
|
||||
to_return = (
|
||||
self.has_cisa_representative is True
|
||||
and self.cisa_representative_email is not None
|
||||
and self.cisa_representative_email != ""
|
||||
and self.cisa_representative_first_name is not None
|
||||
and self.cisa_representative_first_name != ""
|
||||
and self.cisa_representative_last_name is not None
|
||||
and self.cisa_representative_last_name != ""
|
||||
) or self.has_cisa_representative is False
|
||||
|
||||
return to_return
|
||||
|
||||
def _anything_else_radio_button_and_text_field_check(self):
|
||||
# Anything else boolean is True + filled text field and it's not an empty string OR the boolean is No
|
||||
return (
|
||||
|
@ -1032,7 +1146,7 @@ class DomainRequest(TimeStampedModel):
|
|||
) or self.has_anything_else_text is False
|
||||
|
||||
def _is_additional_details_complete(self):
|
||||
return self._cisa_rep_and_email_check() and self._anything_else_radio_button_and_text_field_check()
|
||||
return self._cisa_rep_check() and self._anything_else_radio_button_and_text_field_check()
|
||||
|
||||
def _is_policy_acknowledgement_complete(self):
|
||||
return self.is_policy_acknowledged is not None
|
||||
|
@ -1065,6 +1179,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
|
||||
|
|
|
@ -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}"
|
||||
|
||||
|
|
|
@ -298,3 +298,26 @@ def replace_url_queryparams(url_to_modify: str, query_params, convert_list_to_cs
|
|||
new_url = urlunparse(url_parts)
|
||||
|
||||
return new_url
|
||||
|
||||
|
||||
def convert_queryset_to_dict(queryset, is_model=True, key="id"):
|
||||
"""
|
||||
Transforms a queryset into a dictionary keyed by a specified key (like "id").
|
||||
|
||||
Parameters:
|
||||
requests (QuerySet or list of dicts): Input data.
|
||||
is_model (bool): Indicates if each item in 'queryset' are model instances (True) or dictionaries (False).
|
||||
key (str): Key or attribute to use for the resulting dictionary's keys.
|
||||
|
||||
Returns:
|
||||
dict: Dictionary with keys derived from 'key' and values corresponding to items in 'queryset'.
|
||||
"""
|
||||
|
||||
if is_model:
|
||||
request_dict = {getattr(value, key): value for value in queryset}
|
||||
else:
|
||||
# Querysets sometimes contain sets of dictionaries.
|
||||
# Calling .values is an example of this.
|
||||
request_dict = {value[key]: value for value in queryset}
|
||||
|
||||
return request_dict
|
||||
|
|
|
@ -27,28 +27,35 @@
|
|||
<div class="module height-full">
|
||||
<h2>Current domains</h2>
|
||||
<div class="padding-top-2 padding-x-2">
|
||||
<ul class="usa-button-group">
|
||||
<ul class="usa-button-group wrapped-button-group">
|
||||
<li class="usa-button-group__item">
|
||||
<a href="{% url 'export_data_type' %}" class="button" role="button">
|
||||
<a href="{% url 'export_data_type' %}" class="button text-no-wrap" role="button">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
|
||||
</svg><span class="margin-left-05">All domain metadata</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="usa-button-group__item">
|
||||
<a href="{% url 'export_data_full' %}" class="button" role="button">
|
||||
<a href="{% url 'export_data_full' %}" class="button text-no-wrap" role="button">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
|
||||
</svg><span class="margin-left-05">Current full</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="usa-button-group__item">
|
||||
<a href="{% url 'export_data_federal' %}" class="button" role="button">
|
||||
<a href="{% url 'export_data_federal' %}" class="button text-no-wrap" role="button">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
|
||||
</svg><span class="margin-left-05">Current federal</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="usa-button-group__item">
|
||||
<a href="{% url 'export_data_domain_requests_full' %}" class="button text-no-wrap" role="button">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
|
||||
</svg><span class="margin-left-05">All domain requests metadata</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -69,8 +69,8 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
|||
|
||||
{% block after_help_text %}
|
||||
{% if field.field.name == "status" and original_object.history.count > 0 %}
|
||||
<div class="flex-container">
|
||||
<label aria-label="Submitter contact details"></label>
|
||||
<div class="flex-container" id="dja-status-changelog">
|
||||
<label aria-label="Status changelog"></label>
|
||||
<div>
|
||||
<div class="usa-table-container--scrollable collapse--dgsimple" tabindex="0">
|
||||
<table class="usa-table usa-table--borderless">
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
{% include "includes/required_fields.html" %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- TODO-NL: (refactor) Breakup into two separate components-->
|
||||
{% block form_fields %}
|
||||
|
||||
<fieldset class="usa-fieldset margin-top-2">
|
||||
|
@ -24,7 +23,9 @@
|
|||
{# forms.0 is a small yes/no form that toggles the visibility of "cisa representative" formset #}
|
||||
</fieldset>
|
||||
|
||||
<div id="cisa-representative" class="cisa-representative-form">
|
||||
<div id="cisa-representative" class="cisa-representative-form margin-top-3">
|
||||
{% input_with_errors forms.1.cisa_representative_first_name %}
|
||||
{% input_with_errors forms.1.cisa_representative_last_name %}
|
||||
{% input_with_errors forms.1.cisa_representative_email %}
|
||||
{# forms.1 is a form for inputting the e-mail of a cisa representative #}
|
||||
</div>
|
||||
|
|
|
@ -157,18 +157,33 @@
|
|||
|
||||
{% if step == Step.ADDITIONAL_DETAILS %}
|
||||
{% namespaced_url 'domain-request' step as domain_request_url %}
|
||||
{% with title=form_titles|get_item:step value=domain_request.requested_domain.name|default:"<span class='text-bold text-secondary-dark'>Incomplete</span>"|safe %}
|
||||
{% include "includes/summary_item.html" with title=title sub_header_text='CISA regional representative' value=domain_request.cisa_representative_email heading_level=heading_level editable=True edit_link=domain_request_url custom_text_for_value_none='No' %}
|
||||
{% endwith %}
|
||||
{% with title=form_titles|get_item:step %}
|
||||
{% if domain_request.has_additional_details %}
|
||||
{% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=True edit_link=domain_request_url %}
|
||||
<h3 class="register-form-review-header">CISA Regional Representative</h3>
|
||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||
{% if domain_request.cisa_representative_first_name %}
|
||||
<li>{{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}</li>
|
||||
{% if domain_request.cisa_representative_email %}
|
||||
<li>{{domain_request.cisa_representative_email}}</li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
No
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<h3 class="register-form-review-header">Anything else</h3>
|
||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||
{% if domain_request.anything_else %}
|
||||
{{domain_request.anything_else}}
|
||||
{% else %}
|
||||
No
|
||||
{% endif %}
|
||||
</ul>
|
||||
<h3 class="register-form-review-header">Anything else</h3>
|
||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||
{% if domain_request.anything_else %}
|
||||
{{domain_request.anything_else}}
|
||||
{% else %}
|
||||
No
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% else %}
|
||||
{% include "includes/summary_item.html" with title="Additional Details" value="<span class='text-bold text-secondary-dark'>Incomplete</span>"|safe heading_level=heading_level editable=True edit_link=domain_request_url %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
|
|
@ -118,7 +118,15 @@
|
|||
|
||||
{# We always show this field even if None #}
|
||||
{% if DomainRequest %}
|
||||
{% include "includes/summary_item.html" with title='Additional details' sub_header_text='CISA regional representative' value=DomainRequest.cisa_representative_email custom_text_for_value_none='No' heading_level=heading_level %}
|
||||
<h3 class="register-form-review-header">CISA Regional Representative</h3>
|
||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||
{% if domain_request.cisa_representative_first_name %}
|
||||
{{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
|
||||
{% else %}
|
||||
No
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<h3 class="register-form-review-header">Anything else</h3>
|
||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||
{% if DomainRequest.anything_else %}
|
||||
|
@ -128,7 +136,6 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||
Hi, {{ domain_request.submitter.first_name }}.
|
||||
|
||||
We've identified an action that you’ll need to complete before we continue reviewing your .gov domain request.
|
||||
|
||||
DOMAIN REQUESTED: {{ domain_request.requested_domain.name }}
|
||||
REQUEST RECEIVED ON: {{ domain_request.submission_date|date }}
|
||||
STATUS: Action needed
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
ORGANIZATION ALREADY HAS A .GOV DOMAIN
|
||||
We've reviewed your domain request, but your organization already has at least one other .gov domain. We need more information about your rationale for registering another .gov domain.
|
||||
In general, there are two reasons we will approve an additional domain:
|
||||
- You determine a current .gov domain name will be replaced
|
||||
- We determine an additional domain name is appropriate
|
||||
|
||||
|
||||
WE LIMIT ADDITIONAL DOMAIN NAMES
|
||||
Our practice is to only approve one domain per online service per government organization, evaluating additional requests on a case-by-case basis.
|
||||
There are two core reasons we limit additional domains:
|
||||
- We want to minimize your operational and security load, which increases with each additional domain.
|
||||
- Fewer domains allow us to take protective, namespace-wide security actions faster and without undue dependencies.
|
||||
|
||||
If you’re attempting to claim an additional domain to prevent others from obtaining it, that’s not necessary. .Gov domains are only available to U.S.-based government organizations, and we don’t operate on a first come, first served basis. We'll only assign a domain to the organization whose real name or services actually correspond to the domain name.
|
||||
|
||||
|
||||
CONSIDER USING A SUBDOMAIN
|
||||
Using a subdomain of an existing domain (e.g., service.domain.gov) is a common approach to logically divide your namespace while still maintaining an association with your existing domain name. Subdomains can also be delegated to allow an affiliated entity to manage their own DNS settings.
|
||||
|
||||
|
||||
ACTION NEEDED
|
||||
FOR A REPLACEMENT DOMAIN: If you’re requesting a new domain that will replace your current domain name, we can allow for a transition period where both are registered to your organization. Afterwards, we will reclaim and retire the legacy name.
|
||||
|
||||
Reply to this email. Tell us how many months your organization needs to maintain your current .gov domain and conduct a transition to a new one. Detail why that period of time is needed.
|
||||
|
||||
FOR AN ADDITIONAL DOMAIN: If you’re requesting an additional domain and not replacing your existing one, we’ll need more information to support that request.
|
||||
|
||||
Reply to this email. Detail why you believe another domain is necessary for your organization, and why a subdomain won’t meet your needs.
|
||||
|
||||
|
||||
If you have questions or comments, include those in your reply.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
The .gov team
|
||||
Contact us: <https://get.gov/contact/>
|
||||
Learn about .gov <https://get.gov>
|
||||
|
||||
The .gov registry is a part of the Cybersecurity and Infrastructure Security Agency (CISA) <http://cisa.gov/>
|
||||
{% endautoescape %}
|
|
@ -0,0 +1 @@
|
|||
Update on your .gov request: {{ domain_request.requested_domain.name }}
|
|
@ -0,0 +1,34 @@
|
|||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||
Hi, {{ domain_request.submitter.first_name }}.
|
||||
|
||||
We've identified an action that you’ll need to complete before we continue reviewing your .gov domain request.
|
||||
|
||||
DOMAIN REQUESTED: {{ domain_request.requested_domain.name }}
|
||||
REQUEST RECEIVED ON: {{ domain_request.submission_date|date }}
|
||||
STATUS: Action needed
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS
|
||||
We've reviewed your domain request and, unfortunately, it does not meet our naming requirements.
|
||||
|
||||
Domains should uniquely identify a government organization and be clear to the general public. Read more about naming requirements for your type of organization <https://get.gov/domains/choosing/>.
|
||||
|
||||
|
||||
ACTION NEEDED
|
||||
First, we need you to identify a new domain name that meets our naming requirements for your type of organization. Then, log in to the registrar and update the name in your domain request. <https://manage.get.gov/> Once you submit your updated request, we’ll resume the adjudication process.
|
||||
|
||||
If you have questions or want to discuss potential domain names, reply to this email.
|
||||
|
||||
|
||||
THANK YOU
|
||||
.Gov helps the public identify official, trusted information. Thank you for requesting a .gov domain.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
The .gov team
|
||||
Contact us: <https://get.gov/contact/>
|
||||
Learn about .gov <https://get.gov>
|
||||
|
||||
The .gov registry is a part of the Cybersecurity and Infrastructure Security Agency (CISA) <http://cisa.gov/>
|
||||
{% endautoescape %}
|
|
@ -0,0 +1 @@
|
|||
Update on your .gov request: {{ domain_request.requested_domain.name }}
|
|
@ -0,0 +1,35 @@
|
|||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||
Hi, {{ domain_request.submitter.first_name }}.
|
||||
|
||||
We've identified an action that you’ll need to complete before we continue reviewing your .gov domain request.
|
||||
|
||||
DOMAIN REQUESTED: {{ domain_request.requested_domain.name }}
|
||||
REQUEST RECEIVED ON: {{ domain_request.submission_date|date }}
|
||||
STATUS: Action needed
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS
|
||||
We've reviewed your domain request, but we need more information about the organization you represent:
|
||||
- {{ domain_request.organization_name }}
|
||||
|
||||
.Gov domains are only available to official US-based government organizations, not simply those that provide a public benefit. We lack clear documentation that demonstrates your organization is eligible for a .gov domain.
|
||||
|
||||
|
||||
ACTION NEEDED
|
||||
Reply to this email with links to (or copies of) your authorizing legislation, your founding charter or bylaws, recent election results, or other similar documentation. Without this, we can’t continue our review and your request will likely be rejected.
|
||||
|
||||
If you have questions or comments, include those in your reply.
|
||||
|
||||
|
||||
THANK YOU
|
||||
.Gov helps the public identify official, trusted information. Thank you for requesting a .gov domain.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
The .gov team
|
||||
Contact us: <https://get.gov/contact/>
|
||||
Learn about .gov <https://get.gov>
|
||||
|
||||
The .gov registry is a part of the Cybersecurity and Infrastructure Security Agency (CISA) <http://cisa.gov/>
|
||||
{% endautoescape %}
|
|
@ -0,0 +1 @@
|
|||
Update on your .gov request: {{ domain_request.requested_domain.name }}
|
|
@ -0,0 +1,36 @@
|
|||
{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
|
||||
Hi, {{ domain_request.submitter.first_name }}.
|
||||
|
||||
We've identified an action that you’ll need to complete before we continue reviewing your .gov domain request.
|
||||
|
||||
DOMAIN REQUESTED: {{ domain_request.requested_domain.name }}
|
||||
REQUEST RECEIVED ON: {{ domain_request.submission_date|date }}
|
||||
STATUS: Action needed
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
AUTHORIZING OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS
|
||||
We've reviewed your domain request, but we need more information about the authorizing official listed on the request:
|
||||
- {{ domain_request.authorizing_official.get_formatted_name }}
|
||||
- {{ domain_request.authorizing_official.title }}
|
||||
|
||||
We expect an authorizing official to be someone in a role of significant, executive responsibility within the organization. Our guidelines are open-ended to accommodate the wide variety of government organizations that are eligible for .gov domains, but the person you listed does not meet our expectations for your type of organization. Read more about our guidelines for authorizing officials. <https://get.gov/domains/eligibility/>
|
||||
|
||||
|
||||
ACTION NEEDED
|
||||
Reply to this email with a justification for naming {{ domain_request.authorizing_official.get_formatted_name }} as the authorizing official. If you have questions or comments, include those in your reply.
|
||||
|
||||
Alternatively, you can log in to the registrar and enter a different authorizing official for this domain request. <https://manage.get.gov/> Once you submit your updated request, we’ll resume the adjudication process.
|
||||
|
||||
|
||||
THANK YOU
|
||||
.Gov helps the public identify official, trusted information. Thank you for requesting a .gov domain.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
The .gov team
|
||||
Contact us: <https://get.gov/contact/>
|
||||
Learn about .gov <https://get.gov>
|
||||
|
||||
The .gov registry is a part of the Cybersecurity and Infrastructure Security Agency (CISA) <http://cisa.gov/>
|
||||
{% endautoescape %}
|
|
@ -0,0 +1 @@
|
|||
Update on your .gov request: {{ domain_request.requested_domain.name }}
|
|
@ -735,19 +735,53 @@ class MockDb(TestCase):
|
|||
self.domain_request_4 = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||
name="city4.gov",
|
||||
is_election_board=True,
|
||||
generic_org_type="city",
|
||||
)
|
||||
self.domain_request_5 = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.APPROVED,
|
||||
name="city5.gov",
|
||||
)
|
||||
self.domain_request_6 = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||
name="city6.gov",
|
||||
)
|
||||
self.domain_request_3.submit()
|
||||
self.domain_request_4.submit()
|
||||
self.domain_request_6.submit()
|
||||
|
||||
other, _ = Contact.objects.get_or_create(
|
||||
first_name="Testy1232",
|
||||
last_name="Tester24",
|
||||
title="Another Tester",
|
||||
email="te2@town.com",
|
||||
phone="(555) 555 5557",
|
||||
)
|
||||
other_2, _ = Contact.objects.get_or_create(
|
||||
first_name="Meow",
|
||||
last_name="Tester24",
|
||||
title="Another Tester",
|
||||
email="te2@town.com",
|
||||
phone="(555) 555 5557",
|
||||
)
|
||||
website, _ = Website.objects.get_or_create(website="igorville.gov")
|
||||
website_2, _ = Website.objects.get_or_create(website="cheeseville.gov")
|
||||
website_3, _ = Website.objects.get_or_create(website="https://www.example.com")
|
||||
website_4, _ = Website.objects.get_or_create(website="https://www.example2.com")
|
||||
|
||||
self.domain_request_3.other_contacts.add(other, other_2)
|
||||
self.domain_request_3.alternative_domains.add(website, website_2)
|
||||
self.domain_request_3.current_websites.add(website_3, website_4)
|
||||
self.domain_request_3.cisa_representative_email = "test@igorville.com"
|
||||
self.domain_request_3.submission_date = get_time_aware_date(datetime(2024, 4, 2))
|
||||
self.domain_request_4.submission_date = get_time_aware_date(datetime(2024, 4, 2))
|
||||
self.domain_request_3.save()
|
||||
|
||||
self.domain_request_4.submission_date = get_time_aware_date(datetime(2024, 4, 2))
|
||||
self.domain_request_4.save()
|
||||
|
||||
self.domain_request_6.submission_date = get_time_aware_date(datetime(2024, 4, 2))
|
||||
self.domain_request_6.save()
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
PublicContact.objects.all().delete()
|
||||
|
@ -808,12 +842,13 @@ def create_ready_domain():
|
|||
|
||||
|
||||
# TODO in 1793: Remove the federal agency/updated federal agency fields
|
||||
def completed_domain_request(
|
||||
def completed_domain_request( # noqa
|
||||
has_other_contacts=True,
|
||||
has_current_website=True,
|
||||
has_alternative_gov_domain=True,
|
||||
has_about_your_organization=True,
|
||||
has_anything_else=True,
|
||||
has_cisa_representative=True,
|
||||
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||
user=False,
|
||||
submitter=False,
|
||||
|
@ -895,6 +930,10 @@ def completed_domain_request(
|
|||
domain_request.current_websites.add(current)
|
||||
if has_alternative_gov_domain:
|
||||
domain_request.alternative_domains.add(alt)
|
||||
if has_cisa_representative:
|
||||
domain_request.cisa_representative_first_name = "CISA-first-name"
|
||||
domain_request.cisa_representative_last_name = "CISA-last-name"
|
||||
domain_request.cisa_representative_email = "cisaRep@igorville.gov"
|
||||
|
||||
return domain_request
|
||||
|
||||
|
|
|
@ -1445,20 +1445,25 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
# The results are filtered by "status in [submitted,in review,action needed]"
|
||||
self.assertContains(response, "status in [submitted,in review,action needed]", count=1)
|
||||
|
||||
def transition_state_and_send_email(self, domain_request, status, rejection_reason=None):
|
||||
@less_console_noise_decorator
|
||||
def transition_state_and_send_email(self, domain_request, status, rejection_reason=None, action_needed_reason=None):
|
||||
"""Helper method for the email test cases."""
|
||||
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||
with less_console_noise():
|
||||
# Create a mock request
|
||||
request = self.factory.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk))
|
||||
# Create a mock request
|
||||
request = self.factory.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk))
|
||||
|
||||
# Modify the domain request's properties
|
||||
domain_request.status = status
|
||||
# Modify the domain request's properties
|
||||
domain_request.status = status
|
||||
|
||||
if rejection_reason:
|
||||
domain_request.rejection_reason = rejection_reason
|
||||
|
||||
# Use the model admin's save_model method
|
||||
self.admin.save_model(request, domain_request, form=None, change=True)
|
||||
if action_needed_reason:
|
||||
domain_request.action_needed_reason = action_needed_reason
|
||||
|
||||
# Use the model admin's save_model method
|
||||
self.admin.save_model(request, domain_request, form=None, change=True)
|
||||
|
||||
def assert_email_is_accurate(
|
||||
self, expected_string, email_index, email_address, test_that_no_bcc=False, bcc_email_address=""
|
||||
|
@ -1493,6 +1498,57 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
bcc_email = kwargs["Destination"]["BccAddresses"][0]
|
||||
self.assertEqual(bcc_email, bcc_email_address)
|
||||
|
||||
@override_settings(IS_PRODUCTION=True)
|
||||
def test_action_needed_sends_reason_email_prod_bcc(self):
|
||||
"""When an action needed reason is set, an email is sent out and help@get.gov
|
||||
is BCC'd in production"""
|
||||
# Ensure there is no user with this email
|
||||
EMAIL = "mayor@igorville.gov"
|
||||
BCC_EMAIL = settings.DEFAULT_FROM_EMAIL
|
||||
User.objects.filter(email=EMAIL).delete()
|
||||
in_review = DomainRequest.DomainRequestStatus.IN_REVIEW
|
||||
action_needed = DomainRequest.DomainRequestStatus.ACTION_NEEDED
|
||||
|
||||
# Create a sample domain request
|
||||
domain_request = completed_domain_request(status=in_review)
|
||||
|
||||
# Test the email sent out for already_has_domains
|
||||
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=already_has_domains)
|
||||
self.assert_email_is_accurate("ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, EMAIL, bcc_email_address=BCC_EMAIL)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
||||
|
||||
# Test the email sent out for bad_name
|
||||
bad_name = DomainRequest.ActionNeededReasons.BAD_NAME
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=bad_name)
|
||||
self.assert_email_is_accurate(
|
||||
"DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS", 1, EMAIL, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
|
||||
|
||||
# Test the email sent out for eligibility_unclear
|
||||
eligibility_unclear = DomainRequest.ActionNeededReasons.ELIGIBILITY_UNCLEAR
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=eligibility_unclear)
|
||||
self.assert_email_is_accurate(
|
||||
"ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS", 2, EMAIL, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Test the email sent out for questionable_ao
|
||||
questionable_ao = DomainRequest.ActionNeededReasons.QUESTIONABLE_AUTHORIZING_OFFICIAL
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=questionable_ao)
|
||||
self.assert_email_is_accurate(
|
||||
"AUTHORIZING OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS", 3, EMAIL, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 4)
|
||||
|
||||
# Assert that no other emails are sent on OTHER
|
||||
other = DomainRequest.ActionNeededReasons.OTHER
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=other)
|
||||
|
||||
# Should be unchanged from before
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 4)
|
||||
|
||||
def test_save_model_sends_submitted_email(self):
|
||||
"""When transitioning to submitted from started or withdrawn on a domain request,
|
||||
an email is sent out.
|
||||
|
@ -1528,7 +1584,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
other = DomainRequest.ActionNeededReasons.OTHER
|
||||
in_review = DomainRequest.DomainRequestStatus.IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, in_review, action_needed_reason=other)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Test Submitted Status Again from in IN_REVIEW, no new email should be sent
|
||||
|
@ -1536,7 +1594,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
self.transition_state_and_send_email(domain_request, in_review, action_needed_reason=other)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to ACTION_NEEDED
|
||||
|
@ -1586,7 +1644,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
other = domain_request.ActionNeededReasons.OTHER
|
||||
in_review = DomainRequest.DomainRequestStatus.IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, in_review, action_needed_reason=other)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Test Submitted Status Again from in IN_REVIEW, no new email should be sent
|
||||
|
@ -1594,7 +1654,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to IN_REVIEW
|
||||
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
self.transition_state_and_send_email(domain_request, in_review, action_needed_reason=other)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
# Move it to ACTION_NEEDED
|
||||
|
@ -2238,6 +2298,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
"updated_at",
|
||||
"status",
|
||||
"rejection_reason",
|
||||
"action_needed_reason",
|
||||
"federal_agency",
|
||||
"creator",
|
||||
"investigator",
|
||||
|
@ -2265,6 +2326,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
"anything_else",
|
||||
"has_anything_else_text",
|
||||
"cisa_representative_email",
|
||||
"cisa_representative_first_name",
|
||||
"cisa_representative_last_name",
|
||||
"has_cisa_representative",
|
||||
"is_policy_acknowledged",
|
||||
"submission_date",
|
||||
|
@ -2297,6 +2360,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
"no_other_contacts_rationale",
|
||||
"anything_else",
|
||||
"is_policy_acknowledged",
|
||||
"cisa_representative_first_name",
|
||||
"cisa_representative_last_name",
|
||||
"cisa_representative_email",
|
||||
]
|
||||
|
||||
|
@ -2395,6 +2460,10 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
stack.enter_context(patch.object(messages, "error"))
|
||||
|
||||
domain_request.status = another_state
|
||||
|
||||
if another_state == DomainRequest.DomainRequestStatus.ACTION_NEEDED:
|
||||
domain_request.action_needed_reason = domain_request.ActionNeededReasons.OTHER
|
||||
|
||||
domain_request.rejection_reason = rejection_reason
|
||||
|
||||
self.admin.save_model(request, domain_request, None, True)
|
||||
|
|
|
@ -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.",
|
||||
|
@ -1800,93 +1802,129 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
def test_is_additional_details_complete(self):
|
||||
test_cases = [
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Email - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - None >> e-mail is optional so it should not change anything setting this to None
|
||||
# Anything Else Radio - No
|
||||
# Anything Else Text - No
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - None
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - No
|
||||
# Anything Else Text - No
|
||||
# sync_yes_no will override has_cisa_representative to be False if cisa_representative_email is None
|
||||
# sync_yes_no will override has_cisa_representative to be False if cisa_representative_first_name is None
|
||||
# therefore, our expected will be True
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - None
|
||||
# NOTE: We should never have an instance where only firstname or only lastname are populated
|
||||
# (they are both required)
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None or
|
||||
# cisa_representative_last_name is None bc of sync_yes_no_form_fields
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None or
|
||||
# cisa_representative_last_name is None bc of sync_yes_no_form_fields
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
|
@ -1897,6 +1935,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
|
@ -1907,6 +1947,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
|
@ -1917,6 +1959,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
|
@ -1928,6 +1972,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - No
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
|
@ -1937,6 +1983,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Radio - None
|
||||
{
|
||||
"has_cisa_representative": None,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.test import Client, RequestFactory
|
|||
from io import StringIO
|
||||
from registrar.models.domain_request import DomainRequest
|
||||
from registrar.models.domain import Domain
|
||||
from registrar.models.utility.generic_helper import convert_queryset_to_dict
|
||||
from registrar.utility.csv_export import (
|
||||
export_data_managed_domains_to_csv,
|
||||
export_data_unmanaged_domains_to_csv,
|
||||
|
@ -12,7 +13,7 @@ from registrar.utility.csv_export import (
|
|||
write_csv_for_domains,
|
||||
get_default_start_date,
|
||||
get_default_end_date,
|
||||
write_csv_for_requests,
|
||||
DomainRequestExport,
|
||||
)
|
||||
|
||||
from django.core.management import call_command
|
||||
|
@ -23,6 +24,7 @@ from botocore.exceptions import ClientError
|
|||
import boto3_mocking
|
||||
from registrar.utility.s3_bucket import S3ClientError, S3ClientErrorCodes # type: ignore
|
||||
from django.utils import timezone
|
||||
from api.tests.common import less_console_noise_decorator
|
||||
from .common import MockDb, MockEppLib, less_console_noise, get_time_aware_date
|
||||
|
||||
|
||||
|
@ -667,10 +669,7 @@ class ExportDataTest(MockDb, MockEppLib):
|
|||
# Define columns, sort fields, and filter condition
|
||||
# We'll skip submission date because it's dynamic and therefore
|
||||
# impossible to set in expected_content
|
||||
columns = [
|
||||
"Requested domain",
|
||||
"Organization type",
|
||||
]
|
||||
columns = ["Domain request", "Domain type", "Federal type"]
|
||||
sort_fields = [
|
||||
"requested_domain__name",
|
||||
]
|
||||
|
@ -679,7 +678,12 @@ class ExportDataTest(MockDb, MockEppLib):
|
|||
"submission_date__lte": self.end_date,
|
||||
"submission_date__gte": self.start_date,
|
||||
}
|
||||
write_csv_for_requests(writer, columns, sort_fields, filter_condition, should_write_header=True)
|
||||
|
||||
additional_values = ["requested_domain__name"]
|
||||
all_requests = DomainRequest.objects.filter(**filter_condition).order_by(*sort_fields).distinct()
|
||||
annotated_requests = DomainRequestExport.annotate_and_retrieve_fields(all_requests, {}, additional_values)
|
||||
requests_dict = convert_queryset_to_dict(annotated_requests, is_model=False)
|
||||
DomainRequestExport.write_csv_for_requests(writer, columns, requests_dict)
|
||||
# Reset the CSV file's position to the beginning
|
||||
csv_file.seek(0)
|
||||
# Read the content into a variable
|
||||
|
@ -687,9 +691,10 @@ class ExportDataTest(MockDb, MockEppLib):
|
|||
# We expect READY domains first, created between today-2 and today+2, sorted by created_at then name
|
||||
# and DELETED domains deleted between today-2 and today+2, sorted by deleted then name
|
||||
expected_content = (
|
||||
"Requested domain,Organization type\n"
|
||||
"city3.gov,Federal - Executive\n"
|
||||
"city4.gov,Federal - Executive\n"
|
||||
"Domain request,Domain type,Federal type\n"
|
||||
"city3.gov,Federal,Executive\n"
|
||||
"city4.gov,City,Executive\n"
|
||||
"city6.gov,Federal,Executive\n"
|
||||
)
|
||||
|
||||
# Normalize line endings and remove commas,
|
||||
|
@ -699,6 +704,72 @@ class ExportDataTest(MockDb, MockEppLib):
|
|||
|
||||
self.assertEqual(csv_content, expected_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_full_domain_request_report(self):
|
||||
"""Tests the full domain request report."""
|
||||
|
||||
# Create a CSV file in memory
|
||||
csv_file = StringIO()
|
||||
writer = csv.writer(csv_file)
|
||||
|
||||
# Call the report. Get existing fields from the report itself.
|
||||
annotations = DomainRequestExport._full_domain_request_annotations()
|
||||
additional_values = [
|
||||
"requested_domain__name",
|
||||
"federal_agency__agency",
|
||||
"authorizing_official__first_name",
|
||||
"authorizing_official__last_name",
|
||||
"authorizing_official__email",
|
||||
"authorizing_official__title",
|
||||
"creator__first_name",
|
||||
"creator__last_name",
|
||||
"creator__email",
|
||||
"investigator__email",
|
||||
]
|
||||
requests = DomainRequest.objects.exclude(status=DomainRequest.DomainRequestStatus.STARTED)
|
||||
annotated_requests = DomainRequestExport.annotate_and_retrieve_fields(requests, annotations, additional_values)
|
||||
requests_dict = convert_queryset_to_dict(annotated_requests, is_model=False)
|
||||
DomainRequestExport.write_csv_for_requests(writer, DomainRequestExport.all_columns, requests_dict)
|
||||
|
||||
# Reset the CSV file's position to the beginning
|
||||
csv_file.seek(0)
|
||||
# Read the content into a variable
|
||||
csv_content = csv_file.read()
|
||||
print(csv_content)
|
||||
self.maxDiff = None
|
||||
expected_content = (
|
||||
# Header
|
||||
"Domain request,Submitted at,Status,Domain type,Federal type,"
|
||||
"Federal agency,Organization name,Election office,City,State/territory,"
|
||||
"Region,Creator first name,Creator last name,Creator email,Creator approved domains count,"
|
||||
"Creator active requests count,Alternative domains,AO first name,AO last name,AO email,"
|
||||
"AO title/role,Request purpose,Request additional details,Other contacts,"
|
||||
"CISA regional representative,Current websites,Investigator\n"
|
||||
# Content
|
||||
"city2.gov,,In review,Federal,Executive,,Testorg,N/A,,NY,2,,,,0,1,city1.gov,Testy,Tester,testy@town.com,"
|
||||
"Chief Tester,Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com,\n"
|
||||
"city3.gov,2024-04-02,Submitted,Federal,Executive,,Testorg,N/A,,NY,2,,,,0,1,"
|
||||
"cheeseville.gov | city1.gov | igorville.gov,Testy,Tester,testy@town.com,Chief Tester,"
|
||||
"Purpose of the site,CISA-first-name CISA-last-name | There is more,Meow Tester24 te2@town.com | "
|
||||
"Testy1232 Tester24 te2@town.com | Testy Tester testy2@town.com,test@igorville.com,"
|
||||
"city.com | https://www.example2.com | https://www.example.com,\n"
|
||||
"city4.gov,2024-04-02,Submitted,City,Executive,,Testorg,Yes,,NY,2,,,,0,1,city1.gov,Testy,Tester,"
|
||||
"testy@town.com,Chief Tester,Purpose of the site,CISA-first-name CISA-last-name | There is more,"
|
||||
"Testy Tester testy2@town.com,cisaRep@igorville.gov,city.com,\n"
|
||||
"city5.gov,,Approved,Federal,Executive,,Testorg,N/A,,NY,2,,,,1,0,city1.gov,Testy,Tester,testy@town.com,"
|
||||
"Chief Tester,Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com,\n"
|
||||
"city6.gov,2024-04-02,Submitted,Federal,Executive,,Testorg,N/A,,NY,2,,,,0,1,city1.gov,Testy,Tester,"
|
||||
"testy@town.com,Chief Tester,Purpose of the site,CISA-first-name CISA-last-name | There is more,"
|
||||
"Testy Tester testy2@town.com,cisaRep@igorville.gov,city.com,"
|
||||
)
|
||||
|
||||
# Normalize line endings and remove commas,
|
||||
# spaces and leading/trailing whitespace
|
||||
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip()
|
||||
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip()
|
||||
|
||||
self.assertEqual(csv_content, expected_content)
|
||||
|
||||
|
||||
class HelperFunctions(MockDb):
|
||||
"""This asserts that 1=1. Its limited usefulness lies in making sure the helper methods stay healthy."""
|
||||
|
@ -741,5 +812,5 @@ class HelperFunctions(MockDb):
|
|||
"submission_date__lte": self.end_date,
|
||||
}
|
||||
submitted_requests_sliced_at_end_date = get_sliced_requests(filter_condition)
|
||||
expected_content = [2, 2, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
expected_content = [3, 2, 0, 0, 0, 0, 1, 0, 0, 1]
|
||||
self.assertEqual(submitted_requests_sliced_at_end_date, expected_content)
|
||||
|
|
|
@ -366,6 +366,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
additional_details_form["additional_details-has_cisa_representative"] = "True"
|
||||
additional_details_form["additional_details-has_anything_else_text"] = "True"
|
||||
additional_details_form["additional_details-cisa_representative_first_name"] = "CISA-first-name"
|
||||
additional_details_form["additional_details-cisa_representative_last_name"] = "CISA-last-name"
|
||||
additional_details_form["additional_details-cisa_representative_email"] = "FakeEmail@gmail.com"
|
||||
additional_details_form["additional_details-anything_else"] = "Nothing else."
|
||||
|
||||
|
@ -374,6 +376,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
additional_details_result = additional_details_form.submit()
|
||||
# validate that data from this step are being saved
|
||||
domain_request = DomainRequest.objects.get() # there's only one
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, "CISA-first-name")
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, "CISA-last-name")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "FakeEmail@gmail.com")
|
||||
self.assertEqual(domain_request.anything_else, "Nothing else.")
|
||||
# the post request should return a redirect to the next form in
|
||||
|
@ -719,6 +723,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
additional_details_form["additional_details-has_cisa_representative"] = "True"
|
||||
additional_details_form["additional_details-has_anything_else_text"] = "True"
|
||||
additional_details_form["additional_details-cisa_representative_first_name"] = "cisa-first-name"
|
||||
additional_details_form["additional_details-cisa_representative_last_name"] = "cisa-last-name"
|
||||
additional_details_form["additional_details-cisa_representative_email"] = "FakeEmail@gmail.com"
|
||||
additional_details_form["additional_details-anything_else"] = "Nothing else."
|
||||
|
||||
|
@ -727,6 +733,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
additional_details_result = additional_details_form.submit()
|
||||
# validate that data from this step are being saved
|
||||
domain_request = DomainRequest.objects.get() # there's only one
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, "cisa-first-name")
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, "cisa-last-name")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "FakeEmail@gmail.com")
|
||||
self.assertEqual(domain_request.anything_else, "Nothing else.")
|
||||
# the post request should return a redirect to the next form in
|
||||
|
@ -1125,11 +1133,10 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
def test_yes_no_form_inits_yes_for_cisa_representative_and_anything_else(self):
|
||||
"""On the Additional Details page, the yes/no form gets initialized with YES selected
|
||||
for both yes/no radios if the domain request has a value for cisa_representative and
|
||||
for both yes/no radios if the domain request has a values for cisa_representative_first_name and
|
||||
anything_else"""
|
||||
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=True)
|
||||
domain_request.cisa_representative_email = "test@igorville.gov"
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=True, has_cisa_representative=True)
|
||||
domain_request.anything_else = "1234"
|
||||
domain_request.save()
|
||||
|
||||
|
@ -1181,12 +1188,13 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
"""On the Additional details page, the form preselects "no" when has_cisa_representative
|
||||
and anything_else is no"""
|
||||
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(
|
||||
user=self.user, has_anything_else=False, has_cisa_representative=False
|
||||
)
|
||||
|
||||
# Unlike the other contacts form, the no button is tracked with these boolean fields.
|
||||
# This means that we should expect this to correlate with the no button.
|
||||
domain_request.has_anything_else_text = False
|
||||
domain_request.has_cisa_representative = False
|
||||
domain_request.save()
|
||||
|
||||
# prime the form by visiting /edit
|
||||
|
@ -1205,7 +1213,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
# Check the cisa representative yes/no field
|
||||
yes_no_cisa = additional_details_form["additional_details-has_cisa_representative"].value
|
||||
self.assertEquals(yes_no_cisa, "False")
|
||||
self.assertEquals(yes_no_cisa, None)
|
||||
|
||||
# Check the anything else yes/no field
|
||||
yes_no_anything_else = additional_details_form["additional_details-has_anything_else_text"].value
|
||||
|
@ -1215,11 +1223,15 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
"""When a user submits the Additional Details form with no selected for all fields,
|
||||
the domain request's data gets wiped when submitted"""
|
||||
domain_request = completed_domain_request(name="nocisareps.gov", user=self.user)
|
||||
domain_request.cisa_representative_first_name = "cisa-firstname1"
|
||||
domain_request.cisa_representative_last_name = "cisa-lastname1"
|
||||
domain_request.cisa_representative_email = "fake@faketown.gov"
|
||||
domain_request.save()
|
||||
|
||||
# Make sure we have the data we need for the test
|
||||
self.assertEqual(domain_request.anything_else, "There is more")
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, "cisa-firstname1")
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, "cisa-lastname1")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "fake@faketown.gov")
|
||||
|
||||
# prime the form by visiting /edit
|
||||
|
@ -1253,25 +1265,31 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
# Verify that the anything_else and cisa_representative have been deleted from the DB
|
||||
# Verify that the anything_else and cisa_representative information have been deleted from the DB
|
||||
domain_request = DomainRequest.objects.get(requested_domain__name="nocisareps.gov")
|
||||
|
||||
# Check that our data has been cleared
|
||||
self.assertEqual(domain_request.anything_else, None)
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, None)
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, None)
|
||||
self.assertEqual(domain_request.cisa_representative_email, None)
|
||||
|
||||
# Double check the yes/no fields
|
||||
self.assertEqual(domain_request.has_anything_else_text, False)
|
||||
self.assertEqual(domain_request.has_cisa_representative, False)
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, None)
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, None)
|
||||
self.assertEqual(domain_request.cisa_representative_email, None)
|
||||
|
||||
def test_submitting_additional_details_populates_cisa_representative_and_anything_else(self):
|
||||
"""When a user submits the Additional Details form,
|
||||
the domain request's data gets submitted"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(
|
||||
name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False
|
||||
)
|
||||
|
||||
# Make sure we have the data we need for the test
|
||||
self.assertEqual(domain_request.anything_else, None)
|
||||
self.assertEqual(domain_request.cisa_representative_email, None)
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, None)
|
||||
|
||||
# These fields should not be selected at all, since we haven't initialized the form yet
|
||||
self.assertEqual(domain_request.has_anything_else_text, None)
|
||||
|
@ -1294,6 +1312,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
# Set fields to true, and set data on those fields
|
||||
additional_details_form["additional_details-has_cisa_representative"] = "True"
|
||||
additional_details_form["additional_details-has_anything_else_text"] = "True"
|
||||
additional_details_form["additional_details-cisa_representative_first_name"] = "cisa-firstname"
|
||||
additional_details_form["additional_details-cisa_representative_last_name"] = "cisa-lastname"
|
||||
additional_details_form["additional_details-cisa_representative_email"] = "test@faketest.gov"
|
||||
additional_details_form["additional_details-anything_else"] = "redandblue"
|
||||
|
||||
|
@ -1302,10 +1322,12 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
# Verify that the anything_else and cisa_representative exist in the db
|
||||
# Verify that the anything_else and cisa_representative information exist in the db
|
||||
domain_request = DomainRequest.objects.get(requested_domain__name="cisareps.gov")
|
||||
|
||||
self.assertEqual(domain_request.anything_else, "redandblue")
|
||||
self.assertEqual(domain_request.cisa_representative_first_name, "cisa-firstname")
|
||||
self.assertEqual(domain_request.cisa_representative_last_name, "cisa-lastname")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "test@faketest.gov")
|
||||
|
||||
self.assertEqual(domain_request.has_cisa_representative, True)
|
||||
|
@ -1313,7 +1335,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
def test_if_cisa_representative_yes_no_form_is_yes_then_field_is_required(self):
|
||||
"""Applicants with a cisa representative must provide a value"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(
|
||||
name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False
|
||||
)
|
||||
|
||||
# prime the form by visiting /edit
|
||||
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
|
||||
|
@ -1338,7 +1362,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
self.assertContains(response, "Enter the email address of your CISA regional representative.")
|
||||
self.assertContains(response, "Enter the first name / given name of the CISA regional representative.")
|
||||
self.assertContains(response, "Enter the last name / family name of the CISA regional representative.")
|
||||
|
||||
def test_if_anything_else_yes_no_form_is_yes_then_field_is_required(self):
|
||||
"""Applicants with a anything else must provide a value"""
|
||||
|
@ -1373,7 +1398,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
def test_additional_details_form_fields_required(self):
|
||||
"""When a user submits the Additional Details form without checking the
|
||||
has_cisa_representative and has_anything_else_text fields, the form should deny this action"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(
|
||||
name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False
|
||||
)
|
||||
|
||||
self.assertEqual(domain_request.has_anything_else_text, None)
|
||||
self.assertEqual(domain_request.has_cisa_representative, None)
|
||||
|
|
12
src/registrar/utility/constants.py
Normal file
12
src/registrar/utility/constants.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class BranchChoices(models.TextChoices):
|
||||
EXECUTIVE = "executive", "Executive"
|
||||
JUDICIAL = "judicial", "Judicial"
|
||||
LEGISLATIVE = "legislative", "Legislative"
|
||||
|
||||
@classmethod
|
||||
def get_branch_label(cls, branch_name: str):
|
||||
"""Returns the associated label for a given org name"""
|
||||
return cls(branch_name).label if branch_name else None
|
|
@ -1,18 +1,25 @@
|
|||
import csv
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from registrar.models.domain import Domain
|
||||
from registrar.models.domain_invitation import DomainInvitation
|
||||
from registrar.models.domain_request import DomainRequest
|
||||
from registrar.models.domain_information import DomainInformation
|
||||
from registrar.models import (
|
||||
Domain,
|
||||
DomainInvitation,
|
||||
DomainRequest,
|
||||
DomainInformation,
|
||||
PublicContact,
|
||||
UserDomainRole,
|
||||
)
|
||||
from django.db.models import QuerySet, Value, CharField, Count, Q, F
|
||||
from django.db.models import ManyToManyField
|
||||
from django.utils import timezone
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models import F, Value, CharField
|
||||
from django.db.models.functions import Concat, Coalesce
|
||||
|
||||
from registrar.models.public_contact import PublicContact
|
||||
from registrar.models.user_domain_role import UserDomainRole
|
||||
from django.contrib.postgres.aggregates import StringAgg
|
||||
from registrar.models.utility.generic_helper import convert_queryset_to_dict
|
||||
from registrar.templatetags.custom_filters import get_region
|
||||
from registrar.utility.enums import DefaultEmail
|
||||
from registrar.utility.constants import BranchChoices
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -299,88 +306,11 @@ def write_csv_for_domains(
|
|||
writer.writerows(total_body_rows)
|
||||
|
||||
|
||||
def get_requests(filter_condition, sort_fields):
|
||||
"""
|
||||
Returns DomainRequest objects filtered and sorted based on the provided conditions.
|
||||
filter_condition -> A dictionary of conditions to filter the objects.
|
||||
sort_fields -> A list of fields to sort the resulting query set.
|
||||
returns: A queryset of DomainRequest objects
|
||||
"""
|
||||
requests = DomainRequest.objects.filter(**filter_condition).order_by(*sort_fields).distinct()
|
||||
return requests
|
||||
|
||||
|
||||
def parse_row_for_requests(columns, request: DomainRequest):
|
||||
"""Given a set of columns, generate a new row from cleaned column data"""
|
||||
|
||||
requested_domain_name = "No requested domain"
|
||||
|
||||
if request.requested_domain is not None:
|
||||
requested_domain_name = request.requested_domain.name
|
||||
|
||||
if request.federal_type:
|
||||
request_type = f"{request.get_organization_type_display()} - {request.get_federal_type_display()}"
|
||||
else:
|
||||
request_type = request.get_organization_type_display()
|
||||
|
||||
# create a dictionary of fields which can be included in output
|
||||
FIELDS = {
|
||||
"Requested domain": requested_domain_name,
|
||||
"Status": request.get_status_display(),
|
||||
"Organization type": request_type,
|
||||
"Agency": request.federal_agency,
|
||||
"Organization name": request.organization_name,
|
||||
"City": request.city,
|
||||
"State": request.state_territory,
|
||||
"AO email": request.authorizing_official.email if request.authorizing_official else " ",
|
||||
"Security contact email": request,
|
||||
"Created at": request.created_at,
|
||||
"Submission date": request.submission_date,
|
||||
}
|
||||
|
||||
row = [FIELDS.get(column, "") for column in columns]
|
||||
return row
|
||||
|
||||
|
||||
def write_csv_for_requests(
|
||||
writer,
|
||||
columns,
|
||||
sort_fields,
|
||||
filter_condition,
|
||||
should_write_header=True,
|
||||
):
|
||||
"""Receives params from the parent methods and outputs a CSV with filtered and sorted requests.
|
||||
Works with write_header as long as the same writer object is passed."""
|
||||
|
||||
all_requests = get_requests(filter_condition, sort_fields)
|
||||
|
||||
# Reduce the memory overhead when performing the write operation
|
||||
paginator = Paginator(all_requests, 1000)
|
||||
total_body_rows = []
|
||||
|
||||
for page_num in paginator.page_range:
|
||||
page = paginator.page(page_num)
|
||||
rows = []
|
||||
for request in page.object_list:
|
||||
try:
|
||||
row = parse_row_for_requests(columns, request)
|
||||
rows.append(row)
|
||||
except ValueError:
|
||||
# This should not happen. If it does, just skip this row.
|
||||
# It indicates that DomainInformation.domain is None.
|
||||
logger.error("csv_export -> Error when parsing row, domain was None")
|
||||
continue
|
||||
total_body_rows.extend(rows)
|
||||
|
||||
if should_write_header:
|
||||
write_header(writer, columns)
|
||||
writer.writerows(total_body_rows)
|
||||
|
||||
|
||||
def export_data_type_to_csv(csv_file):
|
||||
"""
|
||||
All domains report with extra columns.
|
||||
This maps to the "All domain metadata" button.
|
||||
Exports domains of all statuses.
|
||||
"""
|
||||
|
||||
writer = csv.writer(csv_file)
|
||||
|
@ -408,15 +338,8 @@ def export_data_type_to_csv(csv_file):
|
|||
"federal_agency",
|
||||
"domain__name",
|
||||
]
|
||||
filter_condition = {
|
||||
"domain__state__in": [
|
||||
Domain.State.READY,
|
||||
Domain.State.DNS_NEEDED,
|
||||
Domain.State.ON_HOLD,
|
||||
],
|
||||
}
|
||||
write_csv_for_domains(
|
||||
writer, columns, sort_fields, filter_condition, should_get_domain_managers=True, should_write_header=True
|
||||
writer, columns, sort_fields, filter_condition={}, should_get_domain_managers=True, should_write_header=True
|
||||
)
|
||||
|
||||
|
||||
|
@ -781,30 +704,338 @@ def export_data_unmanaged_domains_to_csv(csv_file, start_date, end_date):
|
|||
)
|
||||
|
||||
|
||||
def export_data_requests_growth_to_csv(csv_file, start_date, end_date):
|
||||
class DomainRequestExport:
|
||||
"""
|
||||
Growth report:
|
||||
Receive start and end dates from the view, parse them.
|
||||
Request from write_requests_body SUBMITTED requests that are created between
|
||||
the start and end dates. Specify sort params.
|
||||
A collection of functions which return csv files regarding the DomainRequest model.
|
||||
"""
|
||||
|
||||
start_date_formatted = format_start_date(start_date)
|
||||
end_date_formatted = format_end_date(end_date)
|
||||
writer = csv.writer(csv_file)
|
||||
# define columns to include in export
|
||||
columns = [
|
||||
"Requested domain",
|
||||
"Organization type",
|
||||
"Submission date",
|
||||
# Get all columns on the full metadata report
|
||||
all_columns = [
|
||||
"Domain request",
|
||||
"Submitted at",
|
||||
"Status",
|
||||
"Domain type",
|
||||
"Federal type",
|
||||
"Federal agency",
|
||||
"Organization name",
|
||||
"Election office",
|
||||
"City",
|
||||
"State/territory",
|
||||
"Region",
|
||||
"Creator first name",
|
||||
"Creator last name",
|
||||
"Creator email",
|
||||
"Creator approved domains count",
|
||||
"Creator active requests count",
|
||||
"Alternative domains",
|
||||
"AO first name",
|
||||
"AO last name",
|
||||
"AO email",
|
||||
"AO title/role",
|
||||
"Request purpose",
|
||||
"Request additional details",
|
||||
"Other contacts",
|
||||
"CISA regional representative",
|
||||
"Current websites",
|
||||
"Investigator",
|
||||
]
|
||||
sort_fields = [
|
||||
"requested_domain__name",
|
||||
]
|
||||
filter_condition = {
|
||||
"status": DomainRequest.DomainRequestStatus.SUBMITTED,
|
||||
"submission_date__lte": end_date_formatted,
|
||||
"submission_date__gte": start_date_formatted,
|
||||
}
|
||||
|
||||
write_csv_for_requests(writer, columns, sort_fields, filter_condition, should_write_header=True)
|
||||
@classmethod
|
||||
def export_data_requests_growth_to_csv(cls, csv_file, start_date, end_date):
|
||||
"""
|
||||
Growth report:
|
||||
Receive start and end dates from the view, parse them.
|
||||
Request from write_requests_body SUBMITTED requests that are created between
|
||||
the start and end dates. Specify sort params.
|
||||
"""
|
||||
|
||||
start_date_formatted = format_start_date(start_date)
|
||||
end_date_formatted = format_end_date(end_date)
|
||||
writer = csv.writer(csv_file)
|
||||
# define columns to include in export
|
||||
columns = [
|
||||
"Domain request",
|
||||
"Domain type",
|
||||
"Federal type",
|
||||
"Submitted at",
|
||||
]
|
||||
|
||||
sort_fields = [
|
||||
"requested_domain__name",
|
||||
]
|
||||
filter_condition = {
|
||||
"status": DomainRequest.DomainRequestStatus.SUBMITTED,
|
||||
"submission_date__lte": end_date_formatted,
|
||||
"submission_date__gte": start_date_formatted,
|
||||
}
|
||||
|
||||
# We don't want to annotate anything, but we do want to access the requested domain name
|
||||
annotations = {}
|
||||
additional_values = ["requested_domain__name"]
|
||||
|
||||
all_requests = DomainRequest.objects.filter(**filter_condition).order_by(*sort_fields).distinct()
|
||||
|
||||
annotated_requests = cls.annotate_and_retrieve_fields(all_requests, annotations, additional_values)
|
||||
requests_dict = convert_queryset_to_dict(annotated_requests, is_model=False)
|
||||
|
||||
cls.write_csv_for_requests(writer, columns, requests_dict)
|
||||
|
||||
@classmethod
|
||||
def export_full_domain_request_report(cls, csv_file):
|
||||
"""
|
||||
Generates a detailed domain request report to a CSV file.
|
||||
|
||||
Retrieves and annotates DomainRequest objects, excluding 'STARTED' status,
|
||||
with related data optimizations via select/prefetch and annotation.
|
||||
|
||||
Annotated with counts and aggregates of related entities.
|
||||
Converts to dict and writes to CSV using predefined columns.
|
||||
|
||||
Parameters:
|
||||
csv_file (file-like object): Target CSV file.
|
||||
"""
|
||||
writer = csv.writer(csv_file)
|
||||
|
||||
requests = (
|
||||
DomainRequest.objects.select_related(
|
||||
"creator", "authorizing_official", "federal_agency", "investigator", "requested_domain"
|
||||
)
|
||||
.prefetch_related("current_websites", "other_contacts", "alternative_domains")
|
||||
.exclude(status__in=[DomainRequest.DomainRequestStatus.STARTED])
|
||||
.order_by(
|
||||
"status",
|
||||
"requested_domain__name",
|
||||
)
|
||||
.distinct()
|
||||
)
|
||||
|
||||
# Annotations are custom columns returned to the queryset (AKA: computed in the DB).
|
||||
annotations = cls._full_domain_request_annotations()
|
||||
|
||||
# The .values returned from annotate_and_retrieve_fields can't go two levels deep
|
||||
# (just returns the field id of say, "creator") - so we have to include this.
|
||||
additional_values = [
|
||||
"requested_domain__name",
|
||||
"federal_agency__agency",
|
||||
"authorizing_official__first_name",
|
||||
"authorizing_official__last_name",
|
||||
"authorizing_official__email",
|
||||
"authorizing_official__title",
|
||||
"creator__first_name",
|
||||
"creator__last_name",
|
||||
"creator__email",
|
||||
"investigator__email",
|
||||
]
|
||||
|
||||
# Convert the domain request queryset to a dictionary (including annotated fields)
|
||||
annotated_requests = cls.annotate_and_retrieve_fields(requests, annotations, additional_values)
|
||||
requests_dict = convert_queryset_to_dict(annotated_requests, is_model=False)
|
||||
|
||||
# Write the csv file
|
||||
cls.write_csv_for_requests(writer, cls.all_columns, requests_dict)
|
||||
|
||||
@classmethod
|
||||
def _full_domain_request_annotations(cls, delimiter=" | "):
|
||||
"""Returns the annotations for the full domain request report"""
|
||||
return {
|
||||
"creator_approved_domains_count": DomainRequestExport.get_creator_approved_domains_count_query(),
|
||||
"creator_active_requests_count": DomainRequestExport.get_creator_active_requests_count_query(),
|
||||
"all_current_websites": StringAgg("current_websites__website", delimiter=delimiter, distinct=True),
|
||||
"all_alternative_domains": StringAgg("alternative_domains__website", delimiter=delimiter, distinct=True),
|
||||
# Coerce the other contacts object to "{first_name} {last_name} {email}"
|
||||
"all_other_contacts": StringAgg(
|
||||
Concat(
|
||||
"other_contacts__first_name",
|
||||
Value(" "),
|
||||
"other_contacts__last_name",
|
||||
Value(" "),
|
||||
"other_contacts__email",
|
||||
),
|
||||
delimiter=delimiter,
|
||||
distinct=True,
|
||||
),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def write_csv_for_requests(
|
||||
writer,
|
||||
columns,
|
||||
requests_dict,
|
||||
should_write_header=True,
|
||||
):
|
||||
"""Receives params from the parent methods and outputs a CSV with filtered and sorted requests.
|
||||
Works with write_header as long as the same writer object is passed."""
|
||||
|
||||
rows = []
|
||||
for request in requests_dict.values():
|
||||
try:
|
||||
row = DomainRequestExport.parse_row_for_requests(columns, request)
|
||||
rows.append(row)
|
||||
except ValueError as err:
|
||||
logger.error(f"csv_export -> Error when parsing row: {err}")
|
||||
continue
|
||||
|
||||
if should_write_header:
|
||||
write_header(writer, columns)
|
||||
|
||||
writer.writerows(rows)
|
||||
|
||||
@staticmethod
|
||||
def parse_row_for_requests(columns, request):
|
||||
"""
|
||||
Given a set of columns and a request dictionary, generate a new row from cleaned column data.
|
||||
"""
|
||||
|
||||
# Handle the federal_type field. Defaults to the wrong format.
|
||||
federal_type = request.get("federal_type")
|
||||
human_readable_federal_type = BranchChoices.get_branch_label(federal_type) if federal_type else None
|
||||
|
||||
# Handle the org_type field
|
||||
org_type = request.get("generic_org_type") or request.get("organization_type")
|
||||
human_readable_org_type = DomainRequest.OrganizationChoices.get_org_label(org_type) if org_type else None
|
||||
|
||||
# Handle the status field. Defaults to the wrong format.
|
||||
status = request.get("status")
|
||||
status_display = DomainRequest.DomainRequestStatus.get_status_label(status) if status else None
|
||||
|
||||
# Handle the region field.
|
||||
state_territory = request.get("state_territory")
|
||||
region = get_region(state_territory) if state_territory else None
|
||||
|
||||
# Handle the requested_domain field (add a default if None)
|
||||
requested_domain = request.get("requested_domain__name")
|
||||
requested_domain_name = requested_domain if requested_domain else "No requested domain"
|
||||
|
||||
# Handle the election field. N/A if None, "Yes"/"No" if boolean
|
||||
human_readable_election_board = "N/A"
|
||||
is_election_board = request.get("is_election_board")
|
||||
if is_election_board is not None:
|
||||
human_readable_election_board = "Yes" if is_election_board else "No"
|
||||
|
||||
# Handle the additional details field. Pipe seperated.
|
||||
cisa_rep_first = request.get("cisa_representative_first_name")
|
||||
cisa_rep_last = request.get("cisa_representative_last_name")
|
||||
name = [n for n in [cisa_rep_first, cisa_rep_last] if n]
|
||||
|
||||
cisa_rep = " ".join(name) if name else None
|
||||
details = [cisa_rep, request.get("anything_else")]
|
||||
additional_details = " | ".join([field for field in details if field])
|
||||
|
||||
# create a dictionary of fields which can be included in output.
|
||||
# "extra_fields" are precomputed fields (generated in the DB or parsed).
|
||||
FIELDS = {
|
||||
# Parsed fields - defined above.
|
||||
"Domain request": requested_domain_name,
|
||||
"Region": region,
|
||||
"Status": status_display,
|
||||
"Election office": human_readable_election_board,
|
||||
"Federal type": human_readable_federal_type,
|
||||
"Domain type": human_readable_org_type,
|
||||
"Request additional details": additional_details,
|
||||
# Annotated fields - passed into the request dict.
|
||||
"Creator approved domains count": request.get("creator_approved_domains_count", 0),
|
||||
"Creator active requests count": request.get("creator_active_requests_count", 0),
|
||||
"Alternative domains": request.get("all_alternative_domains"),
|
||||
"Other contacts": request.get("all_other_contacts"),
|
||||
"Current websites": request.get("all_current_websites"),
|
||||
# Untouched FK fields - passed into the request dict.
|
||||
"Federal agency": request.get("federal_agency__agency"),
|
||||
"AO first name": request.get("authorizing_official__first_name"),
|
||||
"AO last name": request.get("authorizing_official__last_name"),
|
||||
"AO email": request.get("authorizing_official__email"),
|
||||
"AO title/role": request.get("authorizing_official__title"),
|
||||
"Creator first name": request.get("creator__first_name"),
|
||||
"Creator last name": request.get("creator__last_name"),
|
||||
"Creator email": request.get("creator__email"),
|
||||
"Investigator": request.get("investigator__email"),
|
||||
# Untouched fields
|
||||
"Organization name": request.get("organization_name"),
|
||||
"City": request.get("city"),
|
||||
"State/territory": request.get("state_territory"),
|
||||
"Request purpose": request.get("purpose"),
|
||||
"CISA regional representative": request.get("cisa_representative_email"),
|
||||
"Submitted at": request.get("submission_date"),
|
||||
}
|
||||
|
||||
row = [FIELDS.get(column, "") for column in columns]
|
||||
return row
|
||||
|
||||
@classmethod
|
||||
def annotate_and_retrieve_fields(
|
||||
cls, requests, annotations, additional_values=None, include_many_to_many=False
|
||||
) -> QuerySet:
|
||||
"""
|
||||
Applies annotations to a queryset and retrieves specified fields,
|
||||
including class-defined and annotation-defined.
|
||||
|
||||
Parameters:
|
||||
requests (QuerySet): Initial queryset.
|
||||
annotations (dict, optional): Fields to compute {field_name: expression}.
|
||||
additional_values (list, optional): Extra fields to retrieve; defaults to annotation keys if None.
|
||||
include_many_to_many (bool, optional): Determines if we should include many to many fields or not
|
||||
|
||||
Returns:
|
||||
QuerySet: Contains dictionaries with the specified fields for each record.
|
||||
"""
|
||||
|
||||
if additional_values is None:
|
||||
additional_values = []
|
||||
|
||||
# We can infer that if we're passing in annotations,
|
||||
# we want to grab the result of said annotation.
|
||||
if annotations:
|
||||
additional_values.extend(annotations.keys())
|
||||
|
||||
# Get prexisting fields on DomainRequest
|
||||
domain_request_fields = set()
|
||||
for field in DomainRequest._meta.get_fields():
|
||||
# Exclude many to many fields unless we specify
|
||||
many_to_many = isinstance(field, ManyToManyField) and include_many_to_many
|
||||
if many_to_many or not isinstance(field, ManyToManyField):
|
||||
domain_request_fields.add(field.name)
|
||||
|
||||
queryset = requests.annotate(**annotations).values(*domain_request_fields, *additional_values)
|
||||
return queryset
|
||||
|
||||
# ============================================================= #
|
||||
# Helper functions for django ORM queries. #
|
||||
# We are using these rather than pure python for speed reasons. #
|
||||
# ============================================================= #
|
||||
|
||||
@staticmethod
|
||||
def get_creator_approved_domains_count_query():
|
||||
"""
|
||||
Generates a Count query for distinct approved domain requests per creator.
|
||||
|
||||
Returns:
|
||||
Count: Aggregates distinct 'APPROVED' domain requests by creator.
|
||||
"""
|
||||
|
||||
query = Count(
|
||||
"creator__domain_requests_created__id",
|
||||
filter=Q(creator__domain_requests_created__status=DomainRequest.DomainRequestStatus.APPROVED),
|
||||
distinct=True,
|
||||
)
|
||||
return query
|
||||
|
||||
@staticmethod
|
||||
def get_creator_active_requests_count_query():
|
||||
"""
|
||||
Generates a Count query for distinct approved domain requests per creator.
|
||||
|
||||
Returns:
|
||||
Count: Aggregates distinct 'SUBMITTED', 'IN_REVIEW', and 'ACTION_NEEDED' domain requests by creator.
|
||||
"""
|
||||
|
||||
query = Count(
|
||||
"creator__domain_requests_created__id",
|
||||
filter=Q(
|
||||
creator__domain_requests_created__status__in=[
|
||||
DomainRequest.DomainRequestStatus.SUBMITTED,
|
||||
DomainRequest.DomainRequestStatus.IN_REVIEW,
|
||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||
]
|
||||
),
|
||||
distinct=True,
|
||||
)
|
||||
return query
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import boto3
|
||||
import logging
|
||||
import textwrap
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.template.loader import get_template
|
||||
|
@ -27,6 +28,7 @@ def send_templated_email(
|
|||
bcc_address="",
|
||||
context={},
|
||||
attachment_file: str = None,
|
||||
wrap_email=False,
|
||||
):
|
||||
"""Send an email built from a template to one email address.
|
||||
|
||||
|
@ -66,6 +68,11 @@ def send_templated_email(
|
|||
|
||||
try:
|
||||
if attachment_file is None:
|
||||
# Wrap the email body to a maximum width of 80 characters per line.
|
||||
# Not all email clients support CSS to do this, and our .txt files require parsing.
|
||||
if wrap_email:
|
||||
email_body = wrap_text_and_preserve_paragraphs(email_body, width=80)
|
||||
|
||||
ses_client.send_email(
|
||||
FromEmailAddress=settings.DEFAULT_FROM_EMAIL,
|
||||
Destination=destination,
|
||||
|
@ -91,6 +98,26 @@ def send_templated_email(
|
|||
raise EmailSendingError("Could not send SES email.") from exc
|
||||
|
||||
|
||||
def wrap_text_and_preserve_paragraphs(text, width):
|
||||
"""
|
||||
Wraps text to `width` preserving newlines; splits on '\n', wraps segments, rejoins with '\n'.
|
||||
Args:
|
||||
text (str): Text to wrap.
|
||||
width (int): Max width per line, default 80.
|
||||
|
||||
Returns:
|
||||
str: Wrapped text with preserved paragraph structure.
|
||||
"""
|
||||
# Split text into paragraphs by newlines
|
||||
paragraphs = text.split("\n")
|
||||
|
||||
# Add \n to any line that exceeds our max length
|
||||
wrapped_paragraphs = [textwrap.fill(paragraph, width=width) for paragraph in paragraphs]
|
||||
|
||||
# Join paragraphs with double newlines
|
||||
return "\n".join(wrapped_paragraphs)
|
||||
|
||||
|
||||
def send_email_with_attachment(sender, recipient, subject, body, attachment_file, ses_client):
|
||||
# Create a multipart/mixed parent container
|
||||
msg = MIMEMultipart("mixed")
|
||||
|
|
|
@ -79,6 +79,7 @@ class FSMErrorCodes(IntEnum):
|
|||
- 3 INVESTIGATOR_NOT_STAFF Investigator is a non-staff user
|
||||
- 4 INVESTIGATOR_NOT_SUBMITTER The form submitter is not the investigator
|
||||
- 5 NO_REJECTION_REASON No rejection reason is specified
|
||||
- 6 NO_ACTION_NEEDED_REASON No action needed reason is specified
|
||||
"""
|
||||
|
||||
APPROVE_DOMAIN_IN_USE = 1
|
||||
|
@ -86,6 +87,7 @@ class FSMErrorCodes(IntEnum):
|
|||
INVESTIGATOR_NOT_STAFF = 3
|
||||
INVESTIGATOR_NOT_SUBMITTER = 4
|
||||
NO_REJECTION_REASON = 5
|
||||
NO_ACTION_NEEDED_REASON = 6
|
||||
|
||||
|
||||
class FSMDomainRequestError(Exception):
|
||||
|
@ -100,6 +102,7 @@ class FSMDomainRequestError(Exception):
|
|||
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
|
||||
FSMErrorCodes.INVESTIGATOR_NOT_SUBMITTER: ("Only the assigned investigator can make this change."),
|
||||
FSMErrorCodes.NO_REJECTION_REASON: ("A rejection reason is required."),
|
||||
FSMErrorCodes.NO_ACTION_NEEDED_REASON: ("A reason is required for this status."),
|
||||
}
|
||||
|
||||
def __init__(self, *args, code=None, **kwargs):
|
||||
|
|
|
@ -164,6 +164,17 @@ class ExportDataFederal(View):
|
|||
return response
|
||||
|
||||
|
||||
class ExportDomainRequestDataFull(View):
|
||||
"""Generates a downloaded report containing all Domain Requests (except started)"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""Returns a content disposition response for current-full-domain-request.csv"""
|
||||
response = HttpResponse(content_type="text/csv")
|
||||
response["Content-Disposition"] = 'attachment; filename="current-full-domain-request.csv"'
|
||||
csv_export.DomainRequestExport.export_full_domain_request_report(response)
|
||||
return response
|
||||
|
||||
|
||||
class ExportDataDomainsGrowth(View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
# Get start_date and end_date from the request's GET parameters
|
||||
|
@ -191,7 +202,7 @@ class ExportDataRequestsGrowth(View):
|
|||
response["Content-Disposition"] = f'attachment; filename="requests-{start_date}-to-{end_date}.csv"'
|
||||
# For #999: set export_data_domain_growth_to_csv to return the resulting queryset, which we can then use
|
||||
# in context to display this data in the template.
|
||||
csv_export.export_data_requests_growth_to_csv(response, start_date, end_date)
|
||||
csv_export.DomainRequestExport.export_data_requests_growth_to_csv(response, start_date, end_date)
|
||||
|
||||
return response
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
or self.domain_request.no_other_contacts_rationale is not None
|
||||
),
|
||||
"additional_details": (
|
||||
(self.domain_request.anything_else is not None and self.domain_request.cisa_representative_email)
|
||||
(self.domain_request.anything_else is not None and self.domain_request.has_cisa_representative)
|
||||
or self.domain_request.is_policy_acknowledged is not None
|
||||
),
|
||||
"requirements": self.domain_request.is_policy_acknowledged is not None,
|
||||
|
@ -380,7 +380,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
def get_context_data(self):
|
||||
"""Define context for access on all wizard pages."""
|
||||
has_profile_flag = flag_is_active(self.request, "profile_feature")
|
||||
logger.debug("PROFILE FLAG is %s" % has_profile_flag)
|
||||
|
||||
context_stuff = {}
|
||||
if DomainRequest._form_complete(self.domain_request):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue