Skip to content

Commit

Permalink
include changes from develop branch and fixed theses_test.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Jul 22, 2024
2 parents d21626d + b616177 commit 0f13471
Show file tree
Hide file tree
Showing 31 changed files with 717 additions and 134 deletions.
160 changes: 153 additions & 7 deletions app/assets/stylesheets/bootstrap_and_overrides.css.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,157 @@
/************************/
/*** 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;
}

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;
}
2 changes: 1 addition & 1 deletion app/controllers/committee_members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
36 changes: 24 additions & 12 deletions app/controllers/theses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,8 +55,18 @@ 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'
Expand Down Expand Up @@ -149,10 +161,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)
Expand All @@ -178,33 +190,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 ###
Expand Down Expand Up @@ -241,7 +253,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: [])
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
1 change: 1 addition & 0 deletions app/models/committee_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
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
2 changes: 2 additions & 0 deletions app/models/gem_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 10 additions & 3 deletions app/views/committee_members/_committee_member.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>&nbsp;<% 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 %>&nbsp;<% 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">
&nbsp;
</a>
<% end %>
</div>
</div>
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>
Loading

0 comments on commit 0f13471

Please sign in to comment.