From 9aee53bf79965be1eb1777157fc1148851f20c8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Sun, 4 Dec 2022 13:07:37 +0100
Subject: [PATCH] backoffice: reorder webservice parameters (#71565)

---
 wcs/templates/wcs/backoffice/wscall.html |  6 +++--
 wcs/wf/wscall.py                         |  4 +--
 wcs/wscalls.py                           | 34 +++++++++++++-----------
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/wcs/templates/wcs/backoffice/wscall.html b/wcs/templates/wcs/backoffice/wscall.html
index 684f56775..9cdacba70 100644
--- a/wcs/templates/wcs/backoffice/wscall.html
+++ b/wcs/templates/wcs/backoffice/wscall.html
@@ -17,8 +17,8 @@
   <div class="bo-block">
     <h3>{% trans "Parameters" %}</h3>
     <ul>
+      <li>{% trans "Method:" %} {% if wscall.request.method == 'POST' %}POST{% else %}GET{% endif %}</li>
       {% if wscall.request.url %}<li>{% trans "URL:" %} {{ wscall.request.url }}</li>{% endif %}
-      {% if wscall.request.request_signature_key %}<li>{% trans "Request Signature Key:" %} {{ wscall.request.request_signature_key }}</li>{% endif %}
       {% if wscall.request.qs_data %}
         <li>{% trans "Query string data:" %}
           <ul>
@@ -28,7 +28,9 @@
           </ul>
         </li>
       {% endif %}
-      <li>{% trans "Method:" %} {% if wscall.request.method == 'POST' %}POST{% else %}GET{% endif %}</li>
+      {% if wscall.request.request_signature_key %}
+        <li>{% trans "Request Signature Key:" %} {{ wscall.request.request_signature_key }}</li>
+      {% endif %}
       {% if wscall.request.timeout %}
         <li>{% trans "Timeout:" %} {{ wscall.request.timeout }}s</li>
       {% endif %}
diff --git a/wcs/wf/wscall.py b/wcs/wf/wscall.py
index 63265ee0a..89efd8b8d 100644
--- a/wcs/wf/wscall.py
+++ b/wcs/wf/wscall.py
@@ -171,14 +171,14 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
     def get_parameters(self):
         return (
             'label',
+            'method',
             'url',
-            'request_signature_key',
             'qs_data',
-            'method',
             'post',
             'post_data',
             'response_type',
             'varname',
+            'request_signature_key',
             'backoffice_filefield_id',
             'action_on_app_error',
             'action_on_4xx',
diff --git a/wcs/wscalls.py b/wcs/wscalls.py
index b7f88825a..6f2948ea5 100644
--- a/wcs/wscalls.py
+++ b/wcs/wscalls.py
@@ -319,22 +319,6 @@ class WsCallRequestWidget(CompositeWidget):
         if not value:
             value = {}
 
-        self.add(StringWidget, 'url', title=_('URL'), value=value.get('url'), size=80)
-        self.add(
-            ComputedExpressionWidget,
-            'request_signature_key',
-            title=_('Request Signature Key'),
-            value=value.get('request_signature_key'),
-        )
-        self.add(
-            WidgetDict,
-            'qs_data',
-            title=_('Query string data'),
-            value=value.get('qs_data') or {},
-            element_value_type=ComputedExpressionWidget,
-            allow_empty_values=True,
-            value_for_empty_value='',
-        )
         methods = collections.OrderedDict(
             [
                 ('GET', _('GET')),
@@ -354,6 +338,17 @@ class WsCallRequestWidget(CompositeWidget):
             extra_css_class='widget-inline-radio',
         )
         method_widget = self.get_widget('method')
+        self.add(StringWidget, 'url', title=_('URL'), value=value.get('url'), size=80)
+        self.add(
+            WidgetDict,
+            'qs_data',
+            title=_('Query string data'),
+            value=value.get('qs_data') or {},
+            element_value_type=ComputedExpressionWidget,
+            allow_empty_values=True,
+            value_for_empty_value='',
+        )
+
         if self.include_post_formdata:
             self.add(
                 CheckboxWidget,
@@ -379,6 +374,13 @@ class WsCallRequestWidget(CompositeWidget):
             },
         )
 
+        self.add(
+            ComputedExpressionWidget,
+            'request_signature_key',
+            title=_('Request Signature Key'),
+            value=value.get('request_signature_key'),
+        )
+
         def validate_timeout(value):
             if value and not value.isdecimal():
                 raise ValueError(_('Timeout must be empty or a number.'))
-- 
2.38.1

