Skip to content

Commit c73f211

Browse files
committed
draft implemeting service layer
1 parent 48fd069 commit c73f211

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

services/web/server/src/simcore_service_webserver/projects/_controller/groups_rest.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@ async def share_project(request: web.Request):
6262
body_params.sharee_email,
6363
):
6464

65-
code: IDStr = await _groups_service.create_confirmation_action_to_share_project(
66-
app=request.app,
67-
user_id=req_ctx.user_id,
68-
project_id=path_params.project_id,
69-
sharee_email=body_params.sharee_email,
70-
read=body_params.read,
71-
write=body_params.write,
72-
delete=body_params.delete,
73-
product_name=req_ctx.product_name,
65+
confirmation_code: IDStr = (
66+
await _groups_service.create_confirmation_action_to_share_project(
67+
app=request.app,
68+
user_id=req_ctx.user_id,
69+
project_id=path_params.project_id,
70+
sharee_email=body_params.sharee_email,
71+
read=body_params.read,
72+
write=body_params.write,
73+
delete=body_params.delete,
74+
product_name=req_ctx.product_name,
75+
)
7476
)
7577

76-
confirmation_link: str = login_web.make_confirmation_link(request, code=code)
78+
confirmation_link: str = login_web.make_confirmation_link(
79+
request, code=confirmation_code
80+
)
7781

78-
_logger.debug("Send email with confirmation link: %s", confirmation_link)
82+
_logger.debug(
83+
"Send email with confirmation link %s to %s ",
84+
confirmation_link,
85+
body_params.sharee_email,
86+
)
7987

8088
return web.json_response(status=status.HTTP_204_NO_CONTENT)
8189

@@ -108,7 +116,7 @@ async def create_project_group(request: web.Request):
108116
request.app,
109117
user_id=req_ctx.user_id,
110118
project_id=path_params.project_id,
111-
group_id=path_params.group_id,
119+
sharee_group_id=path_params.group_id,
112120
read=body_params.read,
113121
write=body_params.write,
114122
delete=body_params.delete,

services/web/server/src/simcore_service_webserver/projects/_groups_service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def create_project_group(
3636
*,
3737
user_id: UserID,
3838
project_id: ProjectID,
39-
group_id: GroupID,
39+
sharee_group_id: GroupID,
4040
read: bool,
4141
write: bool,
4242
delete: bool,
@@ -53,7 +53,7 @@ async def create_project_group(
5353
project_group_db: ProjectGroupGetDB = await _groups_repository.create_project_group(
5454
app=app,
5555
project_id=project_id,
56-
group_id=group_id,
56+
group_id=sharee_group_id,
5757
read=read,
5858
write=write,
5959
delete=delete,
@@ -189,7 +189,7 @@ async def create_confirmation_action_to_share_project(
189189
assert app # nosec
190190

191191
_logger.debug(
192-
"Checking that %s in %s has enough access rights (ownership) to %s for sharing",
192+
"Checking that %s in %s has enough access rights (i.e. ownership) to %s for sharing",
193193
f"{user_id=}",
194194
f"{product_name=}",
195195
f"{project_id=}",
@@ -201,6 +201,9 @@ async def create_confirmation_action_to_share_project(
201201
shared_resource_access_rights = AccessRights(read=read, write=write, delete=delete)
202202
shared_at = arrow.utcnow().datetime
203203

204+
# action will be a wrapper around create_project_group that gets primary_gid from the email
205+
# action needs to be statically registered
206+
204207
_logger.debug(
205208
"Creating confirmation token for action=SHARE with and producing a code:"
206209
"\n %s," * 6,

0 commit comments

Comments
 (0)