From fa8f8772a895ba6f0c8774b14c495f536f504590 Mon Sep 17 00:00:00 2001
From: jazairi <16103405+jazairi@users.noreply.github.com>
Date: Mon, 18 Sep 2023 11:59:24 -0400
Subject: [PATCH] Move method from thesis helper to model
---
app/helpers/thesis_helper.rb | 4 ----
app/models/thesis.rb | 6 +++++-
app/views/thesis/process_theses.html.erb | 2 +-
test/helpers/thesis_helper_test.rb | 24 ------------------------
test/models/thesis_test.rb | 24 ++++++++++++++++++++++++
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/app/helpers/thesis_helper.rb b/app/helpers/thesis_helper.rb
index ec2bd6a6..4988800b 100644
--- a/app/helpers/thesis_helper.rb
+++ b/app/helpers/thesis_helper.rb
@@ -93,8 +93,4 @@ def proquest_status_counts(theses)
end
result
end
-
- def look_up_degree_period(thesis)
- DegreePeriod.find_by(grad_year: thesis.graduation_year, grad_month: thesis.graduation_month)
- end
end
diff --git a/app/models/thesis.rb b/app/models/thesis.rb
index 52498db3..ecd64ea7 100644
--- a/app/models/thesis.rb
+++ b/app/models/thesis.rb
@@ -148,13 +148,17 @@ class Thesis < ApplicationRecord
# Looks up the thesis' accession number based on its degree period.
def accession_number
- degree_period = DegreePeriod.find_by(grad_year: graduation_year, grad_month: graduation_month)
+ degree_period = look_up_degree_period
return if degree_period.nil?
return if degree_period.archivematica_accession.nil?
degree_period.archivematica_accession.accession_number
end
+ def look_up_degree_period
+ DegreePeriod.find_by(grad_year: graduation_year, grad_month: graduation_month)
+ end
+
# Returns a true/false value (rendered as "yes" or "no") if there are any
# holds with a status of either 'active' or 'expired'. A false/"No" is
# only returned if all holds are 'released'.
diff --git a/app/views/thesis/process_theses.html.erb b/app/views/thesis/process_theses.html.erb
index 1c647cf8..d4cc6482 100644
--- a/app/views/thesis/process_theses.html.erb
+++ b/app/views/thesis/process_theses.html.erb
@@ -53,7 +53,7 @@
label_html: { style: 'width: 50%' },
input_html: { class: 'disabled', style: 'width: 40%', value: f.object.accession_number.present?? 'Yes' : 'No' },
hint_html: { style: 'display: block' },
- hint: (link_to('Create new accession number', new_admin_archivematica_accession_path(degree_period_id: look_up_degree_period(f.object)), target: :_blank) if f.object.accession_number.nil?) %>
+ hint: (link_to('Create new accession number', new_admin_archivematica_accession_path(degree_period_id: f.object.look_up_degree_period), target: :_blank) if f.object.accession_number.nil?) %>