# HG changeset patch # User Goffi # Date 1600353894 -7200 # Node ID 39719ff4fcadd3da255175d1e9c6f3c3f077e81a # Parent 6f342b36871c6b8d597e0044cbac1b2386c48d3a pages (photos/new): fix permissions: "/albums" path is created with `open` access model if it doesn't already exist. The album itself is created as a sub-directory with a `whitelist` access model, if it doesn't already exist (otherwise the album is just added in list of interests). diff -r 6f342b36871c -r 39719ff4fcad libervia/pages/photos/new/page_meta.py --- a/libervia/pages/photos/new/page_meta.py Thu Sep 17 08:59:43 2020 +0200 +++ b/libervia/pages/photos/new/page_meta.py Thu Sep 17 16:44:54 2020 +0200 @@ -5,6 +5,7 @@ from sat.core.log import getLogger from sat.core.i18n import D_ from sat.core import exceptions +from sat_frontends.bridge.bridge_frontend import BridgeException """creation of new events""" @@ -18,6 +19,8 @@ request_data = self.getRData(request) profile = self.getProfile(request) name = self.getPostedData(request, "name").replace('/', '_') + albums_path = "/albums" + album_path = f"{albums_path}/{name}" if profile is None: self.pageError(request, C.HTTP_BAD_REQUEST) fis_ns = self.host.ns_map["fis"] @@ -40,12 +43,44 @@ "You server has no service to create a photo album, please ask your server " "administrator to add one")) + try: + await self.host.bridgeCall( + "FISCreateDir", + fis_service, + "", + albums_path, + {"access_model": "open"}, + profile + ) + except BridgeException as e: + if e.condition == 'conflict': + pass + else: + log.error(f"Can't create {albums_path} path: {e}") + raise e + + try: + await self.host.bridgeCall( + "FISCreateDir", + fis_service, + "", + album_path, + {"access_model": "whitelist"}, + profile + ) + except BridgeException as e: + if e.condition == 'conflict': + pass + else: + log.error(f"Can't create {album_path} path: {e}") + raise e + await self.host.bridgeCall( "interestsRegisterFileSharing", fis_service, "photos", "", - f"/albums/{name}", + album_path, name, "", profile