diff --git a/src/nsls2api/api/models/proposal_model.py b/src/nsls2api/api/models/proposal_model.py index ce477c7d..42d0c8ad 100644 --- a/src/nsls2api/api/models/proposal_model.py +++ b/src/nsls2api/api/models/proposal_model.py @@ -103,8 +103,6 @@ class ProposalDirectorySkeleton(pydantic.BaseModel): class ProposalDirectoriesList(pydantic.BaseModel): directory_count: int - beamline: list[str] | None = [] - cycles: list[str] | None = [] directories: list[ProposalDirectories] diff --git a/src/nsls2api/api/v1/proposal_api.py b/src/nsls2api/api/v1/proposal_api.py index 1c7181c8..45c8cd4c 100644 --- a/src/nsls2api/api/v1/proposal_api.py +++ b/src/nsls2api/api/v1/proposal_api.py @@ -178,7 +178,5 @@ async def get_proposal_directories(proposal_id: int) -> ProposalDirectoriesList: response_model = ProposalDirectoriesList( directories=directories, directory_count=len(directories), - beamline=await proposal_service.beamlines_for_proposal(proposal_id), - cycles=await proposal_service.cycles_for_proposal(proposal_id), ) return response_model diff --git a/src/nsls2api/services/beamline_service.py b/src/nsls2api/services/beamline_service.py index 30ce641e..c9139acb 100644 --- a/src/nsls2api/services/beamline_service.py +++ b/src/nsls2api/services/beamline_service.py @@ -51,11 +51,11 @@ async def all_services(name: str) -> Optional[ServicesOnly]: async def detectors(name: str) -> Optional[list[Detector]]: detectors = await Beamline.find_one(Beamline.name == name.upper()).project( DetectorView - ) - + ) + if detectors is None: return None - + return detectors.detectors @@ -134,9 +134,8 @@ async def data_roles_by_user(username: str) -> Optional[list[str]]: async def proposal_directory_skeleton(name: str): - detetector_list = await detectors(name.upper()) - + directory_list = [] # TODO: Make this parameter configurable (i.e. have field in beamline document model for this value) @@ -154,14 +153,26 @@ async def proposal_directory_skeleton(name: str): groups_acl.append({f"n2sn-dataadmin-{name.lower()}": "r-x"}) groups_acl.append({"n2sn-dataadmin": "r-x"}) - + # Add the asset directory so this has the same permissions as the detector directories + # and not just inherit from the parent (i.e. proposal) directory. + asset_directory = { + "path": f"{asset_directory_name}", + "is_absolute": False, + "owner": "nsls2data", + "users": users_acl, + "groups": groups_acl, + "beamline": name.upper(), + } + directory_list.append(asset_directory) + for detector in detetector_list: directory = { "path": f"{asset_directory_name}/{detector.directory_name}", "is_absolute": False, "owner": "nsls2data", "users": users_acl, - "groups": groups_acl + "groups": groups_acl, + "beamline": name.upper(), } directory_list.append(directory) @@ -171,8 +182,9 @@ async def proposal_directory_skeleton(name: str): "is_absolute": False, "owner": "nsls2data", "users": users_acl, - "groups": groups_acl + "groups": groups_acl, + "beamline": name.upper(), } directory_list.append(default_directory) - return directory_list \ No newline at end of file + return directory_list