toulouse-maelis : bouton pour demander une mise à jour des référentiels (#76424) #183

Merged
fpeters merged 2 commits from wip/76424-toulouse-maelis-update-referentials into main 2023-04-09 18:50:15 +02:00
6 changed files with 75 additions and 0 deletions

View File

@ -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()

View File

@ -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 %}

View File

@ -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',
),
]

View File

@ -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')
Review

J'ai hésité à utiliser django.contrib.messages pour dire que la mise à jour se faisait en arrière-plan, finalement j'ai opté pour plutôt afficher la page ouverte sur l'onglet des jobs.

J'ai hésité à utiliser django.contrib.messages pour dire que la mise à jour se faisait en arrière-plan, finalement j'ai opté pour plutôt afficher la page ouverte sur l'onglet des jobs.

View File

@ -151,6 +151,7 @@ li.connector.okina a::before {
}
li.connector.fakefamily a::before,
li.connector.toulousemaelis a::before,
Review

Commit bonus pour avoir une icône "famille" dans la liste des connecteurs.

Commit bonus pour avoir une icône "famille" dans la liste des connecteurs.
li.connector.genericfamily a::before,
li.connector.teamnetaxel a::before {
content: "\f0c0"; /* users */

View File

@ -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