Mercurial > libervia-web
changeset 981:97cce8c1e96a
pages(tickets): better URL handling:
- do no accept anymore URL without service or node
- use new getSubPageURL for tickets_new and individual ticket viewing URLs
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 14 Nov 2017 08:37:48 +0100 |
parents | bcacf970f970 |
children | a78169c1bf77 |
files | src/pages/tickets/page_meta.py src/pages/tickets/view/page_meta.py |
diffstat | 2 files changed, 12 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pages/tickets/page_meta.py Tue Nov 14 08:35:17 2017 +0100 +++ b/src/pages/tickets/page_meta.py Tue Nov 14 08:37:48 2017 +0100 @@ -17,13 +17,16 @@ def parse_url(self, request): + # check the service and node to use try: service = self.nextPath(request) + node = self.nextPath(request) except IndexError: + log.warning(_(u"missing service and node")) + self.pageError(request, C.HTTP_BAD_REQUEST) + + if not service or service == u'@': service = u'' - else: - if not service or service == u'@': - service = u'' if service: try: @@ -32,13 +35,8 @@ log.warning(_(u"bad service entered: {}").format(service)) self.pageError(request, C.HTTP_BAD_REQUEST) - try: - node = self.nextPath(request) - except IndexError: + if not node or node == u'@': node = u'' - else: - if not node or node == u'@': - node = u'' data = self.getRData(request) data['service'] = service @@ -46,16 +44,15 @@ template_data = request.template_data template_data[u'url_tickets_list'] = self.getPageByName('tickets_list').getURL(service.full(), node or u'@') - template_data[u'url_tickets_new'] = u'/' + ('/'.join(request.prepath + ['new']).decode('utf-8')) + template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'tickets_new') @defer.inlineCallbacks def prepare_render(self, request): data = self.getRData(request) template_data = request.template_data - service, node = data.get(u'service', u''), data.get(u'node', u'') + service, node = data[u'service'], data[u'node'] profile = self.getProfile(request) or C.SERVICE_PROFILE tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile) - tickets = [template_xmlui.create(self.host, x) for x in tickets[0]] - template_data[u'tickets'] = tickets - template_data[u'on_ticket_click'] = data_objects.OnClick(url="view/{item.id}") + template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in tickets[0]] + template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, 'tickets_view', '{item.id}'))
--- a/src/pages/tickets/view/page_meta.py Tue Nov 14 08:35:17 2017 +0100 +++ b/src/pages/tickets/view/page_meta.py Tue Nov 14 08:37:48 2017 +0100 @@ -11,6 +11,7 @@ log = getLogger('pages/tickets/view') """ticket handling pages""" +name = u"tickets_view" access = C.PAGES_ACCESS_PUBLIC template = u"ticket/item.html"