Mercurial > libervia-web
annotate libervia/web/pages/events/page_meta.py @ 1550:4b0464b2a12b
doc: add end-user A/V calls documentation:
rel 423
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 09 Aug 2023 00:22:18 +0200 |
parents | eb00d593801d |
children | 1d464c72ac12 |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
1518
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
4 from libervia.backend.core.i18n import _ |
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
5 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
|
6 from libervia.backend.tools.common import data_format |
1507
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
7 from twisted.internet import defer |
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
8 |
1518
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 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
10 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
11 log = getLogger(__name__) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
12 |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 |
1216 | 14 name = "events" |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 access = C.PAGES_ACCESS_PUBLIC |
1216 | 16 template = "event/overview.html" |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
1507
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
19 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:
1507
diff
changeset
|
20 profile = self.get_profile(request) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 template_data = request.template_data |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1507
diff
changeset
|
22 template_data["url_event_new"] = self.get_sub_page_url(request, "event_new") |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 if profile is not None: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 try: |
1507
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
25 events = data_format.deserialise( |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1507
diff
changeset
|
26 await self.host.bridge_call("events_get", "", "", [], "", profile), |
1507
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
27 type_check=list |
ae5158f3c420
pages (events): quick fix following changes in backend events
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
28 ) |
1178
92ca86e417e3
pages (events): moved get interests code in prepare_render + use image as thumb_url if it does not already exist
Goffi <goffi@goffi.org>
parents:
1145
diff
changeset
|
29 except Exception as e: |
1216 | 30 log.warning(_("Can't get events list for {profile}: {reason}").format( |
1178
92ca86e417e3
pages (events): moved get interests code in prepare_render + use image as thumb_url if it does not already exist
Goffi <goffi@goffi.org>
parents:
1145
diff
changeset
|
31 profile=profile, reason=e)) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 else: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 own_events = [] |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 other_events = [] |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 for event in events: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
36 if C.bool(event.get("creator", C.BOOL_FALSE)): |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 own_events.append(event) |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1507
diff
changeset
|
38 event["url"] = self.get_sub_page_url( |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
39 request, |
1216 | 40 "event_admin", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
41 ) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 else: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 other_events.append(event) |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1507
diff
changeset
|
44 event["url"] = self.get_sub_page_url( |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
45 request, |
1216 | 46 "event_rsvp", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
47 ) |
1216 | 48 if "thumb_url" not in event and "image" in event: |
49 event["thumb_url"] = event["image"] | |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
1216 | 51 template_data["events"] = own_events + other_events |