Mercurial > libervia-web
comparison src/pages/tickets/new/page_meta.py @ 967:4d1dcf97740f
pages (tickets): tickets first draft:
following pages are available:
tickets/[service]/[node]: display list of all tickets ([node] can be "@" for default node)
.../new: create a ticket
.../view: view a single ticket and its comments, and allow to publish a new comment if use is logged in.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Nov 2017 22:11:23 +0100 |
parents | |
children | 4d37b23777c3 |
comparison
equal
deleted
inserted
replaced
966:12c149171199 | 967:4d1dcf97740f |
---|---|
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 import urllib | |
10 """ticket handling pages""" | |
11 | |
12 access = C.PAGES_ACCESS_PROFILE | |
13 template = u"ticket/create.html" | |
14 | |
15 | |
16 @defer.inlineCallbacks | |
17 def prepare_render(self, request): | |
18 data = self.getRData(request) | |
19 service, node = data.get(u'service', u''), data.get(u'node', u'') | |
20 profile = self.getProfile(request) | |
21 schema = yield self.host.bridge.ticketsSchemaGet(service.full(), node, profile) | |
22 data['schema'] = schema | |
23 # following fields are handled in backend | |
24 ignore = ('reporter', 'created', 'updated', 'comments_uri') | |
25 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) | |
26 request.template_data[u'new_ticket_xmlui'] = xmlui_obj | |
27 | |
28 @defer.inlineCallbacks | |
29 def on_data_post(self, request): | |
30 data = self.getRData(request) | |
31 service = data['service'] | |
32 node = data['node'] | |
33 posted_data = self.getAllPostedData(request) | |
34 profile = self.getProfile(request) | |
35 yield self.host.bridge.ticketsSet(service.full(), node, posted_data, u'', u'', {}, profile) | |
36 # we don't want to redirect to creation page on success, but to tickets list | |
37 data['post_redirect_uri'] = u'{list_url}/{service}/{node}'.format( | |
38 service = urllib.quote_plus(service.full().encode('utf-8')), | |
39 node = urllib.quote_plus(node.encode('utf-8')) if node else u'@', | |
40 list_url = self.getPageByName(u'tickets_list').url) |