You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2020/01/09 17:28:50 UTC

[airavata-django-portal] branch AIRAVATA-3276--BUG--non-uploaded-files-argument-appears-in-command-line-in-job-script created (now 01195f0)

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a change to branch AIRAVATA-3276--BUG--non-uploaded-files-argument-appears-in-command-line-in-job-script
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git.


      at 01195f0  AIRAVATA-3276 Automatically add showOptions for managing isRequired

This branch includes the following new commits:

     new 01195f0  AIRAVATA-3276 Automatically add showOptions for managing isRequired

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[airavata-django-portal] 01/01: AIRAVATA-3276 Automatically add showOptions for managing isRequired

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch AIRAVATA-3276--BUG--non-uploaded-files-argument-appears-in-command-line-in-job-script
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 01195f091273acf862c01b6e29cd3b3c00e3cacc
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Jan 9 12:24:02 2020 -0500

    AIRAVATA-3276 Automatically add showOptions for managing isRequired
---
 .../js/models/InputDataObjectType.js                  |  8 ++++++++
 django_airavata/apps/api/views.py                     | 19 ++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js b/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
index 9149d2e..d758773 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
@@ -242,11 +242,19 @@ export default class InputDataObjectType extends BaseModel {
           this.editorDependencies.show
         );
         if ("showOptions" in this.editorDependencies) {
+          // AIRAVATA-3276 For backwards compatibility, can be removed after
+          // data migration
           if ("toggle" in this.editorDependencies.showOptions) {
             this.editorDependencies.showOptions.toggle.forEach(prop => {
               this[prop] = this.show;
             });
           }
+          if (
+            "isRequired" in this.editorDependencies.showOptions &&
+            this.editorDependencies.showOptions.isRequired
+          ) {
+            this.isRequired = this.show;
+          }
         }
       }
     }
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 007c4ba..174d3b1 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -664,6 +664,7 @@ class ApplicationInterfaceViewSet(APIBackedViewSet):
 
     def perform_create(self, serializer):
         application_interface = serializer.save()
+        self._update_input_metadata(application_interface)
         log.debug("application_interface: {}".format(application_interface))
         app_interface_id = self.request.airavata_client.registerApplicationInterface(
             self.authz_token, self.gateway_id, application_interface)
@@ -671,6 +672,7 @@ class ApplicationInterfaceViewSet(APIBackedViewSet):
 
     def perform_update(self, serializer):
         application_interface = serializer.save()
+        self._update_input_metadata(application_interface)
         self.request.airavata_client.updateApplicationInterface(
             self.authz_token,
             application_interface.applicationInterfaceId,
@@ -680,6 +682,21 @@ class ApplicationInterfaceViewSet(APIBackedViewSet):
         self.request.airavata_client.deleteApplicationInterface(
             self.authz_token, instance.applicationInterfaceId)
 
+    def _update_input_metadata(self, app_interface):
+        for app_input in app_interface.applicationInputs:
+            if app_input.metaData:
+                metadata = json.loads(app_input.metaData)
+                # Automatically add {showOptions: {isRequired: true/false}} to
+                # toggle isRequired on hidden/shown inputs
+                if ("editor" in metadata and
+                    "dependencies" in metadata["editor"] and
+                        "show" in metadata["editor"]["dependencies"]):
+                    if "showOptions" not in metadata["editor"]["dependencies"]:
+                        metadata["editor"]["dependencies"]["showOptions"] = {}
+                    o = metadata["editor"]["dependencies"]["showOptions"]
+                    o["isRequired"] = app_input.isRequired
+                    app_input.metaData = json.dumps(metadata)
+
     @detail_route()
     def compute_resources(self, request, app_interface_id):
         compute_resources = request.airavata_client.getAvailableAppInterfaceComputeResources(
@@ -950,7 +967,7 @@ def tus_upload_finish(request):
         serializer = serializers.DataProductSerializer(
             data_product, context={'request': request})
         return JsonResponse({'uploaded': True,
-                            'data-product': serializer.data})
+                             'data-product': serializer.data})
     except Exception as e:
         return exceptions.generic_json_exception_response(e, status=400)