From 4b048b515b56d07eca699093c576b321000ab298 Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 13:17:01 -0400 Subject: [PATCH 01/24] first commit --- lib/tasks/gem_records_csv.rake | 14 +++++++++ lib/tasks/load_gem_records_csv.rb | 45 +++++++++++++++++++++++++++ test/helpers/load_gem_records_test.rb | 32 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 lib/tasks/gem_records_csv.rake create mode 100644 lib/tasks/load_gem_records_csv.rb create mode 100644 test/helpers/load_gem_records_test.rb diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake new file mode 100644 index 0000000..a7fb311 --- /dev/null +++ b/lib/tasks/gem_records_csv.rake @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require Rails.root.join('lib/tasks/load_gem_records_csv.rb') + +namespace :gem_records_csv do + desc 'Loading Gem Records.' + # Usage: cat /file/with/gem_records.txt | rake gem_records:load + + task load: :environment do + GemRecord.delete_all + gem_load = LoadGemRecordsCSV.new + gem_load.load_csv('dummy_gem_records.csv') + end +end diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb new file mode 100644 index 0000000..ae93e83 --- /dev/null +++ b/lib/tasks/load_gem_records_csv.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +## +# Function to load gem records from a text file, delimited by __ETD_COLSEP__ +## + +require 'csv' + +class LoadGemRecordsCSV + + def load_csv(filename) + count = 0 + + filename = File.join(File.dirname(__FILE__), filename) + + CSV.foreach(filename, headers: true) do |row| + seqgradevent = row['seqgradevent'].strip + unless GemRecord.find_by_seqgradevent(seqgradevent) + gr = GemRecord.new + gr.seqgradevent = seqgradevent + gr.studentname = row['studentname'].strip + gr.sisid = row['sisid'].strip + gr.emailaddress = row['emailaddress'].strip + gr.eventtype = row['eventtype'].strip + gr.eventdate = row['eventdate'].strip + gr.examresult = row['examresult'].strip + gr.title = row['title'].strip + gr.program = row['program'].strip + gr.superv = row['superv'].strip + gr.examdate = row['examdate'].strip + + if gr.save!(validate: false) + count += 1 + else + warn('Error: Load Gem Records Save Failed!') + warn("Error: #{gr.errors.inspect}") + end + end + rescue StandardError => e + warn("ERROR: #{e}") + warn('Hint: Possible Bad File if strip nil') + end + + end +end diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb new file mode 100644 index 0000000..556d6c6 --- /dev/null +++ b/test/helpers/load_gem_records_test.rb @@ -0,0 +1,32 @@ +require 'test_helper' + +require Rails.root.join('lib/tasks/load_gem_records_csv.rb') +class LoadGemRecordsTest < ActiveSupport::TestCase + setup do + gem_load = LoadGemRecordsCSV.new + gem_load.load_csv + end + + should "parse csv" do + puts "\nRunning test..." + + assert_equal 3, GemRecord.count + + records = GemRecord.order(:seqgradevent) + + assert_equal 1, records[0].seqgradevent + assert_equal 'John Doe', records[0].studentname + assert_equal 123456, records[0].sisid + assert_equal 'johndoe@example.com', records[0].emailaddress + + assert_equal 2, records[1].seqgradevent + assert_equal 'Jane Smith', records[1].studentname + assert_equal 654321, records[1].sisid + assert_equal 'janesmith@example.com', records[1].emailaddress + + assert_equal 3, records[2].seqgradevent + assert_equal 'Alice Johnson', records[2].studentname + assert_equal 789012, records[2].sisid + assert_equal 'alicejohnson@example.com', records[2].emailaddress + end +end From b8a88c54db04c0b03ac366afbb4c6964ee580c0f Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 14:46:05 -0400 Subject: [PATCH 02/24] fixed typo --- test/helpers/load_gem_records_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb index 556d6c6..b234f99 100644 --- a/test/helpers/load_gem_records_test.rb +++ b/test/helpers/load_gem_records_test.rb @@ -4,7 +4,7 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv + gem_load.load_csv('dummy_gem_records.csv') end should "parse csv" do From fd55ddb8d8e5d5fc1c08d0f933d929ae54d684ef Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 14:50:16 -0400 Subject: [PATCH 03/24] added dummy data gem records --- lib/tasks/dummy_gem_records.csv | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lib/tasks/dummy_gem_records.csv diff --git a/lib/tasks/dummy_gem_records.csv b/lib/tasks/dummy_gem_records.csv new file mode 100644 index 0000000..6b3c2f0 --- /dev/null +++ b/lib/tasks/dummy_gem_records.csv @@ -0,0 +1,4 @@ +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file From 9c501abc16bd215e33629e453279fbb07eb02e1d Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 15:06:30 -0400 Subject: [PATCH 04/24] moved dummy record file and updated file path --- lib/{tasks => }/dummy_gem_records.csv | 0 lib/tasks/gem_records_csv.rake | 2 +- lib/tasks/load_gem_records_csv.rb | 2 -- test/helpers/load_gem_records_test.rb | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) rename lib/{tasks => }/dummy_gem_records.csv (100%) diff --git a/lib/tasks/dummy_gem_records.csv b/lib/dummy_gem_records.csv similarity index 100% rename from lib/tasks/dummy_gem_records.csv rename to lib/dummy_gem_records.csv diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake index a7fb311..7543cbf 100644 --- a/lib/tasks/gem_records_csv.rake +++ b/lib/tasks/gem_records_csv.rake @@ -9,6 +9,6 @@ namespace :gem_records_csv do task load: :environment do GemRecord.delete_all gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('dummy_gem_records.csv') + gem_load.load_csv('lib/dummy_gem_records.csv') end end diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index ae93e83..b5a6fbf 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -11,8 +11,6 @@ class LoadGemRecordsCSV def load_csv(filename) count = 0 - filename = File.join(File.dirname(__FILE__), filename) - CSV.foreach(filename, headers: true) do |row| seqgradevent = row['seqgradevent'].strip unless GemRecord.find_by_seqgradevent(seqgradevent) diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb index b234f99..c396804 100644 --- a/test/helpers/load_gem_records_test.rb +++ b/test/helpers/load_gem_records_test.rb @@ -4,7 +4,7 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('dummy_gem_records.csv') + gem_load.load_csv('lib/dummy_gem_records.csv') end should "parse csv" do From 8776582105870f8e0b1f6befde855dafb5b4d69b Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 16:57:42 -0400 Subject: [PATCH 05/24] added arguments to rake file --- docker-compose.yml | 3 --- lib/tasks/gem_records_csv.rake | 9 +++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6492e47..5b6db04 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,9 +23,6 @@ services: - RAILS_SERVE_STATIC_FILES=true - NODE_OPTIONS=--openssl-legacy-provider - SELENIUM_SERVER=chrome-server - env_file: - - path: ./override.env - required: false db: image: mysql diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake index 7543cbf..0474dfa 100644 --- a/lib/tasks/gem_records_csv.rake +++ b/lib/tasks/gem_records_csv.rake @@ -6,9 +6,14 @@ namespace :gem_records_csv do desc 'Loading Gem Records.' # Usage: cat /file/with/gem_records.txt | rake gem_records:load - task load: :environment do + task :load, [:filename] => :environment do |t, args| + filename = args[:filename] + if filename.nil? || filename.empty? + puts "Error: Filename is required" + exit 1 + end GemRecord.delete_all gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('lib/dummy_gem_records.csv') + gem_load.load_csv(filename) end end From e1ccdd6a08aa72642c71796412c00b54c30614fe Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 9 Jul 2024 17:01:16 -0400 Subject: [PATCH 06/24] reset docker compose --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 5b6db04..6492e47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,9 @@ services: - RAILS_SERVE_STATIC_FILES=true - NODE_OPTIONS=--openssl-legacy-provider - SELENIUM_SERVER=chrome-server + env_file: + - path: ./override.env + required: false db: image: mysql From f8e6ea70363b1c9ba7c1d3ea7d1fd643842c9481 Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Wed, 10 Jul 2024 10:11:35 -0400 Subject: [PATCH 07/24] moved load gem records test to lib folder --- test/{helpers => lib}/load_gem_records_test.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{helpers => lib}/load_gem_records_test.rb (100%) diff --git a/test/helpers/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb similarity index 100% rename from test/helpers/load_gem_records_test.rb rename to test/lib/load_gem_records_test.rb From 18eac23b220feb8d9050c18ad6e4cf5487e770dd Mon Sep 17 00:00:00 2001 From: Ali Sadaqain <sadaqain@yorku.ca> Date: Wed, 10 Jul 2024 10:16:01 -0400 Subject: [PATCH 08/24] Add upload to thesis view for admins --- .../student_view/process/submit.html.erb | 2 +- app/views/theses/show.html.erb | 119 +++++++++++++++--- test/system/theses_test.rb | 41 ++++++ 3 files changed, 141 insertions(+), 21 deletions(-) diff --git a/app/views/student_view/process/submit.html.erb b/app/views/student_view/process/submit.html.erb index f94128b..df52a2f 100644 --- a/app/views/student_view/process/submit.html.erb +++ b/app/views/student_view/process/submit.html.erb @@ -99,7 +99,7 @@ <% end %> <% end %> <% if @supplemental_documents.count == 0 %> - <p>There are no <strong>supplementary</strong> files or documents attached to this thesis/dissertation.</p> + <p>There are no <strong>supplementary licence</strong> files or documents attached to this thesis/dissertation.</p> <% end %> </div> diff --git a/app/views/theses/show.html.erb b/app/views/theses/show.html.erb index b03fe1f..9d5e708 100644 --- a/app/views/theses/show.html.erb +++ b/app/views/theses/show.html.erb @@ -1,12 +1,12 @@ <% title "#{@student.name} - Thesis" %> <% title_html do %> - <div class="row"> +<div class="row"> <%= render partial: "students/header" %> <div class="col-12 py-0"><hr /></div> - </div> -<% end %> - <div class="row"> +</div> + <% end %> +<div class="row"> <div class="col-sm-12 col-lg-6"> <h5 class="author" title="author">By <%= @thesis.author %> | <%= number_with_delimiter(@thesis.student.sisid, delimiter: " ") %></h5> <h3 class="title" title="title"><%= @thesis.title %></h3> @@ -136,30 +136,109 @@ </div> <div class="row"> - <div class="documents fitted"> + <div class="documents fitted"> + <h6 class="green pt-4">Thesis Files and Documents</h6> - <h6 class="green pt-4">Thesis Files and Documents</h6> + <% if current_user.role != User::STUDENT %> + <div class="mt-4"> + <h6>Primary</h5> + <% unless block_thesis_changes?(@thesis) %> + <% if @primary_documents.count == 0 %> + <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#primary-file">Upload Primary File</button> + <% end %> + <% end %> - <h6>Primary</h6> - <% @primary_documents.each do | document | %> - <%= render partial: document %> - <% end %> - <% if @primary_documents.count == 0 %> - <p>There are no <strong>primary</strong> files or documents attached to this thesis.</p> - <% end %> + <% @primary_documents.each do | document | %> + <%= render partial: document %> + <% end %> + <% if @primary_documents.count == 0 %> + <p>There is no <strong>primary</strong> file or document attached to this thesis/dissertation.</p> + <% end %> + <div class="push-down"></div> + </div> + <div class="mt-4"> + <h6>Supplementary</h6> + <% unless block_thesis_changes?(@thesis) %> + <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#supplemental-files">Upload Supplementary Files</button> + <% end %> - <h6>Supplemental</h6> - <% @supplemental_documents.each do | document | %> - <%= render partial: document %> - <% end %> - <% if @supplemental_documents.count == 0 %> - <p>There are no <strong>supplemental</strong> files or documents attached to this thesis.</p> - <% end %> + <div class='mt-3'> + <% @supplemental_documents.each do | document | %> + <% if document.usage != "licence" %> + <%= render partial: document %> + <% end %> + <% end %> + <% if @supplemental_documents.count == 0 %> + <p>There are no <strong>supplementary</strong> files or documents attached to this thesis/dissertation.</p> + <% end %> + </div> + </div> + <div class='mt-4'> + <h6>License Agreements</h6> + <% unless block_thesis_changes?(@thesis) %> + <button type="button" class="btn btn-dark mb-3 " data-bs-toggle="modal" data-bs-target="#supplemental-licence-files">Upload Licence Files</button> + <% end %> + <% @supplemental_documents.each do | document | %> + <% if document.usage == 'licence'%> + <div class='licence-file'> + <%= render partial: document %> + </div> + <% end %> + <% end %> + <% if @supplemental_documents.where(usage: :licence).count == 0 %> + <p>There are no <strong>supplementary</strong> licence files or documents attached to this thesis/dissertation.</p> + <% end %> + </div> + <% else %> + <h6>Primary</h5> + <% @primary_documents.each do | document | %> + <%= render partial: document %> + <% end %> + <% if @primary_documents.count == 0 %> + <p>There is no <strong>primary</strong> file or document attached to this thesis/dissertation.</p> + <% end %> + <% @supplemental_documents.each do | document | %> + <%= render partial: document %> + <% end %> + <% if @supplemental_documents.where(usage: :licence).count == 0 %> + <p>There are no <strong>supplementary</strong> licence files or documents attached to this thesis/dissertation.</p> + <% end %> + <% end %> + + + </div> </div> + + <%= render partial: "documents/new_form", locals: { primary: true } %> + + <%= render partial: "documents/new_form", locals: { primary: false } %> + + <%= render partial: "documents/new_licence_form", locals: { primary: false } %> + <!-- + <h6>Primary</h6> + <% @primary_documents.each do | document | %> + <%= render partial: document %> + <% end %> + + <% if @primary_documents.count == 0 %> + <p>There are no <strong>primary</strong> files or documents attached to this thesis.</p> + <% end %> + + + + <h6>Supplemental</h6> + <% @supplemental_documents.each do | document | %> + <%= render partial: document %> + <% end %> + <% if @supplemental_documents.count == 0 %> + <p>There are no <strong>supplemental</strong> files or documents attached to this thesis.</p> + <% end %> + --> + </div> </div> \ No newline at end of file diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index c3b1816..6af793f 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -57,4 +57,45 @@ class ThesesTest < ApplicationSystemTestCase page.accept_alert assert_selector 'p', text: 'This thesis has been placed under permanent embargo. It will not be published.' end + + should "be able to upload primary document by admin/staff" do + visit root_url + click_link(@thesis_01.title) + + click_on("Upload Primary File") + assert_selector "p", text: "Your primary file should be in PDF format.", visible: :all + attach_file("document_file", Rails.root.join('test/fixtures/files/Tony_Rich_E_2012_Phd.pdf')) + click_button('Upload') + + assert_selector(".name", text: /Primary\.pdf/) + end + + should "be able to upload supplementary document by admin/staff" do + visit root_url + click_link(@thesis_01.title) + + click_on("Upload Supplementary Files") + assert_selector "h1", text: "Upload Supplementary File", visible: :all + attach_file("document_file", Rails.root.join('test/fixtures/files/pdf-document.pdf')) + assert_selector "select#document_usage" + select "Supplementary file or document attached to thesis/dissertation", from: 'Document type' #document_usage + click_button('Upload') + assert_selector(".supplemental", text: /Supplemental/) #Supplemental + end + + should "be able to upload supplementary license document by admin/staff" do + visit root_url + click_link(@thesis_01.title) + + click_on("Upload Licence Files") + assert_selector "h1", text: "Upload Supplementary Licence File", visible: :all + attach_file("document_file", Rails.root.join('test/fixtures/files/pdf-document.pdf')) + # page.driver.browser.manage.window.resize_to(1920, 2500) + # save_screenshot() + click_button('Upload') + assert_not_empty find('.licence-file').text, "The .licence-file element is empty, no file" + + end + + end From a5a9b1e2f68b984da95d0ff3f4f2a8b7e1541115 Mon Sep 17 00:00:00 2001 From: Ali Sadaqain <sadaqain@yorku.ca> Date: Fri, 12 Jul 2024 11:20:18 -0400 Subject: [PATCH 09/24] Remove publish hiding of actions for admins --- app/views/theses/show.html.erb | 40 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/views/theses/show.html.erb b/app/views/theses/show.html.erb index 9d5e708..63494c3 100644 --- a/app/views/theses/show.html.erb +++ b/app/views/theses/show.html.erb @@ -14,31 +14,33 @@ <div class="col-sm-12 col-lg"> <div class="row"> <div class="col-4"> - <% unless @thesis.status == Thesis::PUBLISHED %> - <h6 class="text-black">Edit thesis</h6> - <div><%= link_to "Make Changes", edit_student_thesis_path(@student, @thesis), class: "btn btn-success btn-sm d-grid" %></div> - <% end %> - </div> - <div class="col-5"> - <% if @thesis.status == Thesis::PUBLISHED %> + <% if current_user.role == User::STUDENT %> <div id="status_menu"> <button id="" class="btn" title="Change Thesis Status"> Status: <span class="status status-<%= @thesis.status %>"><%= @thesis.status.humanize %></span> </button> </div> - <% else%> - <h6 class="text-black">Change status</h6> - <%= render partial: "status_menu"%> - <% end %> - </div> - <div class="col"> - <% unless @thesis.status == Thesis::PUBLISHED %> - <h6 class="text-black">Assign to</h6> - <div class="span d-grid"> - <%= render partial: "assigned_to", locals: { thesis: @thesis }%> - </div> + <% else %> + + <h6 class="text-black">Edit thesis</h6> + <div><%= link_to "Make Changes", edit_student_thesis_path(@student, @thesis), class: "btn btn-success btn-sm d-grid" %></div> + + </div> + <div class="col-5"> + + <h6 class="text-black">Change status</h6> + <%= render partial: "status_menu"%> + + </div> + <div class="col"> + + <h6 class="text-black">Assign to</h6> + <div class="span d-grid"> + <%= render partial: "assigned_to", locals: { thesis: @thesis }%> + </div> + + </div> <% end %> - </div> </div> </div> </div> From a48a641ee7eda95f7ffb498e77e6083732e7538c Mon Sep 17 00:00:00 2001 From: dennis <dennis.deli@nownpos.com> Date: Mon, 15 Jul 2024 13:48:53 -0400 Subject: [PATCH 10/24] first commit --- test/controllers/gem_records_controller_test.rb | 15 +++++++++++++++ test/system/students_test.rb | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/test/controllers/gem_records_controller_test.rb b/test/controllers/gem_records_controller_test.rb index 0d4d448..4a65ab2 100644 --- a/test/controllers/gem_records_controller_test.rb +++ b/test/controllers/gem_records_controller_test.rb @@ -34,4 +34,19 @@ class GemRecordsControllerTest < ActionController::TestCase assert_template 'index', 'Index template should be displayed' end + + should 'committee members included in gem records' + gem_records = create_list(:gem_record, 5, eventtype: GemRecord::PHD_EXAM) + gem_records.each do |record| + create_list(:committee_member, 2, gem_record: record) + end + + get :index, params: { all: true } + + records = assigns(:gem_records) + + records.each do |record| + assert record.committee_members.count >= 1, 'Each gem record should have at least one committee member' + end + end end diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 28b80e8..68538b3 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -20,6 +20,18 @@ class StudentsTest < ApplicationSystemTestCase click_link('Start this thesis') end + test 'Gem Record has committee members' do + visit root_url + click_link('Gem Records') + click_link(@gem_record.studentname) + + assert_selector "h6", text: "Committee Members" + @gem_record.committee_members.each do |committee_member| + assert_selector "p", text: committee_member.full_name + end + + end + test 'Log in as Student and add a thesis' do @thesis = FactoryGirl.create(:thesis) login_as(@thesis.student) From 2b92486b12607c919926325c23d7aa065e6fd785 Mon Sep 17 00:00:00 2001 From: dennis <dennis.deli@nownpos.com> Date: Mon, 15 Jul 2024 15:01:51 -0400 Subject: [PATCH 11/24] fixed typo + added a committee member check --- test/controllers/gem_records_controller_test.rb | 2 +- test/system/students_test.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/controllers/gem_records_controller_test.rb b/test/controllers/gem_records_controller_test.rb index 4a65ab2..79432b6 100644 --- a/test/controllers/gem_records_controller_test.rb +++ b/test/controllers/gem_records_controller_test.rb @@ -35,7 +35,7 @@ class GemRecordsControllerTest < ActionController::TestCase assert_template 'index', 'Index template should be displayed' end - should 'committee members included in gem records' + should 'committee members included in gem records' do gem_records = create_list(:gem_record, 5, eventtype: GemRecord::PHD_EXAM) gem_records.each do |record| create_list(:committee_member, 2, gem_record: record) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 68538b3..8401921 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -26,9 +26,11 @@ class StudentsTest < ApplicationSystemTestCase click_link(@gem_record.studentname) assert_selector "h6", text: "Committee Members" - @gem_record.committee_members.each do |committee_member| - assert_selector "p", text: committee_member.full_name - end + if @gem_record.committee_members.count > 1 + @gem_record.committee_members.each do |committee_member| + assert_selector "p", text: committee_member.full_name + end + end end From 7c94f4ed4ca46fd81a8ed98b3231095df89eb156 Mon Sep 17 00:00:00 2001 From: dennis <dennis.deli@nownpos.com> Date: Mon, 15 Jul 2024 16:57:36 -0400 Subject: [PATCH 12/24] updated with committee members in gem records --- lib/dummy_gem_records.csv | 8 ++++---- lib/tasks/load_gem_records_csv.rb | 11 +++++++++++ test/lib/load_gem_records_test.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/dummy_gem_records.csv b/lib/dummy_gem_records.csv index 6b3c2f0..55aaebc 100644 --- a/lib/dummy_gem_records.csv +++ b/lib/dummy_gem_records.csv @@ -1,4 +1,4 @@ -seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate -1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 -2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 -3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate,committee_members +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01,"John,Smith,Chair;Jane,Doe,Committee Member" +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02,"Jim,Brown,Chair;Jake,White,Committee Member" +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03, "Eve Green:Chair,Frank Black:Committee Member" \ No newline at end of file diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index b5a6fbf..204569a 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -28,6 +28,17 @@ def load_csv(filename) gr.examdate = row['examdate'].strip if gr.save!(validate: false) + committee_members = row['committee_members'].split(';') + committee_members.each do |member| + first_name, last_name, role = member.split(',') + CommitteeMember.create!( + gem_record: gr, + first_name: first_name.strip, + last_name: last_name.strip, + role: role.strip + ) + end + count += 1 else warn('Error: Load Gem Records Save Failed!') diff --git a/test/lib/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb index c396804..26d5874 100644 --- a/test/lib/load_gem_records_test.rb +++ b/test/lib/load_gem_records_test.rb @@ -28,5 +28,32 @@ class LoadGemRecordsTest < ActiveSupport::TestCase assert_equal 'Alice Johnson', records[2].studentname assert_equal 789012, records[2].sisid assert_equal 'alicejohnson@example.com', records[2].emailaddress + + assert_equal 2, records[0].committee_members.count + assert_equal 'John', records[0].committee_members.first.first_name + assert_equal 'Smith', records[0].committee_members.first.last_name + assert_equal 'Chair', records[0].committee_members.first.role + + assert_equal 'Jane', records[0].committee_members.last.first_name + assert_equal 'Doe', records[0].committee_members.last.last_name + assert_equal 'Committee Member', records[0].committee_members.last.role + + assert_equal 2, records[1].committee_members.count + assert_equal 'Jim', records[1].committee_members.first.first_name + assert_equal 'Brown', records[1].committee_members.first.last_name + assert_equal 'Chair', records[1].committee_members.first.role + + assert_equal 'Jake', records[1].committee_members.last.first_name + assert_equal 'White', records[1].committee_members.last.last_name + assert_equal 'Committee Member', records[1].committee_members.last.role + + assert_equal 2, records[2].committee_members.count + assert_equal 'Eve', records[2].committee_members.first.first_name + assert_equal 'Green', records[2].committee_members.first.last_name + assert_equal 'Chair', records[2].committee_members.first.role + + assert_equal 'Frank', records[2].committee_members.last.first_name + assert_equal 'Black', records[2].committee_members.last.last_name + assert_equal 'Committee Member', records[2].committee_members.last.role end end From 9db3ff99b54b01f7c5b3b9fcb0ef30c38075f364 Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Tue, 16 Jul 2024 10:23:19 -0400 Subject: [PATCH 13/24] added gem_record_id in committee_member --- app/controllers/committee_members_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/committee_members_controller.rb b/app/controllers/committee_members_controller.rb index 7dc631e..a5ecb9b 100644 --- a/app/controllers/committee_members_controller.rb +++ b/app/controllers/committee_members_controller.rb @@ -44,6 +44,6 @@ def destroy private def committee_member_params - params.require(:committee_member).permit(:first_name, :last_name, :role, :thesis_id) + params.require(:committee_member).permit(:first_name, :last_name, :role, :thesis_id, :gem_record_id) end end From e8c31b5faad86ae7a0212dadd19d950b55eac89f Mon Sep 17 00:00:00 2001 From: Ali Sadaqain <sadaqain@yorku.ca> Date: Wed, 17 Jul 2024 13:02:36 -0400 Subject: [PATCH 14/24] Add embargo upload to admin thesis show, remove embargo from student flow, add embargo to submit process step --- app/controllers/student_view_controller.rb | 3 + app/models/app_settings.rb | 6 + app/models/document.rb | 2 + .../documents/_new_embargo_form.html.erb | 52 ++++++++ app/views/documents/_new_form.html.erb | 2 +- .../settings/_student_submission.html.erb | 1 + .../student_view/process/review.html.erb | 8 +- .../student_view/process/submit.html.erb | 19 ++- .../student_view/process/upload.html.erb | 2 +- app/views/theses/show.html.erb | 119 +++++++++--------- test/system/theses_test.rb | 34 ++++- 11 files changed, 172 insertions(+), 76 deletions(-) create mode 100644 app/views/documents/_new_embargo_form.html.erb diff --git a/app/controllers/student_view_controller.rb b/app/controllers/student_view_controller.rb index 8be639c..25e91c3 100644 --- a/app/controllers/student_view_controller.rb +++ b/app/controllers/student_view_controller.rb @@ -46,10 +46,13 @@ def thesis_process_router when Thesis::PROCESS_REVIEW @primary_documents = @thesis.documents.not_deleted.primary @supplemental_documents = @thesis.documents.not_deleted.supplemental + @supplemental_licence_documents = @thesis.documents.not_deleted.supplemental.licence_type render_according_to_validation('student_view/process/review') when Thesis::PROCESS_SUBMIT @primary_documents = @thesis.documents.not_deleted.primary @supplemental_documents = @thesis.documents.not_deleted.supplemental + @supplemental_licence_documents = @thesis.documents.not_deleted.supplemental.licence_type + @supplemental_embargo_documents = @thesis.documents.not_deleted.supplemental.embargo_type render_according_to_validation('student_view/process/submit') when Thesis::PROCESS_STATUS render_according_to_validation('student_view/process/status') diff --git a/app/models/app_settings.rb b/app/models/app_settings.rb index baac95f..a662791 100644 --- a/app/models/app_settings.rb +++ b/app/models/app_settings.rb @@ -43,6 +43,12 @@ class AppSettings < RailsSettings::Base <li><strong>Video:</strong> 8-10 bit uncompressed AVI (.avi)</li> <li><strong>Audio:</strong> Free Lossless Audio Codec or WAVE (.flac or .wav)</li> </ul>' + field :student_supplementary_embargo_upload_files, default: '<p> Please Upload the following documents:</p> + <ul> + <li><strong>Supervisor Letter</strong></li> + <li><strong>Other Embargo Supporting Documents</strong></li> + <li><strong>Portable Document Format:</strong> (.pdf), Text (.txt), Hypertext Markup Language (.html, .htm), Open Document Format (.odt, .odp, .ods).</li> + </ul>' field :student_review_license_info, default: 'Please review the licences below, you must agree to all to proceed.' field :student_review_license_lac, default: 'LAC Licence is required. Please download the form (<a href="~//lib/assets/lac-non-exclusive-licence-en.pdf">lac-non-exclusive-licence-en.pdf</a>), sign it and upload it.' field :student_review_lac_licence_instructions, default: '<p class="fw-bold">Please download, sign and upload the LAC Licence file. You must upload the licence to proceed to next step</p> diff --git a/app/models/document.rb b/app/models/document.rb index 53ab748..30d9ff2 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -20,6 +20,8 @@ class Document < ApplicationRecord scope :supplemental, -> { where('supplemental = ? ', true) } scope :deleted, -> { where('deleted = ?', true) } scope :not_deleted, -> { where('deleted = ?', false) } + scope :licence_type, -> { where(usage: :licence) } + scope :embargo_type, -> { where(usage: [:embargo, :embargo_letter])} enum usage: %i[thesis embargo embargo_letter licence] diff --git a/app/views/documents/_new_embargo_form.html.erb b/app/views/documents/_new_embargo_form.html.erb new file mode 100644 index 0000000..96bb8e2 --- /dev/null +++ b/app/views/documents/_new_embargo_form.html.erb @@ -0,0 +1,52 @@ +<% primary = false if local_assigns[:primary].nil? %> +<div class="modal fade" id="<%= primary ? 'primary-file' : 'supplemental-embargo-files' %>" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <% if primary %> + <h1 class="modal-title fs-5" id="primary-file">Upload Primary File</h1> + <% else %> + <h1 class="modal-title fs-5" id="supplemental-files">Upload Supplementary File</h1> + <% end %> + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> + </div> + <%= simple_form_for [@student, @thesis, Document.new], html: { class: "document", multipart: true, id: "new_document_#{primary}" }, authenticity_token: true, remote: true do |f| %> + <div class="modal-body"> + <div class="alert alert-secondary" role="alert"> + <% if primary %> + <p>Your primary file should be in <strong>PDF format.</strong></p> + <% else %> + <% if "#{AppSettings.student_supplementary_embargo_upload_files}" != '' %> + <%= raw(AppSettings.student_supplementary_embargo_upload_files) %> + <% else %> + <p>File size must be limited to acceptable formats include:</p> + <ul> + <li><strong>Documents:</strong> Portable Document Format (.pdf), Text (.txt), Hypertext Markup Language (.html, .htm), Open Document Format (.odt, .odp, .ods).</li> + <li><strong>Images:</strong> Portable Network Graphics format (.png), Tagged Image File format (.tif), JPEG (.jpg)</li> + <li><strong>Data:</strong> Comma-separated values (.csv) or other delimited text, Extensible Markup Language (.xml)</li> + <li><strong>Video:</strong> 8-10 bit uncompressed AVI (.avi)</li> + <li><strong>Audio:</strong> Free Lossless Audio Codec or WAVE (.flac or .wav)</li> + </ul> + <% end %> + <% end %> + </div> + <% f.input :name, required: false, input_html: { class: "span4", autocomplete: "off"} %> + <%= f.input :file, required: true, as: :file %> + + <% if primary %> + <%= f.hidden_field :usage, value: :thesis %> + <%= f.hidden_field :supplemental, value: false %> + <% else %> + <%= f.input :usage, label: "Document type", collection: Document.usages.keys.map(&:to_sym).reject { |usage| usage == :licence or usage == :thesis }, required: true, label_html: { class: 'pt-2' } %> + <%= f.hidden_field :supplemental, value: true %> + <% end %> + + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> + <%= f.button :submit, "Upload", class: "btn btn-primary" %> + </div> + <% end %> + </div> + </div> +</div> \ No newline at end of file diff --git a/app/views/documents/_new_form.html.erb b/app/views/documents/_new_form.html.erb index 71c128d..6b2e0ad 100644 --- a/app/views/documents/_new_form.html.erb +++ b/app/views/documents/_new_form.html.erb @@ -37,7 +37,7 @@ <%= f.hidden_field :usage, value: :thesis %> <%= f.hidden_field :supplemental, value: false %> <% else %> - <%= f.input :usage, label: "Document type", collection: Document.usages.keys.map(&:to_sym).reject { |usage| usage == :licence }, required: true, label_html: { class: 'pt-2' } %> + <%= f.input :usage, label: "Document type", collection: Document.usages.keys.map(&:to_sym).reject { |usage| usage != :thesis }, required: true, label_html: { class: 'pt-2' } %> <%= f.hidden_field :supplemental, value: true %> <% end %> diff --git a/app/views/settings/_student_submission.html.erb b/app/views/settings/_student_submission.html.erb index d680738..f79f2fd 100644 --- a/app/views/settings/_student_submission.html.erb +++ b/app/views/settings/_student_submission.html.erb @@ -22,6 +22,7 @@ <div class="tab-pane fade" id="nav-upload" role="tabpanel" aria-labelledby="nav-upload-tab" tabindex="0"> <%= f.input :student_upload_files, as: :rich_text_area, label: "Upload files message", input_html: { rows: 20 } %> <%= f.input :student_supplementary_upload_files, as: :rich_text_area, label: "Supplementary Upload files message", input_html: { rows: 30 } %> + <%= f.input :student_supplementary_embargo_upload_files, as: :rich_text_area, label: "Supplementary Embargo Upload files message", input_html: { rows: 30 } %> </div> <div class="tab-pane fade" id="nav-review" role="tabpanel" aria-labelledby="nav-review-tab" tabindex="0"> <%= f.input :student_review_license_info, as: :rich_text_area, label: "Information", input_html: { rows: 20, class: "mb-4" } %> diff --git a/app/views/student_view/process/review.html.erb b/app/views/student_view/process/review.html.erb index e453f6f..a28a919 100644 --- a/app/views/student_view/process/review.html.erb +++ b/app/views/student_view/process/review.html.erb @@ -38,16 +38,14 @@ </li> <li class="list-group-item"> <p> - <% if @supplemental_documents.count == 0 %> + <% if @supplemental_licence_documents.count == 0 %> <p>There are no <strong>supplementary</strong> license files or documents attached to this thesis/dissertation.</p> <% end %> <% if AppSettings.student_review_lac_licence_instructions.present? %> <p><%= raw(AppSettings.student_review_lac_licence_instructions) %></p> <% end %> - <% @supplemental_documents.each do | document | %> - <% if document.usage == "licence" %> - <%= render partial: document %> - <% end %> + <% @supplemental_licence_documents.each do | document | %> + <%= render partial: document %> <% end %> <br/> <% unless block_thesis_changes?(@thesis) %> diff --git a/app/views/student_view/process/submit.html.erb b/app/views/student_view/process/submit.html.erb index df52a2f..f53851a 100644 --- a/app/views/student_view/process/submit.html.erb +++ b/app/views/student_view/process/submit.html.erb @@ -81,9 +81,9 @@ <% end %> <div class="mt-3"> - <h6>Supplementary</h6> + <h6>Supplementary Thesis Files</h6> <% @supplemental_documents.each do | document | %> - <% if document.usage != 'licence'%> + <% if document.usage == 'thesis'%> <%= render partial: document %> <% end %> <% end %> @@ -93,15 +93,22 @@ </div> <div class="mt-3"> <h6>License Agreements</h6> - <% @supplemental_documents.each do | document | %> - <% if document.usage == 'licence'%> + <% @supplemental_licence_documents.each do | document | %> <%= render partial: document %> - <% end %> <% end %> - <% if @supplemental_documents.count == 0 %> + <% if @supplemental_licence_documents.count == 0 %> <p>There are no <strong>supplementary licence</strong> files or documents attached to this thesis/dissertation.</p> <% end %> </div> + <div class="mt-3"> + <h6>Embargo Documents</h6> + <% @supplemental_embargo_documents.each do | document | %> + <%= render partial: document %> + <% end %> + <% if @supplemental_embargo_documents.count == 0 %> + <p>There are no <strong>embargo</strong> files or documents attached to this thesis/dissertation.</p> + <% end %> + </div> <div class="my-4"> <h4><%= Date.today.strftime("%B %d, %Y")%></h4> diff --git a/app/views/student_view/process/upload.html.erb b/app/views/student_view/process/upload.html.erb index f57d5b0..3e5d01c 100644 --- a/app/views/student_view/process/upload.html.erb +++ b/app/views/student_view/process/upload.html.erb @@ -48,7 +48,7 @@ <div class='mt-3'> <% @supplemental_documents.each do | document | %> - <% if document.usage != "licence" %> + <% if document.usage == "thesis" %> <%= render partial: document %> <% end %> <% end %> diff --git a/app/views/theses/show.html.erb b/app/views/theses/show.html.erb index 63494c3..5171604 100644 --- a/app/views/theses/show.html.erb +++ b/app/views/theses/show.html.erb @@ -43,47 +43,46 @@ <% end %> </div> </div> - </div> +</div> - <div class="row"> - <div class="col-12 pt-3"> - <h6>Abstract</h6> - <p><%= format @thesis.abstract, true %></p> - </div> - <div class="col-sm-12 col-md-4"> - - <h6>Supervisor</h6> - <p><%= @thesis.supervisor %></p> - <h6>Exam date</h6> - <p><%= @thesis.exam_date ? @thesis.exam_date.strftime("%B %d, %Y") : format(@thesis.exam_date) %></p> - - - </div> - <div class="col-sm-12 col-md-4"> +<div class="row"> + <div class="col-12 pt-3"> + <h6>Abstract</h6> + <p><%= format @thesis.abstract, true %></p> + </div> + <div class="col-sm-12 col-md-4"> + + <h6>Supervisor</h6> + <p><%= @thesis.supervisor %></p> + <h6>Exam date</h6> + <p><%= @thesis.exam_date ? @thesis.exam_date.strftime("%B %d, %Y") : format(@thesis.exam_date) %></p> - <h6>Examining committee</h6> - - <div class="committee_members" id="committee_members"> - <% @thesis.committee_members.each do |committee_member| %> - <%= render "committee_members/committee_member_read", committee_member: committee_member %> - <% end %> - </div> + + </div> + <div class="col-sm-12 col-md-4"> + + <h6>Examining committee</h6> - </div> + <div class="committee_members" id="committee_members"> + <% @thesis.committee_members.each do |committee_member| %> + <%= render "committee_members/committee_member_read", committee_member: committee_member %> + <% end %> + </div> + + </div> - <% if @thesis.returned_message.present? && Thesis::RETURNED == @thesis.status %> + <% if @thesis.returned_message.present? && Thesis::RETURNED == @thesis.status %> <div class="col-lg-4 col-sm-12"> - <h6>Returned message</h6> - <div class="alert alert-danger" role="alert"> - <%= @thesis.returned_message %> - </div> - <% else %> + <h6>Returned message</h6> + <div class="alert alert-danger" role="alert"> + <%= @thesis.returned_message %> + </div> + <% else %> <div class="col-lg-4 d-none d-lg-block"> - <% end %> + <% end %> </div> <div class="col-12"><hr /></div> - </div> - + </div> <div class="row"> <div class="col-4"> <h6>Publish On</h6> @@ -130,11 +129,11 @@ </div> <div class="row"> - <div class="col-12"><hr /></div> - <div class="col-3 span2 distinct strong"><h6>Last Under Review: </h6> <%= format @thesis.under_review_at %></div> - <div class="col-3 span2 distinct strong"><h6>Last Returned: </h6> <%= format @thesis.returned_at %></div> - <div class="col-3 span2 distinct strong"><h6>Thesis Accepted: </h6> <%= format @thesis.accepted_at %></span></div> - <div class="col-3 span2 distinct strong"><h6>Published: </h6> <%= format @thesis.published_at %></div> + <div class="col-12"><hr /></div> + <div class="col-3 span2 distinct strong"><h6>Last Under Review: </h6> <%= format @thesis.under_review_at %></div> + <div class="col-3 span2 distinct strong"><h6>Last Returned: </h6> <%= format @thesis.returned_at %></div> + <div class="col-3 span2 distinct strong"><h6>Thesis Accepted: </h6> <%= format @thesis.accepted_at %></span></div> + <div class="col-3 span2 distinct strong"><h6>Published: </h6> <%= format @thesis.published_at %></div> </div> <div class="row"> @@ -169,7 +168,7 @@ <div class='mt-3'> <% @supplemental_documents.each do | document | %> - <% if document.usage != "licence" %> + <% if document.usage == "thesis" %> <%= render partial: document %> <% end %> <% end %> @@ -194,6 +193,22 @@ <p>There are no <strong>supplementary</strong> licence files or documents attached to this thesis/dissertation.</p> <% end %> </div> + <div class='mt-4'> + <h6>Embargo Documents</h6> + <% unless block_thesis_changes?(@thesis) %> + <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#supplemental-embargo-files">Upload Embargo Files</button> + <% end %> + <% @supplemental_documents.each do | document | %> + <% if document.usage == 'embargo' or document.usage == 'embargo_letter'%> + <div class='embargo-file'> + <%= render partial: document %> + </div> + <% end %> + <% end %> + <% if @supplemental_documents.where(usage: [:embargo, :embargo_letter]).count == 0 %> + <p>There are no <strong>supplementary</strong> embargo files or documents attached to this thesis/dissertation.</p> + <% end %> + </div> <% else %> <h6>Primary</h5> <% @primary_documents.each do | document | %> @@ -204,7 +219,7 @@ <p>There is no <strong>primary</strong> file or document attached to this thesis/dissertation.</p> <% end %> <% @supplemental_documents.each do | document | %> - <%= render partial: document %> + <%= render partial: document %> <% end %> <% if @supplemental_documents.where(usage: :licence).count == 0 %> <p>There are no <strong>supplementary</strong> licence files or documents attached to this thesis/dissertation.</p> @@ -220,27 +235,7 @@ <%= render partial: "documents/new_form", locals: { primary: false } %> <%= render partial: "documents/new_licence_form", locals: { primary: false } %> - <!-- - <h6>Primary</h6> - <% @primary_documents.each do | document | %> - <%= render partial: document %> - <% end %> - - <% if @primary_documents.count == 0 %> - <p>There are no <strong>primary</strong> files or documents attached to this thesis.</p> - <% end %> + <%= render partial: "documents/new_embargo_form", locals: { primary: false } %> - - <h6>Supplemental</h6> - <% @supplemental_documents.each do | document | %> - <%= render partial: document %> - <% end %> - <% if @supplemental_documents.count == 0 %> - <p>There are no <strong>supplemental</strong> files or documents attached to this thesis.</p> - <% end %> - --> - </div> - </div> - - \ No newline at end of file +<!-- </div> HTML structure is someone broken of divs. I need to review when working on GUI over hall.--> \ No newline at end of file diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index 6af793f..ee8e87d 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -58,6 +58,8 @@ class ThesesTest < ApplicationSystemTestCase assert_selector 'p', text: 'This thesis has been placed under permanent embargo. It will not be published.' end + #### FILE UPLOADS FROM BACKEND ##### + should "be able to upload primary document by admin/staff" do visit root_url click_link(@thesis_01.title) @@ -81,15 +83,20 @@ class ThesesTest < ApplicationSystemTestCase select "Supplementary file or document attached to thesis/dissertation", from: 'Document type' #document_usage click_button('Upload') assert_selector(".supplemental", text: /Supplemental/) #Supplemental + end + ########################################################### + ##### TESTS WILL NEED BE UPDATED WITH NEW FILE NAMES ###### + ########################################################### + should "be able to upload supplementary license document by admin/staff" do visit root_url click_link(@thesis_01.title) click_on("Upload Licence Files") assert_selector "h1", text: "Upload Supplementary Licence File", visible: :all - attach_file("document_file", Rails.root.join('test/fixtures/files/pdf-document.pdf')) + attach_file("document_file", Rails.root.join('test/fixtures/files/image-example.jpg')) # page.driver.browser.manage.window.resize_to(1920, 2500) # save_screenshot() click_button('Upload') @@ -97,5 +104,30 @@ class ThesesTest < ApplicationSystemTestCase end + should "be able to upload supplementary embargo document [Request for embargo document] by admin/staff" do + visit root_url + click_link(@thesis_01.title) + + page.driver.browser.manage.window.resize_to(1920, 2500) + click_on("Upload Embargo Files") + assert_selector "h1", text: "Upload Supplementary File", visible: :all + attach_file("document_file", Rails.root.join('test/fixtures/files/papyrus-feature.png')) + + assert_selector "select#document_usage" + select "Request for embargo document", from: 'Document type' #document_usage + + click_button('Upload') + + ## NOTE TO SELF, CHECK HERE FOR EMBARGO SPECIFIC + # assert_selector(".supplemental", text: /Supplemental/) #Supplemental + assert_not_empty find('.embargo-file').text, "The .embargo-file element is empty, no file" + + # Take a screenshot + save_screenshot('screenshot_with_dropdown.png') + end + + ########################################################### + ################## END OF FILE UPLOADS #################### + ########################################################### end From 944a32bc5397454bb6e96971f75f2eba6648b6d7 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen <amtuannguyen@gmail.com> Date: Wed, 17 Jul 2024 19:18:11 -0400 Subject: [PATCH 15/24] add committee members belongs to gem record association --- app/models/committee_member.rb | 1 + app/models/gem_record.rb | 2 ++ ..._add_gem_record_id_to_committee_members.rb | 5 +++ db/schema.rb | 3 +- lib/dummy_gem_records.csv | 4 --- lib/tasks/load_gem_records_csv.rb | 33 +++++++++++-------- test/fixtures/files/committee_members.csv | 7 ++++ test/fixtures/files/gem_records.csv | 4 +++ test/lib/load_gem_records_test.rb | 5 ++- 9 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb delete mode 100644 lib/dummy_gem_records.csv create mode 100644 test/fixtures/files/committee_members.csv create mode 100644 test/fixtures/files/gem_records.csv diff --git a/app/models/committee_member.rb b/app/models/committee_member.rb index 3c755b3..91ebd7a 100644 --- a/app/models/committee_member.rb +++ b/app/models/committee_member.rb @@ -13,6 +13,7 @@ class CommitteeMember < ApplicationRecord ## RELATIONS ## belongs_to :thesis + belongs_to :gem_record ## VALIDATIONS ## validates_presence_of :first_name, message: 'Please choose a name.' diff --git a/app/models/gem_record.rb b/app/models/gem_record.rb index baba38b..87d02c9 100644 --- a/app/models/gem_record.rb +++ b/app/models/gem_record.rb @@ -14,6 +14,8 @@ class GemRecord < ApplicationRecord MASTERS_EXAM = "Master's Thesis Exam" ACCEPTED = 'Accepted' + has_many :committee_members + scope :completed, lambda { where('eventtype = ? OR eventtype = ?', GemRecord::PHD_COMPLETED, GemRecord::MASTERS_COMPLETED) } diff --git a/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb b/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb new file mode 100644 index 0000000..18508fb --- /dev/null +++ b/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb @@ -0,0 +1,5 @@ +class AddGemRecordIdToCommitteeMembers < ActiveRecord::Migration[7.0] + def change + add_column :committee_members, :gem_record_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index ac53eec..d36be1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_11_142734) do +ActiveRecord::Schema[7.0].define(version: 2024_07_17_225736) do create_table "action_text_rich_texts", charset: "utf8mb3", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long @@ -79,6 +79,7 @@ t.datetime "updated_at", precision: nil, null: false t.string "first_name" t.string "last_name" + t.integer "gem_record_id" end create_table "delayed_jobs", id: :integer, charset: "utf8mb3", force: :cascade do |t| diff --git a/lib/dummy_gem_records.csv b/lib/dummy_gem_records.csv deleted file mode 100644 index 55aaebc..0000000 --- a/lib/dummy_gem_records.csv +++ /dev/null @@ -1,4 +0,0 @@ -seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate,committee_members -1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01,"John,Smith,Chair;Jane,Doe,Committee Member" -2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02,"Jim,Brown,Chair;Jake,White,Committee Member" -3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03, "Eve Green:Chair,Frank Black:Committee Member" \ No newline at end of file diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index 204569a..1ee16dc 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true ## -# Function to load gem records from a text file, delimited by __ETD_COLSEP__ +# Function to load gem records from a CSV file ## require 'csv' class LoadGemRecordsCSV - def load_csv(filename) + def load_gem_records(filename) count = 0 - CSV.foreach(filename, headers: true) do |row| + converter = lambda { |header| header.downcase } + CSV.foreach(filename, headers: true, header_converters: converter) do |row| seqgradevent = row['seqgradevent'].strip unless GemRecord.find_by_seqgradevent(seqgradevent) gr = GemRecord.new @@ -28,17 +29,6 @@ def load_csv(filename) gr.examdate = row['examdate'].strip if gr.save!(validate: false) - committee_members = row['committee_members'].split(';') - committee_members.each do |member| - first_name, last_name, role = member.split(',') - CommitteeMember.create!( - gem_record: gr, - first_name: first_name.strip, - last_name: last_name.strip, - role: role.strip - ) - end - count += 1 else warn('Error: Load Gem Records Save Failed!') @@ -49,6 +39,21 @@ def load_csv(filename) warn("ERROR: #{e}") warn('Hint: Possible Bad File if strip nil') end + end + + def load_committee_members(filename) + count = 0 + converter = lambda { |header| header.downcase } + CSV.foreach(filename, headers: true, header_converters: converter) do |row| + seqgradevent = row['seqgradevent'].strip + gr = GemRecord.find_by_seqgradevent(seqgradevent) + cm = CommitteeMember.new + cm.gem_record = gr + cm.first_name = row['firstname'].strip + cm.last_name = row['surname'].strip + cm.role = row['role'].strip + cm.save! + end end end diff --git a/test/fixtures/files/committee_members.csv b/test/fixtures/files/committee_members.csv new file mode 100644 index 0000000..edc6928 --- /dev/null +++ b/test/fixtures/files/committee_members.csv @@ -0,0 +1,7 @@ +"SEQGRADEVENT","SISID","FIRSTNAME","SURNAME","ROLE" +1,12345,"John","Smith","Chair" +1,12345,"Jane","Doe","Committee Member" +2,654321,"Jim","Brown","Chair" +2,654321,"Jake","White","Committee Member" +3,789012,"Eve","Green","Chair" +3,789012,"Frank","Black","Committee Member" diff --git a/test/fixtures/files/gem_records.csv b/test/fixtures/files/gem_records.csv new file mode 100644 index 0000000..6b3c2f0 --- /dev/null +++ b/test/fixtures/files/gem_records.csv @@ -0,0 +1,4 @@ +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file diff --git a/test/lib/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb index 26d5874..9bbfd55 100644 --- a/test/lib/load_gem_records_test.rb +++ b/test/lib/load_gem_records_test.rb @@ -4,12 +4,11 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('lib/dummy_gem_records.csv') + gem_load.load_gem_records("test/fixtures/files/gem_records.csv") + gem_load.load_committee_members("test/fixtures/files/committee_members.csv") end should "parse csv" do - puts "\nRunning test..." - assert_equal 3, GemRecord.count records = GemRecord.order(:seqgradevent) From f6265c88f385115406705a646f6194690dd17090 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen <amtuannguyen@gmail.com> Date: Wed, 17 Jul 2024 21:38:57 -0400 Subject: [PATCH 16/24] increase Capybara max wait time and use headless chrome --- test/application_system_test_case.rb | 2 +- test/test_helper.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index ba34155..81ba0a1 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -3,7 +3,7 @@ require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400], options: { browser: :remote, url: "http://#{ENV.fetch('SELENIUM_SERVER')}:4444" } diff --git a/test/test_helper.rb b/test/test_helper.rb index 812ca9c..cc7a0d7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,6 +24,7 @@ Capybara.server_host = '0.0.0.0' Capybara.app_host = "http://#{Socket.gethostname}:#{Capybara.server_port}" +Capybara.default_max_wait_time = 5 include ActionDispatch::TestProcess From d784bd98e380ef334a9c7cca4793944ae76d9335 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen <amtuannguyen@gmail.com> Date: Wed, 17 Jul 2024 21:38:57 -0400 Subject: [PATCH 17/24] increase Capybara max wait time and use headless chrome --- test/application_system_test_case.rb | 2 +- test/test_helper.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index ba34155..81ba0a1 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -3,7 +3,7 @@ require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400], options: { browser: :remote, url: "http://#{ENV.fetch('SELENIUM_SERVER')}:4444" } diff --git a/test/test_helper.rb b/test/test_helper.rb index 812ca9c..cc7a0d7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,6 +24,7 @@ Capybara.server_host = '0.0.0.0' Capybara.app_host = "http://#{Socket.gethostname}:#{Capybara.server_port}" +Capybara.default_max_wait_time = 5 include ActionDispatch::TestProcess From c93eac1280c2c1161d53eb4df4c5f286a0cf69ce Mon Sep 17 00:00:00 2001 From: Tuan Nguyen <amtuannguyen@gmail.com> Date: Wed, 17 Jul 2024 22:17:24 -0400 Subject: [PATCH 18/24] require 'helpers/system_test_helper' --- test/system/students_test.rb | 5 +---- test/system/theses_test.rb | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 28b80e8..ddd48da 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' -require_relative '../helpers/system_test_helper' +require 'helpers/system_test_helper' class StudentsTest < ApplicationSystemTestCase include SystemTestHelper # Include the SystemTestHelper module here @@ -26,11 +26,8 @@ class StudentsTest < ApplicationSystemTestCase visit root_url fill_in('Non-YorkU Email Address', with: Faker::Internet.email) click_button('Continue') - puts "\nGoing to Update Details\n" click_link('Continue') #update - puts "Going to Upload\n" click_link('Continue') #upload - puts "Going to Review\n" click_link('Continue') #review assert_selector '.alert-warning', text: 'Error: You have to upload a primary file to continue' # page.accept_alert diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index ee8e87d..22bcc0e 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' +require 'helpers/system_test_helper' class ThesesTest < ApplicationSystemTestCase setup do From 7d483a52ca51916f7fd1c1b83854fc6f18a5c810 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen <amtuannguyen@gmail.com> Date: Wed, 17 Jul 2024 22:17:24 -0400 Subject: [PATCH 19/24] require 'helpers/system_test_helper' --- test/system/students_test.rb | 5 +---- test/system/theses_test.rb | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 28b80e8..ddd48da 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' -require_relative '../helpers/system_test_helper' +require 'helpers/system_test_helper' class StudentsTest < ApplicationSystemTestCase include SystemTestHelper # Include the SystemTestHelper module here @@ -26,11 +26,8 @@ class StudentsTest < ApplicationSystemTestCase visit root_url fill_in('Non-YorkU Email Address', with: Faker::Internet.email) click_button('Continue') - puts "\nGoing to Update Details\n" click_link('Continue') #update - puts "Going to Upload\n" click_link('Continue') #upload - puts "Going to Review\n" click_link('Continue') #review assert_selector '.alert-warning', text: 'Error: You have to upload a primary file to continue' # page.accept_alert diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index c3b1816..c9650be 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' +require 'helpers/system_test_helper' class ThesesTest < ApplicationSystemTestCase setup do From 7b5e675fc213d870675215b652f1b2d52baa6f6b Mon Sep 17 00:00:00 2001 From: Ali Sadaqain <sadaqain@yorku.ca> Date: Thu, 18 Jul 2024 11:17:59 -0400 Subject: [PATCH 20/24] Yorkify init. Only bootstrap colors with YU, no structure changes --- .../bootstrap_and_overrides.css.scss | 161 +++++++++++++++++- app/views/layouts/application.html.erb | 2 +- 2 files changed, 155 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.scss b/app/assets/stylesheets/bootstrap_and_overrides.css.scss index 902b862..79e3aee 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.scss +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.scss @@ -1,11 +1,158 @@ +/************************/ +/*** YORKU CSS START ***/ +/************************/ +// Import Bootstrap's default functions first +// then add your custom variables +// then import variables, mixins +// then import bootstrap +// then add your custom css + +@import "bootstrap/functions"; + +//YorkU Colors +/* 2021 YorkU colours */ +/* http://toolbox.info.yorku.ca/visual-identity/colours/ */ +$york-grey-dark: #686260; +$york-grey-medium: #B7AEA9; +$york-grey-pewter: #D6CFCA; +$york-grey-light: #E8E4DF; +$york-grey-lighter: #FAFAFA; +$york-red-pms-186: #E31837; +$york-red-medium: #B82025; +$york-red-dark: #8C0000; +$york-light-blue: #ACE6F8; +$york-bright-blue: #3AC2EF; + +// Custom theme colors +$primary: $york-red-pms-186; +$secondary: $york-grey-dark; +$success: #2e8540 !default; //#35B01C !default; //$green !default; $success: #3AC2EF; +$info: darken($york-light-blue, 50%); +$warning: #ffc107; +$danger: $york-red-medium; +$light: $york-grey-lighter; +$dark: $york-grey-dark; + +// Additional custom styles +$border-radius: .25rem; +$btn-border-radius: .25rem; +$btn-padding-y: .5rem; +$btn-padding-x: 1rem; +$btn-font-weight: 400; + +$theme-colors: ( + 'primary': $primary, + 'secondary': $secondary, + 'success': $success, + 'info': $info, + 'warning': $warning, + 'danger': $danger, + 'light': $light, + 'dark': $dark, +); + +$yorku-colors: ( + 'york-grey-dark': $york-grey-dark, + 'york-grey-medium': $york-grey-medium, + 'york-grey-pewter': $york-grey-pewter, + 'york-grey-light': $york-grey-light, + 'york-grey-lighter': $york-grey-lighter, + 'york-red-pms-186': $york-red-pms-186, + 'york-red-medium': $york-red-medium, + 'york-red-dark': $york-red-dark, + 'york-light-blue': $york-light-blue, + 'york-bright-blue': $york-bright-blue +); + +// Merge the maps +$theme-colors: map-merge($theme-colors, $yorku-colors); +$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value"); + + +@import "bootstrap/variables"; +@import "bootstrap/mixins"; @import "bootstrap"; -$color_h6: #d2452a; -$color_h6_green: #009900; -h6 { - color: $color_h6; + +// Headings customization +.container { + + h1, .h1 { + color: $black; + font-weight: 700; + } + + h2, .h2 { + color: $primary; + font-weight: 600; + } + + h3, .h3 { + color: darken($info, 30%); + font-weight: 500; + text-transform: uppercase; + } + + h4, .h4, h5, .h5, h6, .h6 { + color: $secondary; + font-weight: 400; + } + + // Subheadings customization + .subheading { + color: $secondary; + font-weight: 300; + font-size: 1.25rem; // Adjust as needed + } +} +// Key-Value pairs in forms +.dl-horizontal dt { + font-weight: 500; + color: $primary; } -h6.green{ - color: $color_h6_green; - border-bottom: 1px solid rgb(228, 228, 228); +.dl-horizontal dd { + color: $secondary; +} + +.page-header { + margin-bottom: 10px; +} +.student-view { + margin-top: 10px; +} + +// Custom styles can go here, if needed +.record-data { + margin-top: 10px; + margin-bottom: 10px; + tr { + td:nth-child(1) { + @extend .lead; + // font-size: $small-font-size; + font-size: 1rem; + color: $secondary; + } + td:nth-child(2) { + // color: $secondary; + font-weight: 600; + } + } +} + +.simple_form { + // background-color: lighten($york-grey-pewter, 8%); + // background-color: $york-grey-pewter; + background-color: $light; + padding: 0.875rem; +} +.simple_form .form-control { + font-size: 1.1rem; + margin-bottom: 10px; +} +.simple_form .form-text { + margin-bottom: 0.25rem; +} +.container section { + padding-top: 15px; + padding-bottom: 15px; } \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fd987bb..de85b1a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,7 @@ </div> <% end %> <div class="container my-3"> - <div class="row align-items-center shadow-lg rounded-3 border"> + <div class="row align-items-center shadow-lg rounded-3 border p-3"> <div class="container"> <div class="york_header"> <%= image_tag("yorklogo.gif", alt: "York University - Graduate Studies" )%> From adea9744b2040fd2a8fdb2e816421bf2aa0af618 Mon Sep 17 00:00:00 2001 From: Ali Sadaqain <sadaqain@yorku.ca> Date: Thu, 18 Jul 2024 14:46:09 -0400 Subject: [PATCH 21/24] Issue was CSS changed H3 to uppercase but system test was looking for sentence case. Updated systests --- test/system/students_test.rb | 8 +++++--- test/system/theses_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index ddd48da..5437e77 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -39,7 +39,7 @@ class StudentsTest < ApplicationSystemTestCase login_as(@thesis.student) visit root_url click_link("My ETD Submission") - assert_selector "h3", text: "Hello #{@thesis.student.first_name}" + assert_text(/#{Regexp.escape("Hello #{@thesis.student.first_name}")}/i) assert_selector "h6", text: "Email", visible: :all assert_selector "p", text: "#{@thesis.student.email}", visible: :all end @@ -49,7 +49,7 @@ class StudentsTest < ApplicationSystemTestCase login_as(@thesis.student) visit root_url click_link("My ETD Submission") - assert_selector "h3", text: "Hello #{@thesis.student.first_name}" + assert_text(/#{Regexp.escape("Hello #{@thesis.student.first_name}")}/i) assert_no_selector "input#student_first_name" assert_no_selector "input#student_middle_name" assert_no_selector "input#student_last_name" @@ -159,7 +159,9 @@ class StudentsTest < ApplicationSystemTestCase ## Page 4 - assert_text "LAC Supplementary Licence File Upload" + # assert_text "LAC Supplementary Licence File Upload".upcase + assert_text(/#{Regexp.escape("LAC Supplementary Licence File Upload")}/i) + # Initially, checkboxes should be disabled if not checked assert page.has_unchecked_field?('thesis_yorkspace_licence_agreement', disabled: true) diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index 22bcc0e..6643663 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -22,11 +22,11 @@ class ThesesTest < ApplicationSystemTestCase test 'Check thesis Under review and Overview on nav-tabs' do visit root_url - assert_selector 'h3', text: @thesis_01.title + assert_selector 'h3', text: (/#{Regexp.escape("#{@thesis_01.title}")}/i) click_link(@thesis_01.title) click_link('Overview') click_link('Under Review') - assert_selector 'h3', text: @thesis_02.title + assert_selector 'h3', text: (/#{Regexp.escape("#{@thesis_02.title}")}/i) click_link(@thesis_02.title) end From 54e9bab0e8f3a242feaa3382b217c4e372ab6eac Mon Sep 17 00:00:00 2001 From: DevAdm <libadm@lb-sc-s2b439.library.yorku.ca> Date: Thu, 18 Jul 2024 17:32:41 -0400 Subject: [PATCH 22/24] assigning committee members to gem record + thesis --- app/controllers/theses_controller.rb | 37 +++++++++++++------ .../_committee_member.html.erb | 13 +++++-- lib/tasks/gem_records_csv.rake | 17 ++++++--- test/controllers/theses_controller_test.rb | 9 +++-- test/fixtures/files/gem_records.csv | 6 +-- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/app/controllers/theses_controller.rb b/app/controllers/theses_controller.rb index a36a20d..4ca146d 100644 --- a/app/controllers/theses_controller.rb +++ b/app/controllers/theses_controller.rb @@ -45,6 +45,8 @@ def new @thesis.exam_date = record.examdate @thesis.program = record.program @thesis.assign_degree_name_and_level + @thesis.committee_members = record.committee_members + end def create @@ -53,8 +55,19 @@ def create @thesis.student = @student @thesis.audit_comment = 'Starting a new thesis. Status: OPEN.' + @thesis.audit_comment = 'Starting a new thesis. Status: OPEN.' + @thesis.status = Thesis::OPEN if @thesis.save + + if params[:committee_member_ids].present? + params[:committee_member_ids].each do |committee_member_id| + if committee_member_id.present? + committee_member = CommitteeMember.find(committee_member_id) + committee_member.update(thesis: @thesis) + end + end + end redirect_to [@student, @thesis], notice: 'ETD record successfully created.' else render action: 'new' @@ -149,10 +162,10 @@ def validate_active_thesis(thesis_id) def submit_for_review @thesis = @student.theses.find(params[:id]) @thesis.current_user = current_user - + # Temporarily assign the attributes for validation @thesis.assign_attributes(thesis_params) - + if @thesis.valid?(:submit_for_review) if @thesis.update(thesis_params) if validate_active_thesis(@thesis.id) @@ -178,33 +191,33 @@ def validate_licence_uplaod(thesis_id) def accept_licences @thesis = @student.theses.find(params[:id]) @thesis.current_user = current_user - + # Temporarily assign the attributes for validation @thesis.assign_attributes(thesis_params) @thesis.pretty_inspect - + if @thesis.valid?(:accept_licences) - + if @thesis.update(thesis_params) - + if validate_licence_uplaod(@thesis.id) - + redirect_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_SUBMIT), notice: "Updated status to #{Thesis::STATUS_ACTIONS[@thesis.status]}" else - + redirect_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_REVIEW), alert: 'Missing Licence Document. Please upload LAC Licence Signed Doc.' end else - + error_messages = @thesis.errors.full_messages.join(', ') redirect_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_REVIEW), alert: "There was an error submitting your thesis: #{error_messages}." end else - + error_messages = @thesis.errors.full_messages.join(', ') redirect_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_REVIEW), alert: "There was an error submitting your thesis: #{error_messages}." end - + end ### THESIS ASSIGNMENT TO USERS ### @@ -241,7 +254,7 @@ def thesis_params :keywords, :embargo, :language, :degree_name, :degree_level, :program, :published_date, :exam_date, :student_id, :committee, :abstract, :assigned_to_id, :assigned_to, :student_accepted_terms_at, :under_review_at, :accepted_at, :published_at, :returned_at, - :committee_members_attributes, :embargoed, :certify_content_correct, :lac_licence_agreement, + :committee_members_attributes, :embargoed, :certify_content_correct, :lac_licence_agreement, :yorkspace_licence_agreement, :etd_licence_agreement, committee_members_attributes: %i[first_name last_name role id _destroy], loc_subject_ids: []) diff --git a/app/views/committee_members/_committee_member.html.erb b/app/views/committee_members/_committee_member.html.erb index 5e3abb8..69607b4 100644 --- a/app/views/committee_members/_committee_member.html.erb +++ b/app/views/committee_members/_committee_member.html.erb @@ -2,9 +2,16 @@ <div class="col"><span class="fw-bold"><%= committee_member.name %></span></div> <div class="col"><%= committee_member.role %></div> <div class="col-1"> - <% if can?(:destroy, committee_member) && @thesis.status != Thesis::PUBLISHED %> - <%= link_to student_thesis_committee_member_path(@student, @thesis, committee_member), - method: :delete, class: "btn btn-close pull-right", remote: true, data: { confirm: "Are you sure?" } do %> <% end %> + <% if @thesis.id && %> + <% if can?(:destroy, committee_member) && @thesis.status != Thesis::PUBLISHED %> + <%= link_to student_thesis_committee_member_path(@student, @thesis, committee_member), + method: :delete, class: "btn btn-close pull-right", remote: true, data: { confirm: "Are you sure?" } do %> <% end %> + <% end %> + <% else %> + <%= hidden_field_tag "committee_member_ids[]", committee_member.id %> + <a href="#" class="btn btn-close pull-right" onclick="this.closest('.row').remove(); return false;" data-confirm="Are you sure?" rel="nofollow" data-remote="true"> + + </a> <% end %> </div> </div> diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake index 0474dfa..063dfef 100644 --- a/lib/tasks/gem_records_csv.rake +++ b/lib/tasks/gem_records_csv.rake @@ -6,14 +6,19 @@ namespace :gem_records_csv do desc 'Loading Gem Records.' # Usage: cat /file/with/gem_records.txt | rake gem_records:load - task :load, [:filename] => :environment do |t, args| - filename = args[:filename] - if filename.nil? || filename.empty? - puts "Error: Filename is required" + task :load, [:gem_record_file, :commitee_member_file] => :environment do |t, args| + gem_record_filename = Rails.root.join(args[:gem_record_file]) + commitee_member_file = Rails.root.join(args[:commitee_member_file]) + if gem_record_filename.nil? || gem_record_filename.empty? + puts "Error: Gem Record Filename is required" exit 1 end - GemRecord.delete_all + #GemRecord.delete_all gem_load = LoadGemRecordsCSV.new - gem_load.load_csv(filename) + gem_load.load_gem_records(gem_record_filename) + if !commitee_member_file.nil? || !commitee_member_file.empty? + gem_load.load_committee_members(commitee_member_file) + end + end end diff --git a/test/controllers/theses_controller_test.rb b/test/controllers/theses_controller_test.rb index a63598e..7b61e92 100644 --- a/test/controllers/theses_controller_test.rb +++ b/test/controllers/theses_controller_test.rb @@ -85,6 +85,7 @@ class ThesesControllerTest < ActionController::TestCase thesis = assigns(:thesis) assert thesis, 'ensure that thesis is assigned' + assert_equal record.committee_members.count, thesis.committee_members.count, 'Number of committee members should match' assert_equal record.title, thesis.title, 'Title should be prepopulated' assert_equal record.examdate.beginning_of_day, thesis.exam_date.beginning_of_day, 'Exam date is prepopulate with event date' @@ -421,12 +422,12 @@ class ThesesControllerTest < ActionController::TestCase @thesis.update(certify_content_correct: false) post :submit_for_review, params: { id: @thesis.id, student_id: @student.id, thesis: { certify_content_correct: false } } - + assigns(:thesis) assert_response :redirect assert_redirected_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_SUBMIT) assert_equal "There was an error submitting your thesis: Certify content correct can't be blank.", flash[:alert] - + end ## LICENCE UPLOAD CHECK @@ -435,8 +436,8 @@ class ThesesControllerTest < ActionController::TestCase patch :accept_licences, params: { student_id: @student.id, id: @thesis.id, thesis: { lac_licence_agreement: true, yorkspace_licence_agreement: true, etd_licence_agreement: true } } assert_redirected_to student_view_thesis_process_path(@thesis, Thesis::PROCESS_REVIEW) assert_equal 'Missing Licence Document. Please upload LAC Licence Signed Doc.', flash[:alert] - end - + end + should "should accept licences with a licence document" do # thesis = create(:thesis, student: @student) # create(:document, thesis: @thesis, user: @student, usage: 'licence', supplemental: true, deleted: false) diff --git a/test/fixtures/files/gem_records.csv b/test/fixtures/files/gem_records.csv index 6b3c2f0..58f6717 100644 --- a/test/fixtures/files/gem_records.csv +++ b/test/fixtures/files/gem_records.csv @@ -1,4 +1,4 @@ seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate -1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 -2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 -3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file +1,John Doe,123456789,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 +2,Jane Smith,654321476,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 +3,Alice Johnson,789012185,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file From e44a6ef69d735aabc9ff46a2d868eb074948f65b Mon Sep 17 00:00:00 2001 From: dennis <dennis.deli@nownpos.com> Date: Fri, 19 Jul 2024 11:39:09 -0400 Subject: [PATCH 23/24] fixed sisid in test and added test --- app/controllers/theses_controller.rb | 1 - test/controllers/theses_controller_test.rb | 4 ++++ test/lib/load_gem_records_test.rb | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/theses_controller.rb b/app/controllers/theses_controller.rb index 4ca146d..9954451 100644 --- a/app/controllers/theses_controller.rb +++ b/app/controllers/theses_controller.rb @@ -59,7 +59,6 @@ def create @thesis.status = Thesis::OPEN if @thesis.save - if params[:committee_member_ids].present? params[:committee_member_ids].each do |committee_member_id| if committee_member_id.present? diff --git a/test/controllers/theses_controller_test.rb b/test/controllers/theses_controller_test.rb index 7b61e92..64d7cd9 100644 --- a/test/controllers/theses_controller_test.rb +++ b/test/controllers/theses_controller_test.rb @@ -86,6 +86,10 @@ class ThesesControllerTest < ActionController::TestCase assert thesis, 'ensure that thesis is assigned' assert_equal record.committee_members.count, thesis.committee_members.count, 'Number of committee members should match' + record.committee_members.each do |record_member| + thesis_member = thesis.committee_members.find { |tm| tm.first_name == record_member.first_name && tm.last_name == record_member.last_name && tm.role == record_member.role } + assert thesis_member, "Committee member #{record_member.first_name} #{record_member.last_name} should be present in the thesis" + end assert_equal record.title, thesis.title, 'Title should be prepopulated' assert_equal record.examdate.beginning_of_day, thesis.exam_date.beginning_of_day, 'Exam date is prepopulate with event date' diff --git a/test/lib/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb index 9bbfd55..7182ff7 100644 --- a/test/lib/load_gem_records_test.rb +++ b/test/lib/load_gem_records_test.rb @@ -15,17 +15,17 @@ class LoadGemRecordsTest < ActiveSupport::TestCase assert_equal 1, records[0].seqgradevent assert_equal 'John Doe', records[0].studentname - assert_equal 123456, records[0].sisid + assert_equal 123456789, records[0].sisid assert_equal 'johndoe@example.com', records[0].emailaddress assert_equal 2, records[1].seqgradevent assert_equal 'Jane Smith', records[1].studentname - assert_equal 654321, records[1].sisid + assert_equal 654321476, records[1].sisid assert_equal 'janesmith@example.com', records[1].emailaddress assert_equal 3, records[2].seqgradevent assert_equal 'Alice Johnson', records[2].studentname - assert_equal 789012, records[2].sisid + assert_equal 789012185, records[2].sisid assert_equal 'alicejohnson@example.com', records[2].emailaddress assert_equal 2, records[0].committee_members.count From bc8e15e68543888d603efb8d54f646f3e86736b4 Mon Sep 17 00:00:00 2001 From: dennis <dennis.deli@nownpos.com> Date: Fri, 19 Jul 2024 12:47:11 -0400 Subject: [PATCH 24/24] added committee members to gem record view --- app/views/gem_records/_gem_record.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/gem_records/_gem_record.html.erb b/app/views/gem_records/_gem_record.html.erb index a6d9e74..666dd02 100644 --- a/app/views/gem_records/_gem_record.html.erb +++ b/app/views/gem_records/_gem_record.html.erb @@ -24,6 +24,12 @@ <p><%= gem_record.eventtype%></p> <h6>Program</h6> <p><%= gem_record.program %></p> + <h6>Committee Members</h6> + <% gem_record.committee_members.each do |committee_member| %> + <div class="row" id="committee_member_<%= committee_member.id %>"> + <div class="col"><%= committee_member.name %> - <%= committee_member.role %></div> + </div> + <% end %> </div> <div class="col-4"> <h6>Event date</h6>