annotate src/pages/tickets/new/page_meta.py @ 968:4d37b23777c3

pages (core, tickets/new): replaced post_redirect_uri mechanism by post_redirect_page: instead of giving a full uri, a page is now given when we want to redirect to something else that current page on data post. This make the redirection more simple and intuive A tuple can be used to specify arguments to put in URL.
author Goffi <goffi@goffi.org>
date Thu, 09 Nov 2017 08:02:47 +0100
parents 4d1dcf97740f
children 8943ee1cf3d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from twisted.internet import defer
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from sat.tools.common import template_xmlui
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from sat.core.log import getLogger
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 log = getLogger('pages/ticket')
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 """ticket handling pages"""
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 access = C.PAGES_ACCESS_PROFILE
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 template = u"ticket/create.html"
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 @defer.inlineCallbacks
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 def prepare_render(self, request):
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 data = self.getRData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 service, node = data.get(u'service', u''), data.get(u'node', u'')
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 profile = self.getProfile(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 schema = yield self.host.bridge.ticketsSchemaGet(service.full(), node, profile)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 data['schema'] = schema
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 # following fields are handled in backend
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 ignore = ('reporter', 'created', 'updated', 'comments_uri')
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 request.template_data[u'new_ticket_xmlui'] = xmlui_obj
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 @defer.inlineCallbacks
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 def on_data_post(self, request):
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 data = self.getRData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 service = data['service']
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 node = data['node']
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 posted_data = self.getAllPostedData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 profile = self.getProfile(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 yield self.host.bridge.ticketsSet(service.full(), node, posted_data, u'', u'', {}, profile)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 # we don't want to redirect to creation page on success, but to tickets list
968
4d37b23777c3 pages (core, tickets/new): replaced post_redirect_uri mechanism by post_redirect_page:
Goffi <goffi@goffi.org>
parents: 967
diff changeset
36 data['post_redirect_page'] = (self.getPageByName(u'tickets_list'),
4d37b23777c3 pages (core, tickets/new): replaced post_redirect_uri mechanism by post_redirect_page:
Goffi <goffi@goffi.org>
parents: 967
diff changeset
37 service.full(),
4d37b23777c3 pages (core, tickets/new): replaced post_redirect_uri mechanism by post_redirect_page:
Goffi <goffi@goffi.org>
parents: 967
diff changeset
38 node or u'@')