comparison libervia/web/pages/events/new/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/new/page_meta.py@106bae41f5c8
children b695b98851fc
comparison
equal deleted inserted replaced
1517:b8ed9726525b 1518:eb00d593801d
1 #!/usr/bin/env python3
2
3
4 from libervia.web.server.constants import Const as C
5 from twisted.internet import defer
6 from libervia.backend.core.log import getLogger
7 from libervia.backend.tools.common import date_utils
8
9 """creation of new events"""
10
11 name = "event_new"
12 access = C.PAGES_ACCESS_PROFILE
13 template = "event/create.html"
14 log = getLogger(__name__)
15
16
17 @defer.inlineCallbacks
18 def on_data_post(self, request):
19 request_data = self.get_r_data(request)
20 profile = self.get_profile(request)
21 title, location, body, date, main_img, bg_img = self.get_posted_data(
22 request, ("name", "location", "body", "date", "main_image", "bg_image")
23 )
24 timestamp = date_utils.date_parse(date)
25 data = {"name": title, "description": body, "location": location}
26
27 for value, var in ((main_img, "image"), (bg_img, "background-image")):
28 value = value.strip()
29 if not value:
30 continue
31 if not value.startswith("http"):
32 self.page_error(request, C.HTTP_BAD_REQUEST)
33 data[var] = value
34 data["register"] = C.BOOL_TRUE
35 node = yield self.host.bridge_call("event_create", timestamp, data, "", "", "", profile)
36 log.info("Event node created at {node}".format(node=node))
37
38 request_data["post_redirect_page"] = (self.get_page_by_name("event_admin"), "@", node)
39 defer.returnValue(C.POST_NO_CONFIRM)