Skip to content

Commit

Permalink
fix rack edit default site issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pipaLU committed Oct 5, 2023
1 parent 06ec6d0 commit ca5ccc9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Binary file modified services/web/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions services/web/app/sample/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ def func_shelf_location(id):
"shelf_name",
]
location = dict(zip(colnames, location))
#location["coldstorage_type"]= "(%s) %s" % (location["coldstorage_type"].name, location["coldstorage_type"].value)
location["coldstorage_type"] = location["coldstorage_type"].value # deal with enum
location["coldstorage_temp"] = location["coldstorage_temp"].value

return {"location": location, "pretty": pretty}

Expand Down
11 changes: 9 additions & 2 deletions services/web/app/storage/api/rack.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

from sqlalchemy.sql import insert, func
from sqlalchemy import or_, and_, not_, select, text
from sqlalchemy.orm import aliased
# from sqlalchemy.orm import aliased
from marshmallow import ValidationError

from ..views.rack import *
Expand Down Expand Up @@ -1226,8 +1226,9 @@ def storage_rack_delete(id, tokenuser: UserAccount):


@api.route("/storage/rack/location/LIMBRACK-<id>", methods=["GET"])
@api.route("/storage/rack/location/LIMBRACK-<id>/detail-<detailed>", methods=["GET"])
@token_required
def storage_rack_location(id, tokenuser: UserAccount):
def storage_rack_location(id, tokenuser: UserAccount, detailed=0):
# Get shelf_id for the give rack id
stmt = (
db.session.query(SampleRack)
Expand Down Expand Up @@ -1289,6 +1290,12 @@ def storage_rack_location(id, tokenuser: UserAccount):
][0]
result.update(result1)

if int(detailed)==1:
# Get site/building/room info for the rack
shelf_id = result1["shelf_id"]
location = func_shelf_location(shelf_id)["location"]
result.update(location)

return success_with_content_response(result)


Expand Down
5 changes: 2 additions & 3 deletions services/web/app/storage/routes/rack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ def edit_rack(id):

if response.status_code == 200:
response = requests.get(
url_for("api.storage_rack_location", id=id, _external=True),
url_for("api.storage_rack_location", id=id, detailed=1, _external=True),
# url_for("api.storage_rack_view", id=id, _external=True),
headers=get_internal_api_header(),
)
Expand All @@ -1091,7 +1091,6 @@ def edit_rack(id):

# For SampleRack with location info.
rack = response.json()["content"]
# print("Rack: ", rack)
shelves = []
shelf_dict = {}
shelf_required = True
Expand All @@ -1114,13 +1113,13 @@ def edit_rack(id):

# shelf_required = len(shelves) > 0

print("rack: ", rack)
form = EditSampleRackForm(
sites=sites,
shelves=shelves,
data={
"serial": rack["serial_number"],
"description": rack["description"],
"site_id": rack["site_id"],
"storage_id": rack["storage_id"],
"shelf_id": rack["shelf_id"],
"compartment_row": rack["compartment_row"],
Expand Down

0 comments on commit ca5ccc9

Please sign in to comment.