diff libervia/pages/tickets/edit/page_meta.py @ 1216:b2d067339de3

python 3 port: /!\ Python 3.6+ is now needed to use libervia /!\ instability may occur and features may not be working anymore, this will improve with time /!\ TxJSONRPC dependency has been removed The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog, JSON RPC related code). Adapted code to work without `html` and `themes` dirs.
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:12:31 +0200
parents 5e67c2564779
children f511f8fbbf8a
line wrap: on
line diff
--- a/libervia/pages/tickets/edit/page_meta.py	Tue Aug 13 09:39:33 2019 +0200
+++ b/libervia/pages/tickets/edit/page_meta.py	Tue Aug 13 19:12:31 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 from libervia.server.constants import Const as C
@@ -11,20 +11,20 @@
 log = getLogger(__name__)
 """ticket handling pages"""
 
-name = u"tickets_edit"
+name = "tickets_edit"
 access = C.PAGES_ACCESS_PROFILE
-template = u"ticket/edit.html"
+template = "ticket/edit.html"
 
 
 def parse_url(self, request):
     try:
         item_id = self.nextPath(request)
     except IndexError:
-        log.warning(_(u"no ticket id specified"))
+        log.warning(_("no ticket id specified"))
         self.pageError(request, C.HTTP_BAD_REQUEST)
 
     data = self.getRData(request)
-    data[u"ticket_id"] = item_id
+    data["ticket_id"] = item_id
 
 
 @defer.inlineCallbacks
@@ -32,9 +32,9 @@
     data = self.getRData(request)
     template_data = request.template_data
     service, node, ticket_id = (
-        data.get(u"service", u""),
-        data.get(u"node", u""),
-        data[u"ticket_id"],
+        data.get("service", ""),
+        data.get("node", ""),
+        data["ticket_id"],
     )
     profile = self.getProfile(request)
 
@@ -51,7 +51,7 @@
     )
     tickets = yield self.host.bridgeCall(
         "ticketsGet",
-        service.full() if service else u"",
+        service.full() if service else "",
         node,
         C.NO_LIMIT,
         [ticket_id],
@@ -63,23 +63,23 @@
 
     try:
         # small trick to get a one line text input instead of the big textarea
-        ticket.widgets[u"labels"].type = u"string"
-        ticket.widgets[u"labels"].value = ticket.widgets[u"labels"].value.replace(
-            u"\n", ", "
+        ticket.widgets["labels"].type = "string"
+        ticket.widgets["labels"].value = ticket.widgets["labels"].value.replace(
+            "\n", ", "
         )
     except KeyError:
         pass
 
     # for now we don't have XHTML editor, so we'll go with a TextBox and a convertion
     # to a text friendly syntax using markdown
-    wid = ticket.widgets[u'body']
-    if wid.type == u"xhtmlbox":
-        wid.type = u"textbox"
+    wid = ticket.widgets['body']
+    if wid.type == "xhtmlbox":
+        wid.type = "textbox"
         wid.value =  yield self.host.bridgeCall(
-            u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown",
+            "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
             False, profile)
 
-    template_data[u"new_ticket_xmlui"] = ticket
+    template_data["new_ticket_xmlui"] = ticket
 
 
 @defer.inlineCallbacks
@@ -99,19 +99,19 @@
 
     # we convert back body to XHTML
     body = yield self.host.bridgeCall(
-        u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML,
+        "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
         False, profile)
-    posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
+    posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
                                                                      body=body)]
 
-    extra = {u'update': True}
+    extra = {'update': True}
     yield self.host.bridgeCall(
-        "ticketSet", service.full(), node, posted_data, u"", ticket_id,
+        "ticketSet", service.full(), node, posted_data, "", ticket_id,
         data_format.serialise(extra), profile
     )
     # we don't want to redirect to edit page on success, but to tickets list
     data["post_redirect_page"] = (
-        self.getPageByName(u"tickets"),
+        self.getPageByName("tickets"),
         service.full(),
-        node or u"@",
+        node or "@",
     )