# HG changeset patch # User Goffi # Date 1527848483 -7200 # Node ID 5d4ac5415b40467739577bb90bdda8df8dc26ded # Parent 41db2f58c7538c12480b49b810a2aee5eb62d89a plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters. diff -r 41db2f58c753 -r 5d4ac5415b40 sat/plugins/plugin_exp_pubsub_schema.py --- 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, diff -r 41db2f58c753 -r 5d4ac5415b40 sat/plugins/plugin_misc_merge_requests.py --- a/sat/plugins/plugin_misc_merge_requests.py Fri Jun 01 12:17:06 2018 +0200 +++ b/sat/plugins/plugin_misc_merge_requests.py Fri Jun 01 12:21:23 2018 +0200 @@ -156,6 +156,14 @@ """ if not node: node = NS_MERGE_REQUESTS + 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 = {u'labels': self._s.textbox2ListFilter} + else: + filters = {} tickets_xmlui, metadata = yield self._s.getDataFormItems( client, service, @@ -166,7 +174,7 @@ rsm_request=rsm_request, extra=extra, form_ns=NS_MERGE_REQUESTS, - filters = {u'labels': self._s.textbox2ListFilter}) + filters = filters) parsed_patches = [] if extra.get('parse', False): for ticket in tickets_xmlui: diff -r 41db2f58c753 -r 5d4ac5415b40 sat/plugins/plugin_misc_tickets.py --- a/sat/plugins/plugin_misc_tickets.py Fri Jun 01 12:17:06 2018 +0200 +++ b/sat/plugins/plugin_misc_tickets.py Fri Jun 01 12:21:23 2018 +0200 @@ -56,7 +56,6 @@ default_node=NS_TICKETS, form_ns=NS_TICKETS, filters = {u'author': self._s.valueOrPublisherFilter, - u'labels': self._s.textbox2ListFilter, u'created': self._s.dateFilter, u'updated': self._s.dateFilter, }),