comparison src/pages/events/new/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.log import getLogger
7 from sat.tools.common import date_utils
8 """creation of new events"""
9
10 name = u'event_new'
11 access = C.PAGES_ACCESS_PROFILE
12 template = u"event/create.html"
13 log = getLogger(u'pages/' + name)
14
15 @defer.inlineCallbacks
16 def on_data_post(self, request):
17 request_data = self.getRData(request)
18 profile = self.getProfile(request)
19 title, location, body, date, main_img, bg_img = self.getPostedData(
20 request, ('name', 'location', 'body', 'date', 'main_image', 'bg_image'))
21 timestamp = date_utils.date_parse(date)
22 data = {'name': title,
23 'description': body,
24 'location': location,
25 }
26
27 for value, var in ((main_img, 'image'),
28 (bg_img, 'background-image')):
29 value = value.strip()
30 if not value:
31 continue
32 if not value.startswith('http'):
33 self.pageError(request, C.HTTP_BAD_REQUEST)
34 data[var] = value
35 data[u'register'] = C.BOOL_TRUE
36 node = yield self.host.bridgeCall('eventCreate', timestamp, data, '', '', '', profile)
37 log.info(u"Event node created at {node}".format(node=node))
38
39 request_data['post_redirect_page'] = (self.getPageByName(u'event_admin'),
40 '@',
41 node)
42 defer.returnValue(C.POST_NO_CONFIRM)