toulouse-maelis: add button to ask for a refresh of referentials (#76424)
gitea/passerelle/pipeline/head Build queued...
Details
gitea/passerelle/pipeline/head Build queued...
Details
This commit is contained in:
parent
cb8ee79420
commit
405c606a1d
|
@ -233,6 +233,9 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.update_referential('Regie', data, 'code', 'libelle')
|
||||
|
||||
def daily(self):
|
||||
self.update_referentials()
|
||||
|
||||
def update_referentials(self):
|
||||
try:
|
||||
self.update_family_referentials()
|
||||
self.update_site_referentials()
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{% extends "passerelle/manage/service_view.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block actions %}
|
||||
{% if perms.base.see_accessright %}
|
||||
<a href="{% url 'toulouse-maelis-update-referentials-view' connector='toulouse-maelis' connector_slug=object.slug %}">{% trans 'Update referentials' %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,27 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# Copyright (C) 2023 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.urls import re_path
|
||||
|
||||
from . import views
|
||||
|
||||
management_urlpatterns = [
|
||||
re_path(
|
||||
r'^(?P<connector_slug>[\w,-]+)/update-referentials/$',
|
||||
views.update_referentials,
|
||||
name='toulouse-maelis-update-referentials-view',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# Copyright (C) 2023 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.shortcuts import redirect
|
||||
|
||||
from .models import ToulouseMaelis
|
||||
|
||||
|
||||
def update_referentials(request, connector_slug, **kwargs):
|
||||
connector = ToulouseMaelis.objects.get(slug=connector_slug)
|
||||
connector.add_job('update_referentials')
|
||||
return redirect(connector.get_absolute_url() + '#open:jobs')
|
|
@ -313,6 +313,17 @@ def test_manager(admin_user, app, con):
|
|||
assert con.get_loisir_nature_codes() == []
|
||||
|
||||
|
||||
def test_manager_update_referentials(admin_user, app, con):
|
||||
app = login(app)
|
||||
path = '/%s/%s/' % (con.get_connector_slug(), con.slug)
|
||||
resp = app.get(path)
|
||||
resp = resp.click('Update referentials')
|
||||
resp = resp.follow()
|
||||
assert con.jobs_set().count() == 1
|
||||
job = con.jobs_set().first()
|
||||
assert job.method_name == 'update_referentials'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
def test_call_with_wrong_wsdl_url(mocked_get, con):
|
||||
mocked_get.side_effect = CONNECTION_ERROR
|
||||
|
|
Loading…
Reference in New Issue