Projet

Général

Profil

0001-workflows-add-custom-graph-transition-message-for-ws.patch

Frédéric Péters, 03 novembre 2015 15:00

Télécharger (3,05 ko)

Voir les différences:

Subject: [PATCH] workflows: add custom graph transition message for wscall
 error jumps (#8846)

 wcs/admin/workflows.py | 14 +++++++-------
 wcs/wf/wscall.py       |  3 +++
 wcs/workflows.py       | 11 +++++++++++
 3 files changed, 21 insertions(+), 7 deletions(-)
wcs/admin/workflows.py
151 151
            next_status_ids = [x.id for x in item.get_target_status() if x.id != status.id]
152 152
            if not next_status_ids:
153 153
                next_status_ids = [status.id]
154
            done = {}
154 155
            for next_id in next_status_ids:
156
                if next_id in done:
157
                    # don't display multiple arrows for same action and target
158
                    # status
159
                    continue
155 160
                print >>out, 'status%s -> status%s' % (i, next_id)
161
                done[next_id] = True
156 162
            url = 'status/%s/items/%s/' % (i, item.id)
157
            if getattr(item, 'label', None):
158
                label = item.label
159
                if getattr(item, 'by', None):
160
                    roles = workflow.render_list_of_roles(item.by)
161
                    label += ' %s %s' % (_('by'), roles)
162
            else:
163
                label = item.render_as_line()
163
            label = item.get_jump_label()
164 164
            label = label.replace('"', '\\"')
165 165
            label = label.decode('utf8')
166 166
            label = textwrap.fill(label, 20, break_long_words=False)
wcs/wf/wscall.py
228 228
            targets.append(self.parent.parent.get_status(value))
229 229
        return targets
230 230

  
231
    def get_jump_label(self):
232
        return _('Error calling webservice')
233

  
231 234
    def post_data_export_to_xml(self, xml_item, charset, include_id=False):
232 235
        if not self.post_data:
233 236
            return
wcs/workflows.py
851 851
        """Returns a list of status this item can lead to."""
852 852
        return []
853 853

  
854
    def get_jump_label(self):
855
        '''Return the label to use on a workflow graph arrow'''
856
        if getattr(self, 'label', None):
857
            label = self.label
858
            if getattr(self, 'by', None):
859
                roles = self.parent.parent.render_list_of_roles(self.by)
860
                label += ' %s %s' % (_('by'), roles)
861
        else:
862
            label = self.render_as_line()
863
        return label
864

  
854 865
    def export_to_xml(self, charset, include_id=False):
855 866
        item = ET.Element('item')
856 867
        item.attrib['type'] = self.key
857
-