diff sat/plugins/plugin_exp_pubsub_schema.py @ 2603:5d4ac5415b40

plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
author Goffi <goffi@goffi.org>
date Fri, 01 Jun 2018 12:21:23 +0200
parents 26edcf3a30eb
children 3e4e78de9cca
line wrap: on
line diff
--- a/sat/plugins/plugin_exp_pubsub_schema.py	Fri Jun 01 12:17:06 2018 +0200
+++ b/sat/plugins/plugin_exp_pubsub_schema.py	Fri Jun 01 12:21:23 2018 +0200
@@ -376,13 +376,25 @@
 
         return client, service, node, max_items, extra, sub_id
 
-    def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None, extra_dict=None, default_node=None, form_ns=None, filters=None, profile_key=C.PROF_KEY_NONE):
+    def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None, extra=None, default_node=None, form_ns=None, filters=None, profile_key=C.PROF_KEY_NONE):
         """Bridge method to retrieve data from node with schema
 
         this method is a helper so dependant plugins can use it directly
         when adding *Get methods
+        extra can have the key "labels_as_list" which is a hack to convert
+            labels from textbox to list in XMLUI, which usually render better
+            in final UI.
         """
-        client, service, node, max_items, extra, sub_id = self.prepareBridgeGet(service, node, max_items, sub_id, extra_dict, profile_key)
+        if filters is None:
+            filters = {}
+        if extra is None:
+            extra = {}
+        # XXX: Q&D way to get list for labels when displaying them, but text when we
+        #      have to modify them
+        if C.bool(extra.get('labels_as_list', C.BOOL_FALSE)):
+            filters = filters.copy()
+            filters[u'labels'] = self.textbox2ListFilter
+        client, service, node, max_items, extra, sub_id = self.prepareBridgeGet(service, node, max_items, sub_id, extra, profile_key)
         d = self.getDataFormItems(client, service, node or None,
             max_items=max_items,
             item_ids=item_ids,