Mercurial > libervia-web
view 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 |
line wrap: on
line source
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from libervia.server.constants import Const as C from twisted.internet import defer from sat.tools.common import template_xmlui from sat.core.log import getLogger log = getLogger('pages/ticket') import urllib """ticket handling pages""" access = C.PAGES_ACCESS_PROFILE template = u"ticket/create.html" @defer.inlineCallbacks def prepare_render(self, request): data = self.getRData(request) service, node = data.get(u'service', u''), data.get(u'node', u'') profile = self.getProfile(request) schema = yield self.host.bridge.ticketsSchemaGet(service.full(), node, profile) data['schema'] = schema # following fields are handled in backend ignore = ('reporter', 'created', 'updated', 'comments_uri') xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) request.template_data[u'new_ticket_xmlui'] = xmlui_obj @defer.inlineCallbacks def on_data_post(self, request): data = self.getRData(request) service = data['service'] node = data['node'] posted_data = self.getAllPostedData(request) profile = self.getProfile(request) yield self.host.bridge.ticketsSet(service.full(), node, posted_data, u'', u'', {}, profile) # we don't want to redirect to creation page on success, but to tickets list data['post_redirect_uri'] = u'{list_url}/{service}/{node}'.format( service = urllib.quote_plus(service.full().encode('utf-8')), node = urllib.quote_plus(node.encode('utf-8')) if node else u'@', list_url = self.getPageByName(u'tickets_list').url)