Projet

Général

Profil

0001-workflows-send-notifications-to-interco-portal-41745.patch

Frédéric Péters, 31 octobre 2020 15:14

Télécharger (2,25 ko)

Voir les différences:

Subject: [PATCH] workflows: send notifications to interco portal (#41745)

 tests/test_workflows.py |  8 ++++++++
 wcs/wf/notification.py  | 11 +++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)
tests/test_workflows.py
4700 4700
    assert http_requests.count() == 1
4701 4701
    assert set(x['url'] for x in http_requests.requests) == set(['https://portal/api/notification/add/?NameID=xxy1'])
4702 4702

  
4703
    # check notifications are sent to interco portal if it exists
4704
    pub.site_options.set('variables', '_interco_portal_url', 'https://interco-portal/')
4705
    http_requests.empty()
4706
    item.perform(formdata)
4707
    assert http_requests.count() == 1
4708
    assert set(x['url'] for x in http_requests.requests) == set([
4709
        'https://interco-portal/api/notification/add/?NameID=xxy1'])
4710

  
4703 4711

  
4704 4712
def test_workflow_field_migration(pub):
4705 4713
    Workflow.wipe()
wcs/wf/notification.py
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import urllib.parse
18

  
17 19
from quixote import get_publisher
18 20

  
19 21
from ..qommon import _, N_, ezt
......
59 61

  
60 62
    @classmethod
61 63
    def get_api_url(cls):
62
        url = get_publisher().get_site_option('portal_url', 'variables')
63
        if not url:
64
            return None
65
        return url + 'api/notification/add/'
64
        for variable_name in ('_interco_portal_url', 'portal_url'):
65
            url = get_publisher().get_site_option(variable_name, 'variables')
66
            if url:
67
                return urllib.parse.urljoin(url, '/api/notification/add/')
68
        return None
66 69

  
67 70
    def get_jump_label(self, target_id):
68 71
        return _(self.description)
69
-