Commit 9e5c3c54 authored by Taico Aerts's avatar Taico Aerts
Browse files

Merge branch 'development' into 'master'

Project Forum Release v2.7.0 - 13-06-2022

See merge request eip/bepsys/bepsys2!730
parents 24b84c29 e04564cd
......@@ -228,6 +228,13 @@ build-branch:
variables:
DB_TYPE: sqlite
RAILS_ENV: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# avoid starting detached merge request pipeline (they are enabled by default when overriding "rules")
when: never
- if: $CI_COMMIT_BRANCH != "master"
allow_failure: true
- when: on_success
before_script:
- bundle config --local path /projectforum/vendor
script:
......
......@@ -91,10 +91,7 @@ Style/Documentation:
Enabled: false
Style/GuardClause:
Exclude:
# If the unless + flash message is placed in a guard clause then Rubocop
# indicates that it is better to use a normal unless.
- 'app/controllers/projects_controller.rb'
Enabled: false
Rails/ContentTag:
Enabled: false
......
......@@ -204,6 +204,9 @@ group :development, :test do
# Security Audits
gem 'brakeman', require: false
gem 'bundler-audit', require: false
# Mocking
gem 'mocha', '~> 1.13'
end
# =================================================================================================
......
......@@ -9,7 +9,7 @@ GIT
GIT
remote: https://github.com/elastic/elasticsearch-rails
revision: 03fa16b2774988c59978abb13aae962c9580ec57
revision: b66fe71cc4b9b10069bf6d39dbbfcc0b117a08a5
branch: main
specs:
elasticsearch-model (7.2.1)
......@@ -20,7 +20,7 @@ GIT
GIT
remote: https://github.com/zdennis/activerecord-import.git
revision: 74ea5b1f2f6a9c1e958bff1e29eb46de32860735
revision: 9f631e2adc53b927ff37da442c6913fe621e87ef
specs:
activerecord-import (1.4.0)
activerecord (>= 4.2)
......@@ -47,40 +47,40 @@ GEM
specs:
aasm (5.2.0)
concurrent-ruby (~> 1.0)
actioncable (6.1.5)
actionpack (= 6.1.5)
activesupport (= 6.1.5)
actioncable (6.1.6)
actionpack (= 6.1.6)
activesupport (= 6.1.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.5)
actionpack (= 6.1.5)
activejob (= 6.1.5)
activerecord (= 6.1.5)
activestorage (= 6.1.5)
activesupport (= 6.1.5)
actionmailbox (6.1.6)
actionpack (= 6.1.6)
activejob (= 6.1.6)
activerecord (= 6.1.6)
activestorage (= 6.1.6)
activesupport (= 6.1.6)
mail (>= 2.7.1)
actionmailer (6.1.5)
actionpack (= 6.1.5)
actionview (= 6.1.5)
activejob (= 6.1.5)
activesupport (= 6.1.5)
actionmailer (6.1.6)
actionpack (= 6.1.6)
actionview (= 6.1.6)
activejob (= 6.1.6)
activesupport (= 6.1.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.5)
actionview (= 6.1.5)
activesupport (= 6.1.5)
actionpack (6.1.6)
actionview (= 6.1.6)
activesupport (= 6.1.6)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.5)
actionpack (= 6.1.5)
activerecord (= 6.1.5)
activestorage (= 6.1.5)
activesupport (= 6.1.5)
actiontext (6.1.6)
actionpack (= 6.1.6)
activerecord (= 6.1.6)
activestorage (= 6.1.6)
activesupport (= 6.1.6)
nokogiri (>= 1.8.5)
actionview (6.1.5)
activesupport (= 6.1.5)
actionview (6.1.6)
activesupport (= 6.1.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
......@@ -91,22 +91,22 @@ GEM
ruby2_keywords
active_record_union (1.3.0)
activerecord (>= 4.0)
activejob (6.1.5)
activesupport (= 6.1.5)
activejob (6.1.6)
activesupport (= 6.1.6)
globalid (>= 0.3.6)
activemodel (6.1.5)
activesupport (= 6.1.5)
activerecord (6.1.5)
activemodel (= 6.1.5)
activesupport (= 6.1.5)
activestorage (6.1.5)
actionpack (= 6.1.5)
activejob (= 6.1.5)
activerecord (= 6.1.5)
activesupport (= 6.1.5)
activemodel (6.1.6)
activesupport (= 6.1.6)
activerecord (6.1.6)
activemodel (= 6.1.6)
activesupport (= 6.1.6)
activestorage (6.1.6)
actionpack (= 6.1.6)
activejob (= 6.1.6)
activerecord (= 6.1.6)
activesupport (= 6.1.6)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.5)
activesupport (6.1.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
......@@ -118,9 +118,9 @@ GEM
sshkit (>= 1.6.1, != 1.7.0)
ansi (1.5.0)
ast (2.4.2)
autoprefixer-rails (10.4.2.0)
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
bcrypt (3.1.17)
bcrypt (3.1.18)
bindex (0.8.1)
bootstrap-kaminari-views (0.0.5)
kaminari (>= 0.13)
......@@ -131,11 +131,11 @@ GEM
bootstrap_form (4.5.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
brakeman (5.2.2)
brakeman (5.2.3)
breadcrumbs_on_rails (4.1.0)
railties (>= 5.0)
builder (3.2.4)
bundler-audit (0.9.0.1)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
byebug (11.1.3)
......@@ -145,12 +145,12 @@ GEM
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.0.1)
capistrano-bundler (2.1.0)
capistrano (~> 3.1)
capistrano-rails (1.6.2)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capybara (3.36.0)
capybara (3.37.1)
addressable
matrix
mini_mime (>= 0.1.3)
......@@ -190,7 +190,7 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise_saml_authenticatable (1.8.0)
devise_saml_authenticatable (1.9.0)
devise (> 2.0.0)
ruby-saml (~> 1.7)
diffy (3.4.0)
......@@ -205,7 +205,7 @@ GEM
multi_json
erubi (1.10.0)
execjs (2.8.1)
faker (2.20.0)
faker (2.21.0)
i18n (>= 1.8.11, < 2)
faraday (1.10.0)
faraday-em_http (~> 1.0)
......@@ -249,7 +249,7 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jquery-rails (4.4.0)
jquery-rails (4.5.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
......@@ -285,7 +285,7 @@ GEM
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.16.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
......@@ -307,15 +307,16 @@ GEM
builder
minitest (>= 5.0)
ruby-progressbar
mocha (1.14.0)
multi_json (1.15.0)
multipart-post (2.1.1)
mysql2 (0.5.3)
mysql2 (0.5.4)
net-ldap (0.17.0)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
nio4r (2.5.8)
nokogiri (1.13.4-x86_64-linux)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
paper_trail (12.3.0)
......@@ -324,7 +325,7 @@ GEM
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
passenger (6.0.13)
passenger (6.0.14)
rack
rake (>= 0.8.1)
pry (0.14.1)
......@@ -334,28 +335,28 @@ GEM
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack (2.2.3.1)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.5)
actioncable (= 6.1.5)
actionmailbox (= 6.1.5)
actionmailer (= 6.1.5)
actionpack (= 6.1.5)
actiontext (= 6.1.5)
actionview (= 6.1.5)
activejob (= 6.1.5)
activemodel (= 6.1.5)
activerecord (= 6.1.5)
activestorage (= 6.1.5)
activesupport (= 6.1.5)
rails (6.1.6)
actioncable (= 6.1.6)
actionmailbox (= 6.1.6)
actionmailer (= 6.1.6)
actionpack (= 6.1.6)
actiontext (= 6.1.6)
actionview (= 6.1.6)
activejob (= 6.1.6)
activemodel (= 6.1.6)
activerecord (= 6.1.6)
activestorage (= 6.1.6)
activesupport (= 6.1.6)
bundler (>= 1.15.0)
railties (= 6.1.5)
railties (= 6.1.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-erd (1.6.1)
rails-erd (1.7.0)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
......@@ -364,9 +365,9 @@ GEM
loofah (~> 2.3)
rails-jquery-autocomplete (1.0.5)
rails (>= 3.2)
railties (6.1.5)
actionpack (= 6.1.5)
activesupport (= 6.1.5)
railties (6.1.6)
actionpack (= 6.1.6)
activesupport (= 6.1.6)
method_source
rake (>= 12.2)
thor (~> 1.0)
......@@ -376,7 +377,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
regexp_parser (2.3.0)
regexp_parser (2.5.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.1)
......@@ -389,16 +390,16 @@ GEM
lazy_priority_queue (~> 0.1.0)
stream (~> 0.5.3)
rolify (6.0.0)
rubocop (1.27.0)
rubocop (1.30.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.17.0)
rubocop-ast (1.18.0)
parser (>= 3.1.1.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
......@@ -430,13 +431,13 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sentry-rails (5.2.1)
sentry-rails (5.3.1)
railties (>= 5.0)
sentry-ruby-core (~> 5.2.1)
sentry-ruby (5.2.1)
sentry-ruby-core (~> 5.3.1)
sentry-ruby (5.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
sentry-ruby-core (= 5.2.1)
sentry-ruby-core (5.2.1)
sentry-ruby-core (= 5.3.1)
sentry-ruby-core (5.3.1)
concurrent-ruby
simplecov (0.21.2)
docile (~> 1.1)
......@@ -540,6 +541,7 @@ DEPENDENCIES
letter_opener
lightbox2-rails
minitest-reporters
mocha (~> 1.13)
mysql2
net-ldap
nokogiri
......
......@@ -19,3 +19,10 @@ $thumbnail-caption-padding: 15px !default;
background-color: $brand-primary;
color: #ffffff;
}
.thumbnail-inverse {
@extend .thumbnail;
background-color: $brand-primary !important;
border-color: black !important;
color: white !important;
}
\ No newline at end of file
......@@ -95,3 +95,18 @@ footer a, footer p {
.panel-info > .panel-heading a {
color: #ffffff;
}
.flex-container {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
}
.flex-column {
flex-direction: column;
}
.flex-element {
flex: 1;
width: 100%;
}
\ No newline at end of file
......@@ -190,6 +190,7 @@
.txt-justify { text-align:justify; }
.txt-strong, .txt-bold { font-weight:bold; }
.txt-italic { font-style: italic; }
.txt-uppercase{ text-transform: uppercase; }
.txt-lowercase{ text-transform: lowercase; }
......@@ -207,6 +208,10 @@
box-sizing:border-box;
}
@media (min-width: $screen-md-min) {
.pull-md-right { float: right !important; }
}
.mobile{visibility:hidden; display:none; margin:0; padding:0; height:0;}
.not-mobile{visibility:visible;}
......
......@@ -42,27 +42,19 @@ module Admin
##
# Action to create a new company
def create
@company = Company.create company_params
if @company.persisted?
flash[:success] = "Successfully created company #{@company.name}"
redirect_to admin_company_url(@company)
else
flash[:danger] = 'Failed to create company'
render 'new'
end
@company = Company.create(company_params)
helpers.flash_crud_msg(@company,
on_success: proc { redirect_to admin_company_url(@company) },
on_failure: proc { render 'new' })
end
##
# Updates a company using +company_params+
def update
if @company.update(company_params)
flash[:success] = 'Successfully updated the company'
redirect_to admin_company_url(@company)
else
flash[:danger] = 'Failed to update the company'
render 'edit'
end
@company.update(company_params)
helpers.flash_crud_msg(@company,
on_success: proc { redirect_to admin_company_url(@company) },
on_failure: proc { render 'edit' })
end
protected
......
......@@ -48,6 +48,9 @@ module Admin
new_project.status = :approved if project.status == 'deactivated'
new_project.save!
new_project = new_project.acting_as
project.images.each do |img|
new_project.images.create(title: img.title, file: img.file)
end
if params[:deactivate_old] == '1'
log_event(
......
......@@ -38,34 +38,27 @@ module Admin
end
def create
@course_edition = CourseEdition.create(
course_edition_params.merge(course: @course)
)
@algorithm_params = AlgorithmParamSet.create(course_edition: @course_edition)
failed = update_multiple_roles(course_edition_params_with_staff['staff'],
{ '0': :coordinator, '1': :enrollment_manager, '2': :viewer }, @course_edition)
failed_files = false
if @course_edition.persisted? && @algorithm_params.persisted?
# copy files if duplicating a course edition
failed_files = copy_files
if update_exclusivity_groups.empty? && failed.empty? && !failed_files
flash[:success] = 'Successfully created course edition'
else
flash[:danger] = if failed_files
'Course edition was created, but files could not be copied'
else
'Course edition was created, but staff or exclusivity groups could not be set'
end
end
redirect_to admin_course_edition_url(@course, @course_edition)
else
flash[:danger] = 'Failed to create course edition'
render 'new'
end
# Create course edition. In case of failure, render new page again and return
# On successful creation, also create algorithm param set, exclusivity group, copy files (in case of duplication) and create roles.
@course_edition = CourseEdition.create(course_edition_params.merge(course: @course))
helpers.flash_crud_msg(@course_edition,
html: false,
extra_checks:
{
AlgorithmParamSet.model_name.human => -> { AlgorithmParamSet.create(course_edition: @course_edition) },
ExclusivityGroup.model_name.human(count: 2) => -> { update_exclusivity_groups.none? },
CourseFile.model_name.human(count: 2) => -> { copy_files != true },
Role.model_name.human(count: 2) => lambda do
update_multiple_roles(
course_edition_params_with_staff['staff'],
{ '0': :coordinator, '1': :enrollment_manager, '2': :viewer },
@course_edition
).none?
end
},
on_success: proc { redirect_to admin_course_edition_url(@course, @course_edition) },
on_part_failure: proc { redirect_to admin_course_edition_url(@course, @course_edition) },
on_failure: proc { render 'new' })
end
def edit
......@@ -108,15 +101,21 @@ module Admin
end
def update
failed = update_multiple_roles(course_edition_params_with_staff['staff'],
{ '0': :coordinator, '1': :enrollment_manager, '2': :viewer }, @course_edition)
if @course_edition.update(course_edition_params) && update_exclusivity_groups.empty? && failed.empty?
flash[:success] = 'Successfully updated course edition'
redirect_to admin_course_edition_url(@course, @course_edition)
else
flash[:danger] = 'Failed to update course edition'
render 'edit'
end
# Update course edition, roles and exclusivity groups (all at the same time). If anything fails, show the edit page again.
@course_edition.update(course_edition_params)
helpers.flash_crud_msg(@course_edition,
extra_checks:
{
ExclusivityGroup.model_name.human(count: 2) => update_exclusivity_groups.none?,
Role.model_name.human(count: 2) =>
update_multiple_roles(
course_edition_params_with_staff['staff'],
{ '0': :coordinator, '1': :enrollment_manager, '2': :viewer },
@course_edition
).none?
},
on_success: proc { redirect_to admin_course_edition_url(@course, @course_edition) },
on_failure: proc { render 'edit' })
end
def import_projects
......@@ -341,19 +340,21 @@ module Admin
private
# Copies the files from one course edition to another
# @return [Boolean, Nil] nil if no copying was done, false if copying succeeded and true if copying failed.
def copy_files
edition_to_copy = params[:edition_to_copy]
if edition_to_copy
old_edition = CourseEdition.find_by id: edition_to_copy
# verify permissions
if old_edition && can?(:duplicate, old_edition)
old_edition.course_files.each do |course_file|
@course_edition.course_files.create(title: course_file.title, file: course_file.file, user: current_user)
end
failed_files = !@course_edition.save
return nil unless edition_to_copy
old_edition = CourseEdition.find_by(id: edition_to_copy)
# verify permissions
if old_edition && can?(:duplicate, old_edition)
old_edition.course_files.each do |course_file|
@course_edition.course_files.create(title: course_file.title, file: course_file.file, user: current_user)
end
!@course_edition.save
end
failed_files
end
end
end
......@@ -3,14 +3,10 @@ module Admin
authorize_resource :course_edition
def create
@course_file = CourseFile.new course_file_params
if verify_course_edition && @course_file.save
flash[:success] = 'Successfully uploaded file'
else
flash[:danger] = 'Failed to upload file'
end
authorize! :update, CourseEdition.find_by(id: params[:course_file][:course_edition_id].to_i)
@course_file = CourseFile.create course_file_params
helpers.flash_crud_msg(@course_file, model_name: 'file', action: :upload)
redirect_back(fallback_location: root_path)
end
......@@ -19,23 +15,12 @@ module Admin
authorize! :update, @course_file.course_edition
@course_file.destroy
if @course_file.destroyed?
flash[:success] = 'Successfully deleted file'
else
flash[:danger] = 'Failed to delete file'
end
helpers.flash_crud_msg(@course_file)
redirect_back(fallback_location: root_path)
end
protected
def verify_course_edition
course_edition_id = params[:course_file][:course_edition_id].to_i
can? :update, CourseEdition.find_by(id: course_edition_id)
end
def course_file_params
course_edition_id = params[:course_file][:course_edition_id].to_i
......
......@@ -9,6 +9,8 @@ module Admin
add_breadcrumb @import.name, admin_import_path(@import)
end
before_action :load_data, only: %i[new create]