Mercurial > libervia-web
comparison libervia/pages/events/page_meta.py @ 1216:b2d067339de3
python 3 port:
/!\ Python 3.6+ is now needed to use libervia
/!\ instability may occur and features may not be working anymore, this will improve with time
/!\ TxJSONRPC dependency has been removed
The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs
for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog,
JSON RPC related code).
Adapted code to work without `html` and `themes` dirs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:12:31 +0200 |
parents | 92ca86e417e3 |
children | f511f8fbbf8a |
comparison
equal
deleted
inserted
replaced
1215:f14ab8a25e8b | 1216:b2d067339de3 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 from libervia.server.constants import Const as C | 4 from libervia.server.constants import Const as C |
5 from twisted.internet import defer | 5 from twisted.internet import defer |
6 from sat.core.i18n import _ | 6 from sat.core.i18n import _ |
7 from sat.core.log import getLogger | 7 from sat.core.log import getLogger |
8 | 8 |
9 log = getLogger(__name__) | 9 log = getLogger(__name__) |
10 """ticket handling pages""" | 10 """ticket handling pages""" |
11 | 11 |
12 name = u"events" | 12 name = "events" |
13 access = C.PAGES_ACCESS_PUBLIC | 13 access = C.PAGES_ACCESS_PUBLIC |
14 template = u"event/overview.html" | 14 template = "event/overview.html" |
15 | 15 |
16 | 16 |
17 @defer.inlineCallbacks | 17 @defer.inlineCallbacks |
18 def prepare_render(self, request): | 18 def prepare_render(self, request): |
19 profile = self.getProfile(request) | 19 profile = self.getProfile(request) |
20 template_data = request.template_data | 20 template_data = request.template_data |
21 template_data[u"url_event_new"] = self.getSubPageURL(request, "event_new") | 21 template_data["url_event_new"] = self.getSubPageURL(request, "event_new") |
22 if profile is not None: | 22 if profile is not None: |
23 try: | 23 try: |
24 events = yield self.host.bridgeCall("eventsList", "", "", profile) | 24 events = yield self.host.bridgeCall("eventsList", "", "", profile) |
25 except Exception as e: | 25 except Exception as e: |
26 log.warning(_(u"Can't get events list for {profile}: {reason}").format( | 26 log.warning(_("Can't get events list for {profile}: {reason}").format( |
27 profile=profile, reason=e)) | 27 profile=profile, reason=e)) |
28 else: | 28 else: |
29 own_events = [] | 29 own_events = [] |
30 other_events = [] | 30 other_events = [] |
31 for event in events: | 31 for event in events: |
32 if C.bool(event.get("creator", C.BOOL_FALSE)): | 32 if C.bool(event.get("creator", C.BOOL_FALSE)): |
33 own_events.append(event) | 33 own_events.append(event) |
34 event["url"] = self.getSubPageURL( | 34 event["url"] = self.getSubPageURL( |
35 request, | 35 request, |
36 u"event_admin", | 36 "event_admin", |
37 event.get("service", ""), | 37 event.get("service", ""), |
38 event.get("node", ""), | 38 event.get("node", ""), |
39 event.get("item"), | 39 event.get("item"), |
40 ) | 40 ) |
41 else: | 41 else: |
42 other_events.append(event) | 42 other_events.append(event) |
43 event["url"] = self.getSubPageURL( | 43 event["url"] = self.getSubPageURL( |
44 request, | 44 request, |
45 u"event_rsvp", | 45 "event_rsvp", |
46 event.get("service", ""), | 46 event.get("service", ""), |
47 event.get("node", ""), | 47 event.get("node", ""), |
48 event.get("item"), | 48 event.get("item"), |
49 ) | 49 ) |
50 if u"thumb_url" not in event and u"image" in event: | 50 if "thumb_url" not in event and "image" in event: |
51 event[u"thumb_url"] = event[u"image"] | 51 event["thumb_url"] = event["image"] |
52 | 52 |
53 template_data[u"events"] = own_events + other_events | 53 template_data["events"] = own_events + other_events |