From 85906141ef57999826657e046060cba705bc22cd Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 15:31:41 -0700 Subject: [PATCH 1/6] Replace deprecated find method with get --- app/controllers/users_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 531b4fd6ff..bdae0972cc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -105,8 +105,7 @@ def destroy end def custom_ontologies - @user = LinkedData::Client::Models::User.find(params[:id]) - @user = LinkedData::Client::Models::User.find_by_username(params[:id]).first if @user.nil? + @user = LinkedData::Client::Models::User.get(params[:id]) custom_ontologies = params[:ontology] ? params[:ontology][:ontologyId] : [] custom_ontologies.reject!(&:blank?) @@ -116,7 +115,7 @@ def custom_ontologies if error_response flash[:notice] = 'Error saving Custom Ontologies, please try again' else - updated_user = LinkedData::Client::Models::User.find(@user.id) + updated_user = LinkedData::Client::Models::User.get(@user.id) session[:user].update_from_params(customOntology: updated_user.customOntology) flash[:notice] = if updated_user.customOntology.empty? 'Custom Ontologies were cleared' From 0cc5ba53889e4a2605b199da6c570f11548c89a4 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 15:54:38 -0700 Subject: [PATCH 2/6] Fix red herring error on custom ontology set save Resolves #330 --- app/controllers/users_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bdae0972cc..48934a96ba 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -110,18 +110,18 @@ def custom_ontologies custom_ontologies = params[:ontology] ? params[:ontology][:ontologyId] : [] custom_ontologies.reject!(&:blank?) @user.update_from_params(customOntology: custom_ontologies) - error_response = @user.update + response = @user.update - if error_response - flash[:notice] = 'Error saving Custom Ontologies, please try again' - else - updated_user = LinkedData::Client::Models::User.get(@user.id) + if response.success? + updated_user = LinkedData::Client::Models::User.get(@user.id, include: 'customOntology') session[:user].update_from_params(customOntology: updated_user.customOntology) flash[:notice] = if updated_user.customOntology.empty? 'Custom Ontologies were cleared' else 'Custom Ontologies were saved' end + else + flash[:notice] = 'Error saving Custom Ontologies, please try again' end redirect_to user_path(@user.username) end From 5f9791257016db5640dd280426594edf8d6a199f Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 15:55:59 -0700 Subject: [PATCH 3/6] Use proper error flash styling --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 48934a96ba..b30f074ed0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -121,7 +121,7 @@ def custom_ontologies 'Custom Ontologies were saved' end else - flash[:notice] = 'Error saving Custom Ontologies, please try again' + flash[:error] = 'Error saving Custom Ontologies, please try again' end redirect_to user_path(@user.username) end From c875b15396a578027606b6bbd0a5490a66174a70 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 16:00:39 -0700 Subject: [PATCH 4/6] Improve flash notice and error text for custom set --- app/controllers/users_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b30f074ed0..cc65fc2408 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -116,12 +116,12 @@ def custom_ontologies updated_user = LinkedData::Client::Models::User.get(@user.id, include: 'customOntology') session[:user].update_from_params(customOntology: updated_user.customOntology) flash[:notice] = if updated_user.customOntology.empty? - 'Custom Ontologies were cleared' + 'Custom ontology set successfully cleared' else - 'Custom Ontologies were saved' + 'Custom ontology set successfully saved' end else - flash[:error] = 'Error saving Custom Ontologies, please try again' + flash[:error] = 'Error saving custom ontology set. Please try again.' end redirect_to user_path(@user.username) end From d2f81cd33c20d670848081d6d9213b3a8a6de905 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 16:12:31 -0700 Subject: [PATCH 5/6] Narrow the include params on each get --- app/views/users/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index f4ea240873..cd0150ea44 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -130,7 +130,7 @@ - if @user_ontologies.present? %ul - @user_ontologies.each do |ont| - - ont = LinkedData::Client::Models::Ontology.get(ont) + - ont = LinkedData::Client::Models::Ontology.get(ont, include: 'name,acronym') %li #{ont.name} (#{ont.acronym}) - else From 8a8b346e0192dd4289e1907f265102255942a122 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 18 Sep 2024 16:27:57 -0700 Subject: [PATCH 6/6] Tweak list style for custom ontology sets --- app/views/users/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index cd0150ea44..28f42ff7c6 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -121,14 +121,14 @@ } %h4{class: 'pb-2 mt-5 mb-4 border-bottom'} Custom ontology set - #custom_ontologies.enable-lists + #custom_ontologies - if at_slice? = custom_ontology_set_slice_text - else = custom_ontology_set_intro_text = button_tag('Select ontologies', type: 'button', id: 'edit_custom_ontologies', class: 'btn btn-primary') - if @user_ontologies.present? - %ul + %ul{class: 'list-unstyled mt-3 mb-5'} - @user_ontologies.each do |ont| - ont = LinkedData::Client::Models::Ontology.get(ont, include: 'name,acronym') %li