Displaying differences for changeset
 
display as  

services.py

@@ -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"

static/er2_303d_assess/js/actions/assessment_summary.js

@@ -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

static/er2_303d_assess/js/actions/assessment_tracking.js

@@ -14,9 +14,9 @@
     // 1) load a selected tracking sheet, i.e. when you get to the website for the first time or change which tracking sheet you are on
     // 2) reload the data for a selected tracking sheet after it has been modified (add/update/delete of an assessment entry)
     let hasError = false
-    const selectedTrackingSheet = ""
+    const selectedTrackingSheet = "basins"
     fetch(
-        `/${getState().meta.name}/api/v1/get_selected_assessment_registry/?token=${
+        `/${getState().meta.name}/api/v1/get_selected_tracking_sheet/?token=${
             getState().token.value
         }`,
         {