Mercurial > libervia-web
annotate libervia/pages/events/page_meta.py @ 1313:12aa95eeb409
pages (files/list): set `directory_affiliation` template data:
Directory affiliation is checked by listing parent directory, then added to template_data
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 Aug 2020 16:47:24 +0200 |
parents | f511f8fbbf8a |
children | e3e303a30a74 |
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 |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 from libervia.server.constants import Const as C |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from twisted.internet import defer |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 from sat.core.i18n import _ |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 from sat.core.log import getLogger |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
8 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
9 log = getLogger(__name__) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 """ticket handling pages""" |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
1216 | 12 name = "events" |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 access = C.PAGES_ACCESS_PUBLIC |
1216 | 14 template = "event/overview.html" |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 @defer.inlineCallbacks |
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
|
18 def prepare_render(self, request): |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 profile = self.getProfile(request) |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 template_data = request.template_data |
1216 | 21 template_data["url_event_new"] = self.getSubPageURL(request, "event_new") |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 if profile is not None: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 try: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 events = yield self.host.bridgeCall("eventsList", "", "", profile) |
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
|
25 except Exception as e: |
1216 | 26 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
|
27 profile=profile, reason=e)) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 else: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 own_events = [] |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 other_events = [] |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 for event in events: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
32 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
|
33 own_events.append(event) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
34 event["url"] = self.getSubPageURL( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
35 request, |
1216 | 36 "event_admin", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
37 event.get("service", ""), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
38 event.get("node", ""), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
39 event.get("item"), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
40 ) |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 else: |
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 other_events.append(event) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
43 event["url"] = self.getSubPageURL( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
44 request, |
1216 | 45 "event_rsvp", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
46 event.get("service", ""), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
47 event.get("node", ""), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
48 event.get("item"), |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
49 ) |
1216 | 50 if "thumb_url" not in event and "image" in event: |
51 event["thumb_url"] = event["image"] | |
1111
4d1c4bd4931a
pages (events): added root, admin, new, rsvp and view pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
1216 | 53 template_data["events"] = own_events + other_events |