From ec2baaaf84bb619a5d63746b17d94eca619c171a Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Mon, 30 Sep 2019 17:01:31 +0200 Subject: [PATCH] Redirecting to mapping-edition when creating a new data source with a file --- .../viralhostrangedb/tests/test_views.py | 2 +- src/viralhostrange/viralhostrangedb/views.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/viralhostrange/viralhostrangedb/tests/test_views.py b/src/viralhostrange/viralhostrangedb/tests/test_views.py index 8496a6b3..91b15fb2 100644 --- a/src/viralhostrange/viralhostrangedb/tests/test_views.py +++ b/src/viralhostrange/viralhostrangedb/tests/test_views.py @@ -821,7 +821,7 @@ class DataSourceCreateViewTestCase(ViewTestCase): self.assertRedirects( response_4, - expected_url=reverse('viralhostrangedb:data-source-detail', args=[new_pk]) + expected_url=reverse('viralhostrangedb:data-source-mapping-edit', args=[new_pk]) ) def test_creation_with_a_live(self): diff --git a/src/viralhostrange/viralhostrangedb/views.py b/src/viralhostrange/viralhostrangedb/views.py index fefca372..98793b3e 100644 --- a/src/viralhostrange/viralhostrangedb/views.py +++ b/src/viralhostrange/viralhostrangedb/views.py @@ -1015,6 +1015,21 @@ class DataSourceWizard(wizard_views.NamedUrlSessionWizardView): form_dict["Information"].save() if self.upload_data(): form_dict["Upload"].save(importation_observer=MessageImportationObserver(request=self.request)) + + url = reverse("viralhostrangedb:data-source-mapping-edit", args=[self.instance.pk]) + messages.success( + request=self.request, + message=mark_safe(_( + """Successfully imported data source """ + """<a href="%(url_data_source_name)s" target="_blank"><b>%(data_source_name)s</b></a>.""" + """Redirecting to <a href="%(url)s">%(url)s</a> to map the responses to the global scheme.""" + ) % dict( + data_source_name=self.instance.name, + url_data_source_name=self.instance.get_absolute_url(), + url=url, + )), + ) + return HttpResponseRedirect(url) else: self.instance.save() form_dict["LiveInput"].save(data_source=self.instance) -- GitLab