From 65052d301ba6a345b9fd649c0bd05effedfcd656 Mon Sep 17 00:00:00 2001 From: Priya Rani Date: Tue, 30 Jul 2024 15:53:50 +0530 Subject: [PATCH] OTWO-7286 Show 'Report Outdated' button when no analysis (#1795) --- app/models/project.rb | 4 ++++ app/views/projects/show/_header.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 44fa3bb49..95782f8f5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -108,6 +108,10 @@ def after_undo(current_user) remove_enlistments(current_user) if deleted? end + def analysis_updated_or_project_created_time + best_analysis.nil? ? created_at : best_analysis.updated_on + end + class << self def search_and_sort(query, sort, page) sort_by = sort == 'relevance' ? nil : "by_#{sort}" diff --git a/app/views/projects/show/_header.html.haml b/app/views/projects/show/_header.html.haml index 6b66a5c72..25df716f9 100644 --- a/app/views/projects/show/_header.html.haml +++ b/app/views/projects/show/_header.html.haml @@ -20,7 +20,7 @@ - if current_user_is_admin? | = link_to bootstrap_icon('icon-legal', t('projects.header.job')), oh_admin_project_jobs_path(@project) - - if !current_user.nil? && !@project.best_analysis.nil? && @project.best_analysis.updated_on < 1.week.ago + - if current_user.present? && @project.analysis_updated_or_project_created_time < 1.week.ago | = link_to bootstrap_icon('icon-lock', t('projects.header.outdated')), report_outdated_project_path(@project), method: :put .pull-right.no_padding#widgets