Mercurial > libervia-web
comparison libervia/web/pages/events/page_meta.py @ 1518:eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 16:49:28 +0200 |
parents | libervia/pages/events/page_meta.py@106bae41f5c8 |
children | 1d464c72ac12 |
comparison
equal
deleted
inserted
replaced
1517:b8ed9726525b | 1518:eb00d593801d |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 | |
4 from libervia.backend.core.i18n import _ | |
5 from libervia.backend.core.log import getLogger | |
6 from libervia.backend.tools.common import data_format | |
7 from twisted.internet import defer | |
8 | |
9 from libervia.web.server.constants import Const as C | |
10 | |
11 log = getLogger(__name__) | |
12 | |
13 | |
14 name = "events" | |
15 access = C.PAGES_ACCESS_PUBLIC | |
16 template = "event/overview.html" | |
17 | |
18 | |
19 async def prepare_render(self, request): | |
20 profile = self.get_profile(request) | |
21 template_data = request.template_data | |
22 template_data["url_event_new"] = self.get_sub_page_url(request, "event_new") | |
23 if profile is not None: | |
24 try: | |
25 events = data_format.deserialise( | |
26 await self.host.bridge_call("events_get", "", "", [], "", profile), | |
27 type_check=list | |
28 ) | |
29 except Exception as e: | |
30 log.warning(_("Can't get events list for {profile}: {reason}").format( | |
31 profile=profile, reason=e)) | |
32 else: | |
33 own_events = [] | |
34 other_events = [] | |
35 for event in events: | |
36 if C.bool(event.get("creator", C.BOOL_FALSE)): | |
37 own_events.append(event) | |
38 event["url"] = self.get_sub_page_url( | |
39 request, | |
40 "event_admin", | |
41 ) | |
42 else: | |
43 other_events.append(event) | |
44 event["url"] = self.get_sub_page_url( | |
45 request, | |
46 "event_rsvp", | |
47 ) | |
48 if "thumb_url" not in event and "image" in event: | |
49 event["thumb_url"] = event["image"] | |
50 | |
51 template_data["events"] = own_events + other_events |