Mercurial > libervia-web
changeset 1356:39719ff4fcad
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).
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 17 Sep 2020 16:44:54 +0200 |
parents | 6f342b36871c |
children | dbd573b0bc9c |
files | libervia/pages/photos/new/page_meta.py |
diffstat | 1 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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