comparison libervia/pages/events/page_meta.py @ 1178:92ca86e417e3

pages (events): moved get interests code in prepare_render + use image as thumb_url if it does not already exist
author Goffi <goffi@goffi.org>
date Sat, 04 May 2019 00:01:08 +0200
parents 29eb15062416
children b2d067339de3
comparison
equal deleted inserted replaced
1177:75c5e8d21c7d 1178:92ca86e417e3
13 access = C.PAGES_ACCESS_PUBLIC 13 access = C.PAGES_ACCESS_PUBLIC
14 template = u"event/overview.html" 14 template = u"event/overview.html"
15 15
16 16
17 @defer.inlineCallbacks 17 @defer.inlineCallbacks
18 def parse_url(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[u"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: 25 except Exception as e:
26 log.warning(_(u"Can't get events list for {profile}").format(profile=profile)) 26 log.warning(_(u"Can't get events list for {profile}: {reason}").format(
27 profile=profile, reason=e))
27 else: 28 else:
28 own_events = [] 29 own_events = []
29 other_events = [] 30 other_events = []
30 for event in events: 31 for event in events:
31 if C.bool(event.get("creator", C.BOOL_FALSE)): 32 if C.bool(event.get("creator", C.BOOL_FALSE)):
44 u"event_rsvp", 45 u"event_rsvp",
45 event.get("service", ""), 46 event.get("service", ""),
46 event.get("node", ""), 47 event.get("node", ""),
47 event.get("item"), 48 event.get("item"),
48 ) 49 )
50 if u"thumb_url" not in event and u"image" in event:
51 event[u"thumb_url"] = event[u"image"]
49 52
50 template_data[u"events"] = own_events + other_events 53 template_data[u"events"] = own_events + other_events