From 00f155c41cdae3bedc635ea3fb00f834af7e8cdf Mon Sep 17 00:00:00 2001
From: dcz <dcz@ipipan.waw.pl>
Date: Fri, 14 Jul 2023 11:27:25 +0200
Subject: [PATCH] Unified frame creation external service

---
 .../components/unification/shared/LexicalUnitDisplay.vue  | 3 ++-
 shellvalier/settings.py                                   | 3 +++
 unifier/views.py                                          | 8 +++++---
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
index 518dbdc..ebac745 100644
--- a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
+++ b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
@@ -54,7 +54,8 @@ export default {
                 if (this.hasWhiteSpace(title) || title.length === 0) {
                   alert(gettext("Nazwa zunifikowanej ramy nie może być pusta oraz nie może zawierać białych znaków."));
                 } else {
-                  const data = {'lu_id': this.lexicalUnitId, 'unified_frame_title': title};
+                  const data = {'lu_id': this.lexicalUnitId, 'unified_frame_title': title,
+                      'frame_id': this.frame.id};
                   $.ajax({
                     type     : 'post',
                     url      : `/${lang}/unifier/frame_assign/`,
diff --git a/shellvalier/settings.py b/shellvalier/settings.py
index 2f4ba07..45be427 100644
--- a/shellvalier/settings.py
+++ b/shellvalier/settings.py
@@ -188,3 +188,6 @@ EMAIL_USE_SSL = get_environment('EMAIL_USE_SSL', mapper=boolean_mapper)
 SUPER_LEXICOGRAPHS_GROUP_NAME = 'Super Leksykografowie'
 
 DATE_INPUT_FORMATS = ['%d-%m-%Y']
+
+UNIFIED_FRAME_SERVICE_URL = get_environment('UNIFIED_FRAME_SERVICE_URL',
+                                            default="http://127.0.0.1:8000/en/unifier/build_unified_frame_xml/?lu_id=")
diff --git a/unifier/views.py b/unifier/views.py
index 00212f3..b91e59d 100644
--- a/unifier/views.py
+++ b/unifier/views.py
@@ -26,6 +26,7 @@ import io
 from xml.sax import handler, make_parser
 from django.db.models import Q
 
+from django.conf import settings
 
 @ajax_required
 @transaction.atomic
@@ -515,8 +516,8 @@ def change_unified_frame_status_to_verified_by_superleksykograf(request):
     return JsonResponse({})
 
 
-def create_unified_frame(lu_id):
-    response = requests.post('http://127.0.0.1:8000/en/unifier/build_unified_frame_xml/?lu_id=' + str(lu_id))
+def create_unified_frame(frame_id):
+    response = requests.post(settings.UNIFIED_FRAME_SERVICE_URL + str(frame_id), timeout=(1000, 1000))
 
     parser = make_parser()
     parser.setFeature(handler.feature_external_ges, False)
@@ -592,9 +593,10 @@ def frame_assign(request):
     if request.method == 'POST':
 
         lu_id = request.POST['lu_id']
+        frame_id = request.POST['frame_id']
         unified_frame_title = request.POST['unified_frame_title']
 
-        unified_frame_pk = create_unified_frame(lu_id)
+        unified_frame_pk = create_unified_frame(frame_id)
 
         unifiedFrame = get_object_or_404(
             UnifiedFrame.objects,
-- 
GitLab