mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-13 06:28:24 +02:00
Check for api response codes when resetting values
This commit is contained in:
parent
0feb0a7ef8
commit
b89ae53c84
2 changed files with 12 additions and 7 deletions
|
@ -811,7 +811,7 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
organizationType.value = "";
|
organizationType.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// There isn't a senior official associated with null records and non federal agencies
|
// There isn't a federal senior official associated with null records and non federal agencies
|
||||||
if (!selectedText || selectedText === "Non-Federal Agency") {
|
if (!selectedText || selectedText === "Non-Federal Agency") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -825,11 +825,16 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
|
|
||||||
let seniorOfficialApi = document.querySelector("#senior_official_from_agency_json_url").value;
|
let seniorOfficialApi = document.querySelector("#senior_official_from_agency_json_url").value;
|
||||||
fetch(`${seniorOfficialApi}?agency_name=${selectedText}`)
|
fetch(`${seniorOfficialApi}?agency_name=${selectedText}`)
|
||||||
.then(response => response.json())
|
.then(response => {
|
||||||
.then(data => {
|
const statusCode = response.status;
|
||||||
|
return response.json().then(data => ({ statusCode, data }));
|
||||||
|
})
|
||||||
|
.then(({ statusCode, data }) => {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
// Clear the field if the SO doesn't exist
|
// Clear the field if the SO doesn't exist.
|
||||||
|
if (statusCode === 404) {
|
||||||
$seniorOfficial.val("").trigger("change");
|
$seniorOfficial.val("").trigger("change");
|
||||||
|
}
|
||||||
console.error("Error in AJAX call: " + data.error);
|
console.error("Error in AJAX call: " + data.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Portfolio(TimeStampedModel):
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
"""Save override for custom properties"""
|
"""Save override for custom properties"""
|
||||||
|
|
||||||
# We can't have urbanization if the state isn't puerto rico
|
# The urbanization field is only intended for the state_territory puerto rico
|
||||||
if self.state_territory != self.StateTerritoryChoices.PUERTO_RICO and self.urbanization:
|
if self.state_territory != self.StateTerritoryChoices.PUERTO_RICO and self.urbanization:
|
||||||
self.urbanization = None
|
self.urbanization = None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue