Skip to content

Commit

Permalink
Add embargo upload to admin thesis show, remove embargo from student …
Browse files Browse the repository at this point in the history
…flow, add embargo to submit process step
  • Loading branch information
asadaqain committed Jul 17, 2024
1 parent a5a9b1e commit e8c31b5
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 76 deletions.
3 changes: 3 additions & 0 deletions app/controllers/student_view_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 6 additions & 0 deletions app/models/app_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
52 changes: 52 additions & 0 deletions app/views/documents/_new_embargo_form.html.erb
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion app/views/documents/_new_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down
1 change: 1 addition & 0 deletions app/views/settings/_student_submission.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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" } %>
Expand Down
8 changes: 3 additions & 5 deletions app/views/student_view/process/review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>
Expand Down
19 changes: 13 additions & 6 deletions app/views/student_view/process/submit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion app/views/student_view/process/upload.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
119 changes: 57 additions & 62 deletions app/views/theses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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 %>
Expand All @@ -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 | %>
Expand All @@ -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>
Expand All @@ -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>


<!-- </div> HTML structure is someone broken of divs. I need to review when working on GUI over hall.-->
Loading

0 comments on commit e8c31b5

Please sign in to comment.