Projet

Général

Profil

0001-workflows-add-redirect-to-url-action-11245.patch

Thomas Noël, 23 janvier 2017 17:20

Télécharger (2,8 ko)

Voir les différences:

Subject: [PATCH] workflows: add redirect to url action (#11245)

 wcs/wf/redirect_to_url.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++
 wcs/workflows.py          |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 wcs/wf/redirect_to_url.py
wcs/wf/redirect_to_url.py
1
# w.c.s. - web application for online forms
2
# Copyright (C) 2005-2017  Entr'ouvert
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, see <http://www.gnu.org/licenses/>.
16

  
17
from qommon.form import *
18
from wcs.workflows import (WorkflowStatusItem, register_item_class)
19

  
20

  
21
class RedirectToUrlStatusItem(WorkflowStatusItem):
22
    description = N_('Redirect to URL')
23
    key = 'redirect_to_url'
24
    endpoint = False
25
    waitpoint = True
26
    ok_in_global_action = False
27

  
28
    url = None
29

  
30
    def render_as_line(self):
31
        if self.url:
32
            return _('Redirect to "%s"') % self.url
33
        else:
34
            return _('Redirect to (not configured)')
35

  
36
    def get_parameters(self):
37
        return ('url',)
38

  
39
    def add_parameters_widgets(self, form, parameters, prefix='', formdef=None):
40
        if 'url' in parameters:
41
            form.add(StringWidget, '%surl' % prefix,
42
                     title=_('URL'), value=self.url, size=100,
43
                     hint=_('Common substitution variables are available with the [variable] syntax.'))
44

  
45
    def perform(self, formdata):
46
        if not self.url:
47
            # misconfigured action
48
            return
49
        url = self.compute(self.url)
50
        if not self.url:
51
            # misconfigured action
52
            return
53
        return url
54

  
55
register_item_class(RedirectToUrlStatusItem)
wcs/workflows.py
2388 2388
    import wf.criticality
2389 2389
    import wf.profile
2390 2390
    import wf.backoffice_fields
2391
    import wf.redirect_to_url
2391 2392

  
2392 2393
from wf.export_to_model import ExportToModel
2393
-