From d6019c64464aadb0798df93d5877d73a4a1b9d67 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 1 Oct 2021 12:38:40 -0400 Subject: [PATCH] Adds content to blank reporting page --- app/controllers/report_controller.rb | 1 + app/models/report.rb | 10 ++++++++++ app/views/report/_files_empty.html.erb | 3 +++ app/views/report/_files_without_purpose.html.erb | 14 ++++++++++++++ app/views/report/files.html.erb | 15 +++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 app/views/report/_files_empty.html.erb create mode 100644 app/views/report/_files_without_purpose.html.erb diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb index 080f493b..9a3064d7 100644 --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -12,6 +12,7 @@ def files theses = Thesis.all @terms = report.extract_terms theses subset = filter_theses_by_term theses + @list = report.list_unattached_files subset end def index diff --git a/app/models/report.rb b/app/models/report.rb index 47253f8a..ac650ad2 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -252,6 +252,16 @@ def extract_terms(collection) collection.pluck(:grad_date).uniq.sort end + def list_unattached_files(collection) + result = [] + collection.joins(:files_attachments).order(:grad_date).uniq.each do |record| + record.files.where(purpose: nil).each do |file| + result.push(file) + end + end + result + end + def table_copyright(collection) result = {} collection.group(:copyright).count.each do |record| diff --git a/app/views/report/_files_empty.html.erb b/app/views/report/_files_empty.html.erb new file mode 100644 index 00000000..ce45e78b --- /dev/null +++ b/app/views/report/_files_empty.html.erb @@ -0,0 +1,3 @@ + + There are no files without an assigned purpose within the selected term. + diff --git a/app/views/report/_files_without_purpose.html.erb b/app/views/report/_files_without_purpose.html.erb new file mode 100644 index 00000000..bc057266 --- /dev/null +++ b/app/views/report/_files_without_purpose.html.erb @@ -0,0 +1,14 @@ + + <%= link_to(files_without_purpose.blob[:filename],thesis_process_path(files_without_purpose[:record_id])) %> + + <% files_without_purpose.record.authors.each do |author| %> + <%= author.user.display_name %>
+ <% end %> + + + <% files_without_purpose.record.departments.each do |dept| %> + <%= dept.name_dw %>
+ <% end %> + + <%= files_without_purpose[:description] %> + diff --git a/app/views/report/files.html.erb b/app/views/report/files.html.erb index 389ec969..c7f3cbb1 100644 --- a/app/views/report/files.html.erb +++ b/app/views/report/files.html.erb @@ -6,6 +6,21 @@ <%= render 'shared/defined_terms_filter' %> + + + + + + + + + + + + <%= render(partial: 'report/files_without_purpose', collection: @list) || render('files_empty') %> + +
FileAuthorsDepartmentsDescription
+