mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Add PR suggestions
This commit is contained in:
parent
47779f8f29
commit
44b8163422
3 changed files with 19 additions and 3 deletions
|
@ -807,10 +807,8 @@ function initializeWidgetOnList(list, parentId) {
|
|||
if (organizationType.value !== "federal") {
|
||||
organizationType.value = "federal";
|
||||
}
|
||||
// Set the SO field
|
||||
}else if (selectedText === "Non-Federal Agency" && organizationType.value === "federal") {
|
||||
organizationType.value = "";
|
||||
// Set the SO field
|
||||
}
|
||||
|
||||
// There isn't a senior official associated with null records and non federal agencies
|
||||
|
@ -830,6 +828,8 @@ function initializeWidgetOnList(list, parentId) {
|
|||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
// Clear the field if the SO doesn't exist
|
||||
$seniorOfficial.val("").trigger("change");
|
||||
console.error('Error in AJAX call: ' + data.error);
|
||||
return;
|
||||
}
|
||||
|
@ -837,7 +837,8 @@ function initializeWidgetOnList(list, parentId) {
|
|||
let seniorOfficialId = data.id;
|
||||
let seniorOfficialName = [data.first_name, data.last_name].join(" ");
|
||||
if (!seniorOfficialId || !seniorOfficialName || !seniorOfficialName.trim()){
|
||||
console.error("Could not assign current Senior Official: no values found.")
|
||||
// Clear the field if the SO doesn't exist
|
||||
$seniorOfficial.val("").trigger("change");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,3 +110,12 @@ class Portfolio(TimeStampedModel):
|
|||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.organization_name}"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Save override for custom properties"""
|
||||
|
||||
# We can't have urbanization if the state isn't puerto rico
|
||||
if self.state_territory != self.StateTerritoryChoices.PUERTO_RICO and self.urbanization:
|
||||
self.urbanization = None
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
|
|
@ -25,6 +25,12 @@ def get_senior_official_from_federal_agency_json(request):
|
|||
if agency and senior_official:
|
||||
# Convert the agency object to a dictionary
|
||||
so_dict = model_to_dict(senior_official)
|
||||
|
||||
# The phone number field isn't json serializable, so we
|
||||
# convert this to a string first if it exists.
|
||||
if "phone" in so_dict and so_dict.get("phone"):
|
||||
so_dict["phone"] = str(so_dict["phone"])
|
||||
|
||||
return JsonResponse(so_dict)
|
||||
else:
|
||||
return JsonResponse({"error": "Senior Official not found"}, status=404)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue