Mercurial > libervia-web
comparison libervia/pages/photos/new/page_meta.py @ 1278:4385a75e3962
pages (photos/new): photo album creation
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jun 2020 16:47:50 +0200 |
parents | |
children | 198605982d15 |
comparison
equal
deleted
inserted
replaced
1277:2e4fcd31f2a9 | 1278:4385a75e3962 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 from libervia.server.constants import Const as C | |
4 from twisted.internet import defer | |
5 from sat.core.log import getLogger | |
6 from sat.core.i18n import D_ | |
7 from sat.tools.common import date_utils, data_format | |
8 | |
9 """creation of new events""" | |
10 | |
11 name = "photos_new" | |
12 access = C.PAGES_ACCESS_PROFILE | |
13 template = "photo/create.html" | |
14 log = getLogger(__name__) | |
15 | |
16 | |
17 async def on_data_post(self, request): | |
18 request_data = self.getRData(request) | |
19 profile = self.getProfile(request) | |
20 name = self.getPostedData(request, "name") | |
21 if profile is None: | |
22 self.pageError(request, C.HTTP_BAD_REQUEST) | |
23 fis_ns = self.host.ns_map["fis"] | |
24 http_upload_ns = self.host.ns_map["http_upload"] | |
25 entities_services, __, __ = await self.host.bridgeCall( | |
26 "discoFindByFeatures", | |
27 [fis_ns, http_upload_ns], | |
28 [], | |
29 False, | |
30 True, | |
31 False, | |
32 False, | |
33 False, | |
34 profile | |
35 ) | |
36 try: | |
37 fis_service = next(iter(entities_services)) | |
38 except StopIteration: | |
39 raise DataError(D_( | |
40 "You server has no service to create a photo album, please ask your server" | |
41 "administrator to add one")) | |
42 | |
43 await self.host.bridgeCall( | |
44 "interestsRegisterFileSharing", | |
45 fis_service, | |
46 "photos", | |
47 f"photo-album:{name}", | |
48 "", | |
49 name, | |
50 "", | |
51 profile | |
52 ) | |
53 log.info(f"album {name} created") | |
54 request_data["post_redirect_page"] = self.getPageByName("photos") | |
55 defer.returnValue(C.POST_NO_CONFIRM) |