@@ -294,6 +294,60 @@ def put(self, request: Request, workspace_id: str, application_id: str):
294294 data = {'application_id' : application_id , 'user_id' : request .user .id ,
295295 'workspace_id' : workspace_id , }).publish (request .data ))
296296
297+ class PortalUp (APIView ):
298+ authentication_classes = [TokenAuth ]
299+
300+ @extend_schema (
301+ methods = ['PUT' ],
302+ description = _ ("Publishing an application to Portal" ),
303+ summary = _ ("Publishing an application to Portal" ),
304+ operation_id = _ ("Publishing an application to Portal" ), # type: ignore
305+ parameters = ApplicationOperateAPI .get_parameters (),
306+ request = None ,
307+ responses = result .DefaultResultSerializer ,
308+ tags = [_ ('Application' )] # type: ignore
309+ )
310+ @has_permissions (PermissionConstants .APPLICATION_PORTAL_UP .get_workspace_application_permission (),
311+ PermissionConstants .APPLICATION_PORTAL_UP .get_workspace_permission_workspace_manage_role (),
312+ ViewPermission ([RoleConstants .USER .get_workspace_role ()],
313+ [PermissionConstants .APPLICATION .get_workspace_application_permission ()],
314+ compare = CompareConstants .AND ),
315+ RoleConstants .WORKSPACE_MANAGE .get_workspace_role ())
316+ @log (menu = 'Application' , operate = 'Publishing an application to Portal' ,
317+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
318+ def put (self , request : Request , workspace_id : str , application_id : str ):
319+ return result .success (
320+ ApplicationOperateSerializer (
321+ data = {'application_id' : application_id , 'user_id' : request .user .id ,
322+ 'workspace_id' : workspace_id , }).portal_up ())
323+
324+ class PortalDown (APIView ):
325+ authentication_classes = [TokenAuth ]
326+
327+ @extend_schema (
328+ methods = ['PUT' ],
329+ description = _ ("Unpublishing an application from Portal" ),
330+ summary = _ ("Unpublishing an application from Portal" ),
331+ operation_id = _ ("Unpublishing an application from Portal" ), # type: ignore
332+ parameters = ApplicationOperateAPI .get_parameters (),
333+ request = None ,
334+ responses = result .DefaultResultSerializer ,
335+ tags = [_ ('Application' )] # type: ignore
336+ )
337+ @has_permissions (PermissionConstants .APPLICATION_PORTAL_DOWN .get_workspace_application_permission (),
338+ PermissionConstants .APPLICATION_PORTAL_DOWN .get_workspace_permission_workspace_manage_role (),
339+ ViewPermission ([RoleConstants .USER .get_workspace_role ()],
340+ [PermissionConstants .APPLICATION .get_workspace_application_permission ()],
341+ compare = CompareConstants .AND ),
342+ RoleConstants .WORKSPACE_MANAGE .get_workspace_role ())
343+ @log (menu = 'Application' , operate = 'Unpublishing an application from Portal' ,
344+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
345+ def put (self , request : Request , workspace_id : str , application_id : str ):
346+ return result .success (
347+ ApplicationOperateSerializer (
348+ data = {'application_id' : application_id , 'user_id' : request .user .id ,
349+ 'workspace_id' : workspace_id , }).portal_down ())
350+
297351 class StoreApplication (APIView ):
298352 authentication_classes = [TokenAuth ]
299353
0 commit comments