Mercurial > libervia-web
annotate src/pages/tickets/new/page_meta.py @ 971:6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 09 Nov 2017 08:02:49 +0100 |
parents | bc28b9068f91 |
children | 2e75dc986e03 |
rev | line source |
---|---|
967 | 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.tools.common import template_xmlui | |
7 from sat.core.log import getLogger | |
8 log = getLogger('pages/ticket') | |
9 """ticket handling pages""" | |
10 | |
11 access = C.PAGES_ACCESS_PROFILE | |
12 template = u"ticket/create.html" | |
13 | |
14 | |
15 @defer.inlineCallbacks | |
16 def prepare_render(self, request): | |
17 data = self.getRData(request) | |
18 service, node = data.get(u'service', u''), data.get(u'node', u'') | |
19 profile = self.getProfile(request) | |
20 schema = yield self.host.bridge.ticketsSchemaGet(service.full(), node, profile) | |
21 data['schema'] = schema | |
22 # following fields are handled in backend | |
969
8943ee1cf3d7
page(tickets/new): ignore status as it makes sense to use default status on ticket creation
Goffi <goffi@goffi.org>
parents:
968
diff
changeset
|
23 ignore = ('reporter', 'created', 'updated', 'comments_uri', 'status') |
967 | 24 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
25 try: |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
26 # small trick to get a one line text input instead of the big textarea |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
27 xmlui_obj.widgets[u'labels'].type = u'string' |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
28 except KeyError: |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
29 pass |
967 | 30 request.template_data[u'new_ticket_xmlui'] = xmlui_obj |
31 | |
32 @defer.inlineCallbacks | |
33 def on_data_post(self, request): | |
34 data = self.getRData(request) | |
35 service = data['service'] | |
36 node = data['node'] | |
37 posted_data = self.getAllPostedData(request) | |
970
bc28b9068f91
page(tickets/new): refuse request if title is not set
Goffi <goffi@goffi.org>
parents:
969
diff
changeset
|
38 if not posted_data['title']: |
bc28b9068f91
page(tickets/new): refuse request if title is not set
Goffi <goffi@goffi.org>
parents:
969
diff
changeset
|
39 self.pageError(request, C.HTTP_BAD_REQUEST) |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
40 try: |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
41 posted_data['labels'] = [l.strip() for l in posted_data['labels'][0].split(',')] |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
42 except (KeyError, IndexError): |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
43 pass |
967 | 44 profile = self.getProfile(request) |
45 yield self.host.bridge.ticketsSet(service.full(), node, posted_data, u'', u'', {}, profile) | |
46 # 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
|
47 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
|
48 service.full(), |
4d37b23777c3
pages (core, tickets/new): replaced post_redirect_uri mechanism by post_redirect_page:
Goffi <goffi@goffi.org>
parents:
967
diff
changeset
|
49 node or u'@') |