Commit a4d58294 authored by Taico Aerts's avatar Taico Aerts
Browse files

Merge branch 'development' into 'master'

Project Forum Release v2.6.0

See merge request eip/bepsys/bepsys2!703
parents 8444bf80 d5138207
......@@ -86,6 +86,10 @@ gem 'cancancan'
# User role allocation
gem 'rolify'
# LDAP integration
gem 'connection_pool'
gem 'net-ldap'
# =================================================================================================
# UI / Frontend
# =================================================================================================
......
......@@ -20,7 +20,7 @@ GIT
GIT
remote: https://github.com/zdennis/activerecord-import.git
revision: ea304fd66bbcd333e4559e7fe5dcc814d71b3ffb
revision: 74ea5b1f2f6a9c1e958bff1e29eb46de32860735
specs:
activerecord-import (1.4.0)
activerecord (>= 4.2)
......@@ -131,7 +131,7 @@ GEM
bootstrap_form (4.5.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
brakeman (5.2.1)
brakeman (5.2.2)
breadcrumbs_on_rails (4.1.0)
railties (>= 5.0)
builder (3.2.4)
......@@ -182,6 +182,7 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.10)
connection_pool (2.2.5)
crass (1.0.6)
devise (4.8.1)
bcrypt (~> 3.0)
......@@ -309,18 +310,19 @@ GEM
multi_json (1.15.0)
multipart-post (2.1.1)
mysql2 (0.5.3)
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.3-x86_64-linux)
nokogiri (1.13.4-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
paper_trail (12.3.0)
activerecord (>= 5.2)
request_store (~> 1.1)
parallel (1.22.1)
parser (3.1.1.0)
parser (3.1.2.0)
ast (~> 2.4.1)
passenger (6.0.13)
rack
......@@ -328,7 +330,7 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
......@@ -374,7 +376,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
regexp_parser (2.2.1)
regexp_parser (2.3.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.1)
......@@ -387,7 +389,7 @@ GEM
lazy_priority_queue (~> 0.1.0)
stream (~> 0.5.3)
rolify (6.0.0)
rubocop (1.26.1)
rubocop (1.27.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
......@@ -396,7 +398,7 @@ GEM
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
rubocop-ast (1.17.0)
parser (>= 3.1.1.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
......@@ -517,6 +519,7 @@ DEPENDENCIES
ckeditor
cocoon
coffee-rails
connection_pool
devise
devise_saml_authenticatable
diffy
......@@ -538,6 +541,7 @@ DEPENDENCIES
lightbox2-rails
minitest-reporters
mysql2
net-ldap
nokogiri
paper_trail (~> 12.1)
passenger (>= 6.0)
......
......@@ -5,6 +5,7 @@ $(document).on('turbolinks:load', function() {
autoplay: true,
slidesToShow: 1,
centerMode: true,
variableWidth: true
variableWidth: true,
adaptiveHeight: true
});
});
......@@ -33,6 +33,16 @@ a.list-group-item:hover, a.list-group-item:active {
color: #ffffff;
}
.list-group-item.list-group-item-left,
.list-group-item.list-group-item-right {
float: left;
width: 50%;
}
.list-group-item.list-group-item-left {
border-right-width: 0;
}
.panel.panel-primary.front {
margin-top: 10vh;
}
......
.slick-carousel__image {
height: 300px;
.project-image-carousel .slick-slide img {
margin: auto;
max-height: 300px;
}
.slick-carousel .slick-slide {
@media screen and (min-width: 992px) {
.project-image-carousel .slick-slide img {
max-width: 485px;
}
}
@media screen and (max-width: 992px) {
.project-image-carousel .slick-slide img {
max-width: 375px;
}
}
.project-image-carousel .slick-slide {
margin: 0 10px;
}
......@@ -45,8 +45,7 @@ module Admin
# Catch access denied errors, log them and show the correct error page.
# Otherwise, error 500 would be displayed instead (uncaught exception)
rescue_from CanCan::AccessDenied do |exception|
Rails.logger.error("An access denied exception was triggered: #{exception.message}")
Rails.logger.error(exception.backtrace)
Rails.logger.error("An access denied exception was triggered: #{exception.action} #{exception.subject.inspect}")
render file: Rails.root.join('public/403.html'),
status: :forbidden,
layout: false
......
......@@ -145,7 +145,7 @@ module Admin
end
# Copy course-specific role assignments from project
transfer_course_specific_roles(group, project)
transfer_course_specific_roles(group, project, approve_group)
# Create the memberships
members.each_with_index do |member, index|
......@@ -215,7 +215,7 @@ module Admin
project = Project.new(id: -1,
name: 'Unknown project',
description: '',
company: Company.new(id: -1, name: 'Unknown company'),
offerer: Company.new(id: -1, name: 'Unknown company').acting_as,
actable_id: -1,
actable_type: 'GenericProject')
errors.append("Unable to process line #{index + 1}: cannot find project \"#{row[0]}\"")
......@@ -244,10 +244,24 @@ module Admin
private
def transfer_course_specific_roles(group, project)
def transfer_course_specific_roles(group, project, should_notify)
project.user_course_specific_roles.each do |ucsr|
UserCourseSpecificRole.create(user: ucsr.user, resource: group,
course_specific_role: ucsr.course_specific_role)
ucsr.copy_to_resource! group
# notify user of their assignment if group is approved
next unless should_notify
notification_message = ucsr.course_specific_role.build_notification_message(project, ucsr.user, current_user)
next if notification_message.blank?
log_event(
group,
:role_assigned,
notification_message: notification_message,
project: project.name,
url: course_edition_project_group_url(project.course_edition, project, group)
).notify(ucsr.user)
end
end
end
......
......@@ -100,6 +100,21 @@ module Admin
error = "Unable to assign #{role.name} role for #{user.full_name} for group #{group.id}"
raise ActiveRecord::Rollback, error
end
# notify user of their assignment if group is approved
next if group.status != 'approved'
notification_message = role.build_notification_message(group.project, user, current_user)
next if notification_message.blank?
log_event(
group,
:role_assigned,
notification_message: notification_message,
project: group.project.name,
url: course_edition_project_group_url(@course_edition, group.project, group)
).notify(user)
end
end
end
......
......@@ -73,8 +73,8 @@ module Admin
# Actually send notification if no failures occurred
event.notify(User.with_role(:client, project), as: :client)
.notify(User.with_role(:registrar, project.company) - User.with_role(:client, project), as: :registrar)
.notify(User.with_role(:employee, project.company) - User.with_role(:client, project), as: :employee)
.notify(User.with_role(:registrar, project.offerer.actable) - User.with_role(:client, project), as: :registrar)
.notify(User.with_role(:employee, project.offerer.actable) - User.with_role(:client, project), as: :employee)
new_project
end
......
......@@ -158,21 +158,32 @@ module Admin
end
def write_email
authorize! :send_email, @course_edition
@course_specific_role = @course_edition.course_specific_roles.find_by(id: params[:role]) if params[:type] == 'role'
render 'admin/course_editions/write_email/write_email'
end
def send_email
authorize! :send_email, @course_edition
@course_specific_role = @course_edition.course_specific_roles.find_by(id: params[:role]) if params[:type] == 'role'
message = params.require(:message)
subject = params.require(:subject)
if params[:type] == 'clients'
case params[:type]
when 'clients'
targets = @course_edition.projects.map(&:clients).flatten(1).map(&:email)
UserMailer.client_email(current_user, current_user.email, targets, subject, message, @course_edition).deliver_now
else
targets = @course_edition.coaches.map(&:email)
when 'role'
targets = @course_edition.groups.flat_map(&:user_course_specific_roles)
.select { |ucsr| ucsr.course_specific_role_id == @course_specific_role.id }
.map { |ucsr| ucsr.user.email }
UserMailer.coach_email(current_user, current_user.email, targets, subject, message, @course_edition).deliver_now
else
raise ActionController::BadRequest
end
flash[:success] = "Successfully sent an email to all #{params[:type]}"
recipients_name = params[:type]
recipients_name = @course_specific_role.name.pluralize if @course_specific_role
flash[:success] = "Successfully sent an email to all #{recipients_name}"
redirect_to admin_course_edition_path(@course, @course_edition)
end
......@@ -239,7 +250,7 @@ module Admin
Rails.logger.warn("Cleaning up students in approved groups from interest lists and other groups in #{@course_edition.display_name}")
@course_edition.participants.each do |student|
groups = student.groups.joins(:course_edition).where(course_editions: { id: @course_edition.id })
approved_groups = groups.where(client_status: :client_approved).union(groups.where(status: :approved))
approved_groups = groups.where(client_status: :client_approved).or(groups.where(status: :approved))
# Do nothing if the user is not in (client or coordinator) approved groups
next if approved_groups.count.zero?
......
......@@ -41,6 +41,10 @@ module Admin
add_breadcrumb 'New', new_admin_generic_project_path(@specific_project)
end
def edit
add_breadcrumb 'Edit', edit_admin_generic_project_path(@specific_project)
end
def create
@specific_project = GenericProject.new(generic_project_params)
@specific_project.status = :approved
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment