Skip to content

Commit

Permalink
Merge pull request #25 from stuartcampbell/add-assets-to-skeleton
Browse files Browse the repository at this point in the history
Add assets directory to skeleton
  • Loading branch information
stuartcampbell authored Feb 1, 2024
2 parents 5ec6da5 + 39cd4c4 commit b99e341
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/nsls2api/api/models/proposal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
2 changes: 0 additions & 2 deletions src/nsls2api/api/v1/proposal_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 21 additions & 9 deletions src/nsls2api/services/beamline_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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
return directory_list

0 comments on commit b99e341

Please sign in to comment.