annotate libervia/web/pages/files/list/page_meta.py @ 1598:86c7a3a625d5

server: always start a new session on connection: The session was kept when a user was connecting from service profile (but not from other profiles), this was leading to session fixation vulnerability (an attacker on the same machine could get service profile session cookie, and use it when a victim would log-in). This patch fixes it by always starting a new session on connection. fix 443
author Goffi <goffi@goffi.org>
date Fri, 23 Feb 2024 13:35:24 +0100
parents eb00d593801d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
1 #!/usr/bin/env python3
1239
f511f8fbbf8a fixed shebangs
Goffi <goffi@goffi.org>
parents: 1216
diff changeset
2
1290
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
3 import json
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
4 import os
1313
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
5 from pathlib import Path
1518
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
6 from libervia.backend.core.log import getLogger
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
7 from libervia.backend.tools.common import uri
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
8 from libervia.frontends.bridge.bridge_frontend import BridgeException
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
9 from libervia.web.server.constants import Const as C
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
10 from libervia.web.server import session_iface
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
11 from libervia.web.server import pages_tools
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
12
1145
29eb15062416 pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
13 log = getLogger(__name__)
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 """files handling pages"""
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
16 name = "files_list"
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 access = C.PAGES_ACCESS_PROFILE
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
18 template = "file/overview.html"
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
20
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 def parse_url(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
22 self.get_path_args(request, ["service", "*path"], min_args=1, service="jid", path="")
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
23
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
1419
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
25 def add_breadcrumb(self, request, breadcrumbs):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
26 data = self.get_r_data(request)
1419
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
27 breadcrumbs.append({
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
28 "label": data["service"],
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
29 "url": self.get_url(data["service"].full()),
1419
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
30 "icon": "server",
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
31 })
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
32 for idx, p in enumerate(data["path"]):
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
33 breadcrumbs.append({
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
34 "label": p,
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
35 "url": self.get_url(data["service"].full(), *data["path"][:idx+1]),
1419
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
36 "icon": "folder-open-empty",
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
37 })
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
38
6fc41f000d24 pages (blog/view, u, files/list): custom breadcrumbs:
Goffi <goffi@goffi.org>
parents: 1349
diff changeset
39
1290
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
40 async def prepare_render(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
41 data = self.get_r_data(request)
1326
089742e065e3 pages (files/list, photos/album): updated thumbnails size limits
Goffi <goffi@goffi.org>
parents: 1325
diff changeset
42 thumb_limit = data.get("thumb_limit", 400)
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 template_data = request.template_data
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
44 service, path_elts = data["service"], data["path"]
1313
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
45 path = Path('/', *path_elts)
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
46 profile = self.get_profile(request) or C.SERVICE_PROFILE
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
47 session_data = self.host.get_session_data(
1506
ce879da7fcf7 server: fix `on_signal` callback
Goffi <goffi@goffi.org>
parents: 1421
diff changeset
48 request, session_iface.IWebSession
1316
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
49 )
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50
1290
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
51 try:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
52 files_data = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
53 "fis_list", service.full(), str(path), {}, profile)
1290
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
54 except BridgeException as e:
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
55 if e.condition == 'item-not-found':
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
56 log.debug(
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
57 f'"item-not-found" received for {path} at {service}, this may indicate '
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
58 f'that the location is new')
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
59 files_data = []
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
60 else:
ee984eefc787 pages (files/list): return empty list of files when `item-not-found` is received
Goffi <goffi@goffi.org>
parents: 1289
diff changeset
61 raise e
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 for file_data in files_data:
1067
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
63 try:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
64 extra_raw = file_data["extra"]
1067
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
65 except KeyError:
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
66 pass
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
67 else:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
68 file_data["extra"] = json.loads(extra_raw) if extra_raw else {}
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
69 dir_path = path_elts + [file_data["name"]]
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
70 if file_data["type"] == C.FILE_TYPE_DIRECTORY:
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 page = self
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
72 elif file_data["type"] == C.FILE_TYPE_FILE:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
73 page = self.get_page_by_name("files_view")
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
74
1325
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
75 # we set URL for the last thumbnail which has a size below thumb_limit
1067
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
76 try:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
77 thumbnails = file_data["extra"]["thumbnails"]
1067
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
78 thumb = thumbnails[0]
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
79 for thumb_data in thumbnails:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
80 if thumb_data["size"][0] > thumb_limit:
1067
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
81 break
808ec98de8b3 pages (files/list): retrieve thumbnail:
Goffi <goffi@goffi.org>
parents: 1064
diff changeset
82 thumb = thumb_data
1325
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
83 file_data["thumb_url"] = (
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
84 thumb.get("url")
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
85 or os.path.join(session_data.cache_dir, thumb["filename"])
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
86 )
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
87 except (KeyError, IndexError):
009542289bc9 pages (files/list): removed/updated code to download thumbnails and sort them as it is now done by the backend
Goffi <goffi@goffi.org>
parents: 1316
diff changeset
88 pass
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 else:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
90 raise ValueError(
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
91 "unexpected file type: {file_type}".format(file_type=file_data["type"])
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
92 )
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
93 file_data["url"] = page.get_url(service.full(), *dir_path)
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
94
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
95 ## comments ##
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
96 comments_url = file_data.get("comments_url")
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
97 if comments_url:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
98 parsed_url = uri.parse_xmpp_uri(comments_url)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
99 comments_service = file_data["comments_service"] = parsed_url["path"]
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
100 comments_node = file_data["comments_node"] = parsed_url["node"]
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
101 try:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
102 comments_count = file_data["comments_count"] = int(
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
103 file_data["comments_count"]
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
104 )
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
105 except KeyError:
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
106 comments_count = None
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
107 if comments_count and data.get("retrieve_comments", False):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
108 file_data["comments"] = await pages_tools.retrieve_comments(
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
109 self, comments_service, comments_node, profile=profile
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1069
diff changeset
110 )
1069
2dab7692eae7 pages (files/list): comments handling + size parameters:
Goffi <goffi@goffi.org>
parents: 1067
diff changeset
111
1313
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
112 # parent dir affiliation
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
113 # TODO: some caching? What if affiliation changes?
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
114
1349
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
115 try:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
116 affiliations = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
117 "fis_affiliations_get", service.full(), "", str(path), profile
1349
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
118 )
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
119 except BridgeException as e:
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
120 if e.condition == 'item-not-found':
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
121 log.debug(
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
122 f'"item-not-found" received for {path} at {service}, this may indicate '
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
123 f'that the location is new')
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
124 # FIXME: Q&D handling of empty dir (e.g. new directory/photos album)
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
125 affiliations = {
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
126 session_data.jid.userhost(): "owner"
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
127 }
1421
e065c8886b81 pages (files/list): set empty affiliations when they can't be retrieved
Goffi <goffi@goffi.org>
parents: 1419
diff changeset
128 if e.condition == "service-unavailable":
e065c8886b81 pages (files/list): set empty affiliations when they can't be retrieved
Goffi <goffi@goffi.org>
parents: 1419
diff changeset
129 affiliations = {}
1349
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
130 else:
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
131 raise e
886d1856e9de pages (files/list): fixed empty dir handling
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
132
1316
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
133 directory_affiliation = affiliations.get(session_data.jid.userhost())
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
134 if directory_affiliation == "owner":
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
135 # we need to transtype dict items to str because with some bridges (D-Bus)
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
136 # we have a specific type which can't be exposed
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
137 self.expose_to_scripts(
1316
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
138 request,
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
139 affiliations={str(e): str(a) for e, a in affiliations.items()}
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
140 )
1313
12aa95eeb409 pages (files/list): set `directory_affiliation` template data:
Goffi <goffi@goffi.org>
parents: 1290
diff changeset
141
1316
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
142 template_data["directory_affiliation"] = directory_affiliation
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
143 template_data["files_data"] = files_data
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
144 template_data["path"] = path
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
145 self.expose_to_scripts(
1316
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
146 request,
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
147 directory_affiliation=str(directory_affiliation),
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
148 files_service=service.full(),
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
149 files_path=str(path),
d0575e9abf7d pages (files/list): use new `FISAffiliationsGet` to get `directory_affiliation`
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
150 )
1064
abc5d545dbaa pages (files): files sharing first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 if path_elts:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1506
diff changeset
152 template_data["parent_url"] = self.get_url(service.full(), *path_elts[:-1])