From a6283990e809ce0afcf625489e355af712b0df88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org>
Date: Mon, 24 Jan 2022 07:41:48 +0100
Subject: [PATCH] Use autocomplete for Profile duplicates

---
 scipost_django/profiles/forms.py                     | 12 ++++++++++--
 .../templates/profiles/profile_duplicate_list.html   |  4 ++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/scipost_django/profiles/forms.py b/scipost_django/profiles/forms.py
index 7a84157db..9b26bebf9 100644
--- a/scipost_django/profiles/forms.py
+++ b/scipost_django/profiles/forms.py
@@ -92,8 +92,16 @@ class SimpleProfileForm(ProfileForm):
 
 
 class ProfileMergeForm(forms.Form):
-    to_merge = ModelChoiceFieldwithid(queryset=Profile.objects.all(), empty_label=None)
-    to_merge_into = ModelChoiceFieldwithid(queryset=Profile.objects.all(), empty_label=None)
+    to_merge = ModelChoiceFieldwithid(
+        queryset=Profile.objects.all(),
+        widget=autocomplete.ModelSelect2(url='/profiles/profile-autocomplete'),
+        empty_label=None
+    )
+    to_merge_into = ModelChoiceFieldwithid(
+        queryset=Profile.objects.all(),
+        widget=autocomplete.ModelSelect2(url='/profiles/profile-autocomplete'),
+        empty_label=None
+    )
 
     def clean(self):
         """
diff --git a/scipost_django/profiles/templates/profiles/profile_duplicate_list.html b/scipost_django/profiles/templates/profiles/profile_duplicate_list.html
index d3a30bbc7..74b93d467 100644
--- a/scipost_django/profiles/templates/profiles/profile_duplicate_list.html
+++ b/scipost_django/profiles/templates/profiles/profile_duplicate_list.html
@@ -42,3 +42,7 @@
   </div>
 
 {% endblock content %}
+
+{% block footer_script %}
+  {{ merge_form.media }}
+{% endblock footer_script %}
-- 
GitLab