comparison src/pages/events/page_meta.py @ 1111:4d1c4bd4931a

pages (events): added root, admin, new, rsvp and view pages
author Goffi <goffi@goffi.org>
date Thu, 21 Jun 2018 01:19:57 +0200
parents
children cdd389ef97bc
comparison
equal deleted inserted replaced
1110:045e8bdaed4f 1111:4d1c4bd4931a
1 #!/usr/bin/env python2.7
2 # -*- coding: utf-8 -*-
3
4 from libervia.server.constants import Const as C
5 from twisted.internet import defer
6 from sat.core.i18n import _
7 from sat.core.log import getLogger
8 log = getLogger('pages/ticket')
9 """ticket handling pages"""
10
11 name = u'events'
12 access = C.PAGES_ACCESS_PUBLIC
13 template = u"event/overview.html"
14
15
16 @defer.inlineCallbacks
17 def parse_url(self, request):
18 profile = self.getProfile(request)
19 template_data = request.template_data
20 template_data[u'url_event_new'] = self.getSubPageURL(request, 'event_new')
21 if profile is not None:
22 try:
23 events = yield self.host.bridgeCall("eventsList", "", "", profile)
24 except Exception:
25 log.warning(_(u"Can't get events list for {profile}").format(profile=profile))
26 else:
27 own_events = []
28 other_events = []
29 for event in events:
30 if C.bool(event.get('creator', C.BOOL_FALSE)):
31 own_events.append(event)
32 event['url'] = self.getSubPageURL(request,
33 u'event_admin',
34 event.get('service',''),
35 event.get('node',''),
36 event.get('item'))
37 else:
38 other_events.append(event)
39 event['url'] = self.getSubPageURL(request,
40 u'event_rsvp',
41 event.get('service',''),
42 event.get('node',''),
43 event.get('item'))
44
45 template_data[u'events'] = own_events + other_events