annotate src/pages/tickets/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 2e75dc986e03
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 sat.core.i18n import _
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from twisted.internet import defer
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from twisted.words.protocols.jabber import jid
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from sat.tools.common import template_xmlui
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 from sat.tools.common import data_objects
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 from sat.core.log import getLogger
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 log = getLogger('pages/ticket')
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 """ticket handling pages"""
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 name = u'tickets_list'
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 access = C.PAGES_ACCESS_PUBLIC
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 template = u"ticket/overview.html"
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 trailing_slash = True
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 def parse_url(self, request):
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 try:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 service = self.nextPath(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 except IndexError:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 service = u''
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 else:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 if not service or service == u'@':
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 service = u''
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 if service:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 try:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 service = jid.JID(service)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 except Exception:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 log.warning(_(u"bad service entered: {}").format(service))
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 self.pageError(request, C.HTTP_BAD_REQUEST)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 try:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 node = self.nextPath(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 except IndexError:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 node = u''
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 else:
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 if not node or node == u'@':
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 node = u''
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 data = self.getRData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 data['service'] = service
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 data['node'] = node
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 @defer.inlineCallbacks
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 def prepare_render(self, request):
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 data = self.getRData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 template_data = request.template_data
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 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
55 profile = self.getProfile(request) or C.SERVICE_PROFILE
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 tickets = [template_xmlui.create(self.host, x) for x in tickets[0]]
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 template_data[u'tickets'] = tickets
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 template_data[u'on_ticket_click'] = data_objects.OnClick(url="view/{item.id}")