diff --git a/hydroshare_resources_app/static/images/apps.png b/hydroshare_resources_app/static/images/apps.png new file mode 100644 index 0000000..1723405 Binary files /dev/null and b/hydroshare_resources_app/static/images/apps.png differ diff --git a/hydroshare_resources_app/utils.py b/hydroshare_resources_app/utils.py index 3c71063..19f6f8d 100644 --- a/hydroshare_resources_app/utils.py +++ b/hydroshare_resources_app/utils.py @@ -11,9 +11,6 @@ def get_dict_with_attribute(list_of_dicts, attribute, value): # Loop through each dictionary in the list for dictionary in list_of_dicts: - # logging.warning(dictionary) - # if attribute in dictionary: - # logging.warning(dictionary[attribute]) # Check if the attribute exists in the dictionary and has the specified value if attribute in dictionary and dictionary[attribute] == value: return dictionary # Return the dictionary if found @@ -22,12 +19,9 @@ def get_dict_with_attribute(list_of_dicts, attribute, value): def get_most_recent_date(date_local_resource, date_api): - # logging.warning(f'{date_local_resource} , {date_api}') - # Convert strings to datetime objects date_time_local_resource = datetime.datetime.fromisoformat(date_local_resource[:-1]) date_time_api = datetime.datetime.fromisoformat(date_api[:-1]) - # logging.warning(f'{date_time_local_resource} , {date_time_api}') # Compare the datetime objects if date_time_local_resource > date_time_api: return False @@ -38,14 +32,13 @@ def get_most_recent_date(date_local_resource, date_api): def update_resource(resource, hs, instance): - # logging.warning(science_metadata_json) single_resource = {} if resource["resource_type"] == "ToolResource": science_metadata_json = hs.getScienceMetadata(resource["resource_id"]) # logging.warning(f'{science_metadata_json}') image_url = science_metadata_json.get( "app_icon", instance.placeholder_image - ).get("value", instance.placeholder_image) + ).get("data_url", instance.placeholder_image) web_site_url = ( "" if not science_metadata_json.get("app_home_page_url", "") @@ -99,7 +92,6 @@ def update_resource(resource, hs, instance): "resource_type": resource["resource_type"], "resource_url": resource["resource_url"], } - # logging.warning(single_resource) return single_resource diff --git a/hydroshare_resources_app/views.py b/hydroshare_resources_app/views.py index b17c3ed..d996628 100644 --- a/hydroshare_resources_app/views.py +++ b/hydroshare_resources_app/views.py @@ -25,13 +25,10 @@ def hydroshare_resources_view(request): body = json.loads(body_unicode) instance = HydroShareResourcesList.objects.get(id=body["instance_id"]) - # logger.warning(instance.updated_version) keywords = [] json_resources = {"resources": []} - # logging.warning(instance.user,instance.password) if instance.tags: keywords = instance.tags.split(",") - # logging.warning(keywords) if instance.user != "" and instance.password != "": auth = HydroShareAuthBasic(username=instance.user, password=instance.password) hs = HydroShare(auth=auth) @@ -49,9 +46,6 @@ def hydroshare_resources_view(request): matching_resource_model = get_dict_with_attribute( resources_model, "resource_id", resource_api["resource_id"] ) - # logging.warning("this is a matching_resource_model") - # logging.warning(matching_resource_model) - # If resource found locally, then check last update date if matching_resource_model: is_recent_date = get_most_recent_date( @@ -62,27 +56,20 @@ def hydroshare_resources_view(request): if ( is_recent_date ): # If the resource retrieved from api is more recent, then update resource - # logging.warning("resource has a more recent version") single_resource = update_resource(resource_api, hs, instance) - # logging.warning(single_resource) json_resources["resources"].append(single_resource) instance.resources = json_resources else: # resource is the same, then retrive the resource saved locally - # logging.warning("resource is the same") - single_resource = matching_resource_model json_resources["resources"].append(single_resource) instance.resources = json_resources # If the resource is not here then create one else: - # logging.warning(resource) - # logging.warning("resource is new, creating now") single_resource = update_resource(resource_api, hs, instance) json_resources["resources"].append(single_resource) instance.resources = json_resources - # logging.warning(json_resources) instance.save(update_fields=["resources"]) return JsonResponse(json_resources)