@@ -2663,7 +2663,8 @@ |
) |
self.kind = "AssessmentTracking" |
self.registry = { |
- "basins": [], |
+ "2021 Arkansas/Rio Grande": [], |
+ "2022 Upper/Lower Colorado": [], |
} |
self.assessments = [] |
self.load_registry() |
@@ -2675,47 +2676,42 @@ |
|
def get_selected_registry(self, selected_tracking_sheet): |
"""Fetch a particular tracking sheet""" |
- |
- |
-# import pdb; pdb.set_trace() |
- for basin_data in self.registry["basins"]: |
+ if selected_tracking_sheet not in self.registry: |
+ return "Unable to find specified tracking sheet "{0}" in the registry.".format(selected_tracking_sheet) |
+ for basin_data in self.registry[selected_tracking_sheet]: |
for site in basin_data["sites"]: |
self.assessments.append(site) |
return er2_api.respond(self) |
|
def add_summary_to_tracking_sheet(self, selected_tracking_sheet, summary_arg): |
summary = summary_arg.copy() |
- summary.update( |
- { |
- "token": self._token["value"], |
- } |
- ) |
+ summary.update({ "token": self._token["value"] }) |
|
# Locate the basin |
subBasin = summary["SubBasin"] |
ibasins = [ |
i |
- for i, b in enumerate(self.registry["basins"]) |
+ for i, b in enumerate(self.registry[selected_tracking_sheet]) |
if b["basin"] == subBasin or b["name"] == subBasin |
] |
if not ibasins: |
- return "Unable to save assessment {0} to the tracking list because this basin is not part of the current assessment area.".format(subBasin) |
+ return "Unable to save assessment {0} to the tracking list "{1}" because this basin is not part of the current assessment area.".format(subBasin, selected_tracking_sheet) |
# raise Exception(f"No basin named {subBasin} in assessment registry.") |
ibasin = ibasins[0] |
- basin = self.registry["basins"][ibasin] |
+ tracking_sheet_content = self.registry[selected_tracking_sheet][ibasin] |
# Locate the site by matching the station ID or AUID/WBID |
comp_key = "Site ID" |
if summary["Type"] != "station": |
# AUID/WBID |
comp_key = summary["Type"].upper() |
isites = [] |
- for i, s in enumerate(basin["sites"]): |
+ for i, s in enumerate(tracking_sheet_content["sites"]): |
if s[comp_key] == summary[comp_key] and s["Type"] == summary["Type"]: |
isites.append(i) |
if isites: |
- basin["sites"][isites[0]] = summary |
+ tracking_sheet_content["sites"][isites[0]] = summary |
else: |
- basin["sites"].append(summary) |
+ tracking_sheet_content["sites"].append(summary) |
self.save_registry() |
if isites: |
return "Updated assessment" |
@@ -12,7 +12,7 @@ |
export const addToRegistry = () => (dispatch, getState) => { |
let hasError = false |
const { summary } = getState().assessmentSummary |
- const selectedTrackingSheet = "" |
+ const selectedTrackingSheet = "basins" |
fetch( |
`/${getState().meta.name}/api/v1/add_to_tracking_sheet/?token=${ |
getState().token.value |
@@ -49,7 +49,7 @@ |
getState, |
) => { |
let hasError = false |
- const selectedTrackingSheet = "" |
+ const selectedTrackingSheet = "basins" |
fetch( |
`/${getState().meta.name}/api/v1/remove_from_tracking_sheet/?token=${ |
getState().token.value |