Repository: hydroshare/hydroshare

Issue:
Edit overwrites are possible on the resource landing page
If you edit spatial data, then save a different part of the resource data edits, then the spatial data is cleared with a generic error

![005](https://user-images.githubusercontent.com/43424907/108943420-c6bc5c00-7626-11eb-8e3b-24a5fc17efd1.png)




Discussion:
Unable to reproduce.  Plan to close unless @hydrocheck or anyone provides additional information.
I was able to reproduce in HS v 2.6.1 by
* adding spatial data
* edit and then save **temporal data** or upload/delete a file in the FB 

Resolving patch:
diff --git a/hs_core/views/__init__.py b/hs_core/views/__init__.py
--- a/hs_core/views/__init__.py
+++ b/hs_core/views/__init__.py
@@ -354,6 +354,9 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
         msg = {"validation_error": str(ex)}
         return JsonResponse(msg, status=500)
 
+    aggregations_pre = [aggr for aggr in resource.logical_files]
+    aggr_count_pre = len(aggregations_pre)
+
     try:
         hydroshare.utils.resource_file_add_process(
             resource=resource,
@@ -369,6 +372,9 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
         msg = {"validation_error": str(ex)}
         return JsonResponse(msg, status=500)
 
+    aggregations_post = [aggr for aggr in resource.logical_files]
+    aggr_count_post = len(aggregations_post)
+
     res_public_status = "public" if resource.raccess.public else "not public"
     res_discoverable_status = (
         "discoverable" if resource.raccess.discoverable else "not discoverable"
@@ -397,6 +403,7 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
     response_data = {
         "res_public_status": res_public_status,
         "res_discoverable_status": res_discoverable_status,
+        "number_new_aggregations": aggr_count_post - aggr_count_pre,
         "metadata_status": metadata_status,
         "show_meta_status": show_meta_status,
     }
@@ -662,6 +669,7 @@ def add_metadata_element(request, shortkey, element_name, *args, **kwargs):
             else:
                 ajax_response_data = {
                     "status": "success",
+                    "element_type": getattr(element, 'type', None),
                     "element_name": element_name,
                     "spatial_coverage": get_coverage_data_dict(res),
                     "temporal_coverage": get_coverage_data_dict(res, "temporal"),
diff --git a/hs_core/views/resource_folder_hierarchy.py b/hs_core/views/resource_folder_hierarchy.py
--- a/hs_core/views/resource_folder_hierarchy.py
+++ b/hs_core/views/resource_folder_hierarchy.py
@@ -20,7 +20,7 @@
 
 from hs_core.views.utils import authorize, ACTION_TO_AUTHORIZE, zip_folder, unzip_file, \
     create_folder, remove_folder, move_or_rename_file_or_folder, move_to_folder, \
-    rename_file_or_folder, get_coverage_data_dict, irods_path_is_directory, \
+    rename_file_or_folder, irods_path_is_directory, \
     add_reference_url_to_resource, edit_reference_url_in_resource, zip_by_aggregation_file
 
 from hs_file_types.models import FileSetLogicalFile, ModelInstanceLogicalFile, ModelProgramLogicalFile
@@ -219,10 +219,6 @@ def data_store_structure(request):
                      'aggregations': aggregations,
                      'can_be_public': resource.can_be_public_or_discoverable}
 
-    if resource.resource_type == "CompositeResource":
-        return_object['spatial_coverage'] = get_coverage_data_dict(resource)
-        return_object['temporal_coverage'] = get_coverage_data_dict(resource,
-                                                                    coverage_type='temporal')
     return HttpResponse(
         json.dumps(return_object),
         content_type="application/json"


Test patch: