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

Merge branch 'development' into 'master'

Project Forum Release v2.8.7 - 31-08-2022

See merge request !851
parents 8e8f5b31 771bd13b
......@@ -119,9 +119,6 @@ gem 'cocoon'
gem 'kaminari'
gem 'bootstrap-kaminari-views'
# Hybrid text / select input fields
gem 'selectize-rails'
# Diffing for project update comparison
gem 'diffy'
......
......@@ -434,7 +434,6 @@ GEM
tilt
seedbank (0.5.0)
rake (>= 10.0)
selectize-rails (0.12.6)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
......@@ -569,7 +568,6 @@ DEPENDENCIES
rubyzip (>= 1.3.0)
sass-rails
seedbank
selectize-rails
selenium-webdriver (~> 3.6)
sentry-rails
sentry-ruby
......
......@@ -17,7 +17,7 @@
//= require zebra-datepicker/core
//= require normal/datepicker_inputs
//= require cocoon
//= require selectize
//= require selectize/selectize
//= require normal/selectize_inputs
//= require mammoth/mammoth.browser
//= require toastui/toastui-editor-all
......
......@@ -21,7 +21,7 @@
//= require normal/checkbox
//= require normal/slick_carousels
//= require lightbox
//= require selectize
//= require selectize/selectize
//= require normal/selectize_inputs
//= require mammoth/mammoth.browser
//= require toastui/toastui-editor-all
......
This diff is collapsed.
......@@ -22,8 +22,8 @@
body { padding-top: 0px; }
.navbar { margin-bottom: 0; }
@import 'selectize';
@import 'selectize.bootstrap3';
@import 'selectize/selectize';
@import 'selectize/selectize.bootstrap3';
@import 'toastui/toastui-editor';
@import 'toastui/prism';
@import 'toastui/toastui-editor-plugin-code-syntax-highlight';
......
......@@ -30,8 +30,8 @@
@import 'zebra-datepicker/bootstrap';
@import 'selectize';
@import 'selectize.bootstrap3';
@import 'selectize/selectize';
@import 'selectize/selectize.bootstrap3';
@import 'toastui/toastui-editor';
@import 'toastui/prism';
@import 'toastui/toastui-editor-plugin-code-syntax-highlight';
......
.selectize-control.plugin-drag_drop.multi>.selectize-input.dragging{overflow:visible}.selectize-control.plugin-drag_drop.multi>.selectize-input>div.ui-sortable-placeholder{visibility:visible !important;background:#f2f2f2 !important;background:rgba(0,0,0,.06) !important;border:0 none !important;box-shadow:inset 0 0 12px 4px #fff}.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after{content:"!";visibility:hidden}.selectize-control.plugin-drag_drop .ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.selectize-control .dropdown-header{position:relative;padding:6px 12px;border-bottom:1px solid #d0d0d0;background:#f8f8f8;border-radius:4px 4px 0 0}.selectize-control .dropdown-header-close{position:absolute;right:12px;top:50%;color:#333;opacity:.4;margin-top:-12px;line-height:20px;font-size:20px !important}.selectize-control .dropdown-header-close:hover{color:#000}.selectize-dropdown.plugin-optgroup_columns .selectize-dropdown-content{display:flex}.selectize-dropdown.plugin-optgroup_columns .optgroup{border-right:1px solid #f2f2f2;border-top:0 none;flex-grow:1;flex-basis:0;min-width:0}.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child{border-right:0 none}.selectize-dropdown.plugin-optgroup_columns .optgroup:before{display:none}.selectize-dropdown.plugin-optgroup_columns .optgroup-header{border-top:0 none}.selectize-control.plugin-remove_button .item{display:inline-flex;align-items:center;padding-right:0 !important}.selectize-control.plugin-remove_button .item .remove{color:inherit;text-decoration:none;vertical-align:middle;display:inline-block;padding:1px 5px;border-left:1px solid rgba(0,0,0,0);border-radius:0 2px 2px 0;box-sizing:border-box;margin-left:5px}.selectize-control.plugin-remove_button .item .remove:hover{background:rgba(0,0,0,.05)}.selectize-control.plugin-remove_button .item.active .remove{border-left-color:rgba(0,0,0,0)}.selectize-control.plugin-remove_button .disabled .item .remove:hover{background:none}.selectize-control.plugin-remove_button .disabled .item .remove{border-left-color:rgba(77,77,77,0)}.selectize-control.plugin-remove_button .remove-single{position:absolute;right:0;top:0;font-size:23px}.selectize-control{position:relative}.selectize-dropdown,.selectize-input,.selectize-input input{color:#333;font-family:inherit;font-size:inherit;line-height:20px;font-smoothing:inherit}.selectize-input,.selectize-control.single .selectize-input.input-active{background:#fff;cursor:text;display:inline-block}.selectize-input{border:1px solid #ccc;padding:6px 12px;display:inline-block;width:100%;position:relative;z-index:1;box-sizing:border-box;box-shadow:none;border-radius:4px}.selectize-control.multi .selectize-input.has-items{padding:calc(
6px - 1px - 0px
) 12px calc(
6px - 1px - 3px -
0px
)}.selectize-input.full{background-color:#fff}.selectize-input.disabled,.selectize-input.disabled *{cursor:default !important}.selectize-input.focus{box-shadow:inset 0 1px 2px rgba(0,0,0,.15)}.selectize-input.dropdown-active{border-radius:4px 4px 0 0}.selectize-input>*{vertical-align:baseline;display:inline-block;zoom:1}.selectize-control.multi .selectize-input>div{cursor:pointer;margin:0 3px 3px 0;padding:1px 5px;background:#efefef;color:#333;border:0px solid rgba(0,0,0,0)}.selectize-control.multi .selectize-input>div.active{background:#337ab7;color:#fff;border:0px solid rgba(0,0,0,0)}.selectize-control.multi .selectize-input.disabled>div,.selectize-control.multi .selectize-input.disabled>div.active{color:gray;background:#fff;border:0px solid rgba(77,77,77,0)}.selectize-input>input{display:inline-block !important;padding:0 !important;min-height:0 !important;max-height:none !important;max-width:100% !important;margin:0 !important;text-indent:0 !important;border:0 none !important;background:none !important;line-height:inherit !important;user-select:auto !important;box-shadow:none !important}.selectize-input>input::-ms-clear{display:none}.selectize-input>input:focus{outline:none !important}.selectize-input>input[placeholder]{box-sizing:initial}.selectize-input.has-items>input{margin:0 0px !important}.selectize-input::after{content:" ";display:block;clear:left}.selectize-input.dropdown-active::before{content:" ";display:block;position:absolute;background:#fff;height:1px;bottom:0;left:0;right:0}.selectize-dropdown{position:absolute;top:100%;left:0;width:100%;z-index:10;border:1px solid #d0d0d0;background:#fff;margin:-1px 0 0 0;border-top:0 none;box-sizing:border-box;box-shadow:0 1px 3px rgba(0,0,0,.1);border-radius:0 0 4px 4px}.selectize-dropdown [data-selectable]{cursor:pointer;overflow:hidden}.selectize-dropdown [data-selectable] .highlight{background:rgba(255,237,40,.4);border-radius:1px}.selectize-dropdown .option,.selectize-dropdown .optgroup-header,.selectize-dropdown .no-results,.selectize-dropdown .create{padding:3px 12px}.selectize-dropdown .option,.selectize-dropdown [data-disabled],.selectize-dropdown [data-disabled] [data-selectable].option{cursor:inherit;opacity:.5}.selectize-dropdown [data-selectable].option{opacity:1;cursor:pointer}.selectize-dropdown .optgroup:first-child .optgroup-header{border-top:0 none}.selectize-dropdown .optgroup-header{color:#777;background:#fff;cursor:default}.selectize-dropdown .active{background-color:#f5f5f5;color:#262626}.selectize-dropdown .active.create{color:#262626}.selectize-dropdown .create{color:rgba(51,51,51,.5)}.selectize-dropdown-content{overflow-y:auto;overflow-x:hidden;max-height:200px;overflow-scrolling:touch}.selectize-dropdown-emptyoptionlabel{text-align:center}.selectize-dropdown .spinner{display:inline-block;width:30px;height:30px;margin:3px 12px}.selectize-dropdown .spinner:after{content:" ";display:block;width:24px;height:24px;margin:3px;border-radius:50%;border:5px solid #d0d0d0;border-color:#d0d0d0 rgba(0,0,0,0) #d0d0d0 rgba(0,0,0,0);animation:lds-dual-ring 1.2s linear infinite}@keyframes lds-dual-ring{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.selectize-control.single .selectize-input,.selectize-control.single .selectize-input input{cursor:pointer}.selectize-control.single .selectize-input.input-active,.selectize-control.single .selectize-input.input-active input{cursor:text}.selectize-control.single .selectize-input:after{content:" ";display:block;position:absolute;top:50%;right:17px;margin-top:-3px;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#333 rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0)}.selectize-control.single .selectize-input.dropdown-active:after{margin-top:-4px;border-width:0 5px 5px 5px;border-color:rgba(0,0,0,0) rgba(0,0,0,0) #333 rgba(0,0,0,0)}.selectize-control.rtl{text-align:right}.selectize-control.rtl.single .selectize-input:after{left:17px;right:auto}.selectize-control.rtl .selectize-input>input{margin:0 4px 0 -2px !important}.selectize-control .selectize-input.disabled{opacity:.5;background-color:#fff}.selectize-dropdown,.selectize-dropdown.form-control{height:auto;padding:0;margin:2px 0 0 0;z-index:1000;background:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;box-shadow:0 6px 12px rgba(0,0,0,.175)}.selectize-dropdown .optgroup-header{font-size:12px;line-height:1.428571429}.selectize-dropdown .optgroup:first-child:before{display:none}.selectize-dropdown .optgroup:before{content:" ";display:block;height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5;margin-left:-12px;margin-right:-12px}.selectize-dropdown-content{padding:5px 0}.selectize-dropdown-emptyoptionlabel{text-align:center}.selectize-input{min-height:34px}.selectize-input.dropdown-active{border-radius:4px}.selectize-input.dropdown-active::before{display:none}.selectize-input.focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.has-error .selectize-input{border-color:#a94442;box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-error .selectize-input:focus{border-color:#843534;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483}.selectize-control.multi .selectize-input.has-items{padding-left:7px;padding-right:7px}.selectize-control.multi .selectize-input>div{border-radius:3px}.form-control.selectize-control{padding:0;height:auto;border:none;background:none;box-shadow:none;border-radius:0}
\ No newline at end of file
/**
* selectize.css (v0.13.6)
* Copyright (c) 2013–2015 Brian Reavis & contributors
* Copyright (c) 2020-2022 Selectize Team & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
* @author Brian Reavis <brian@thirdroute.com>
* @author Ris Adams <selectize@risadams.com>
*/
.selectize-control.plugin-drag_drop.multi>.selectize-input.dragging{overflow:visible}.selectize-control.plugin-drag_drop.multi>.selectize-input>div.ui-sortable-placeholder{visibility:visible !important;background:#f2f2f2 !important;background:rgba(0,0,0,.06) !important;border:0 none !important;box-shadow:inset 0 0 12px 4px #fff}.selectize-control.plugin-drag_drop .ui-sortable-placeholder::after{content:"!";visibility:hidden}.selectize-control.plugin-drag_drop .ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.selectize-control .dropdown-header{position:relative;padding:10px 8px;border-bottom:1px solid #d0d0d0;background:#f8f8f8;border-radius:3px 3px 0 0}.selectize-control .dropdown-header-close{position:absolute;right:8px;top:50%;color:#303030;opacity:.4;margin-top:-12px;line-height:20px;font-size:20px !important}.selectize-control .dropdown-header-close:hover{color:#000}.selectize-dropdown.plugin-optgroup_columns .selectize-dropdown-content{display:flex}.selectize-dropdown.plugin-optgroup_columns .optgroup{border-right:1px solid #f2f2f2;border-top:0 none;flex-grow:1;flex-basis:0;min-width:0}.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child{border-right:0 none}.selectize-dropdown.plugin-optgroup_columns .optgroup:before{display:none}.selectize-dropdown.plugin-optgroup_columns .optgroup-header{border-top:0 none}.selectize-control.plugin-remove_button .item{display:inline-flex;align-items:center;padding-right:0 !important}.selectize-control.plugin-remove_button .item .remove{color:inherit;text-decoration:none;vertical-align:middle;display:inline-block;padding:2px 6px;border-left:1px solid #d0d0d0;border-radius:0 2px 2px 0;box-sizing:border-box;margin-left:6px}.selectize-control.plugin-remove_button .item .remove:hover{background:rgba(0,0,0,.05)}.selectize-control.plugin-remove_button .item.active .remove{border-left-color:#cacaca}.selectize-control.plugin-remove_button .disabled .item .remove:hover{background:none}.selectize-control.plugin-remove_button .disabled .item .remove{border-left-color:#fff}.selectize-control.plugin-remove_button .remove-single{position:absolute;right:0;top:0;font-size:23px}.selectize-control{position:relative}.selectize-dropdown,.selectize-input,.selectize-input input{color:#303030;font-family:inherit;font-size:13px;line-height:18px;font-smoothing:inherit}.selectize-input,.selectize-control.single .selectize-input.input-active{background:#fff;cursor:text;display:inline-block}.selectize-input{border:1px solid #d0d0d0;padding:8px 8px;display:inline-block;width:100%;position:relative;z-index:1;box-sizing:border-box;box-shadow:inset 0 1px 1px rgba(0,0,0,.1);border-radius:3px}.selectize-control.multi .selectize-input.has-items{padding:calc(
8px - 2px - 0px
) 8px calc(
8px - 2px - 3px -
0px
)}.selectize-input.full{background-color:#fff}.selectize-input.disabled,.selectize-input.disabled *{cursor:default !important}.selectize-input.focus{box-shadow:inset 0 1px 2px rgba(0,0,0,.15)}.selectize-input.dropdown-active{border-radius:3px 3px 0 0}.selectize-input>*{vertical-align:baseline;display:inline-block;zoom:1}.selectize-control.multi .selectize-input>div{cursor:pointer;margin:0 3px 3px 0;padding:2px 6px;background:#f2f2f2;color:#303030;border:0px solid #d0d0d0}.selectize-control.multi .selectize-input>div.active{background:#e8e8e8;color:#303030;border:0px solid #cacaca}.selectize-control.multi .selectize-input.disabled>div,.selectize-control.multi .selectize-input.disabled>div.active{color:#7d7d7d;background:#fff;border:0px solid #fff}.selectize-input>input{display:inline-block !important;padding:0 !important;min-height:0 !important;max-height:none !important;max-width:100% !important;margin:0 !important;text-indent:0 !important;border:0 none !important;background:none !important;line-height:inherit !important;user-select:auto !important;box-shadow:none !important}.selectize-input>input::-ms-clear{display:none}.selectize-input>input:focus{outline:none !important}.selectize-input>input[placeholder]{box-sizing:initial}.selectize-input.has-items>input{margin:0 0px !important}.selectize-input::after{content:" ";display:block;clear:left}.selectize-input.dropdown-active::before{content:" ";display:block;position:absolute;background:#f0f0f0;height:1px;bottom:0;left:0;right:0}.selectize-dropdown{position:absolute;top:100%;left:0;width:100%;z-index:10;border:1px solid #d0d0d0;background:#fff;margin:-1px 0 0 0;border-top:0 none;box-sizing:border-box;box-shadow:0 1px 3px rgba(0,0,0,.1);border-radius:0 0 3px 3px}.selectize-dropdown [data-selectable]{cursor:pointer;overflow:hidden}.selectize-dropdown [data-selectable] .highlight{background:rgba(125,168,208,.2);border-radius:1px}.selectize-dropdown .option,.selectize-dropdown .optgroup-header,.selectize-dropdown .no-results,.selectize-dropdown .create{padding:5px 8px}.selectize-dropdown .option,.selectize-dropdown [data-disabled],.selectize-dropdown [data-disabled] [data-selectable].option{cursor:inherit;opacity:.5}.selectize-dropdown [data-selectable].option{opacity:1;cursor:pointer}.selectize-dropdown .optgroup:first-child .optgroup-header{border-top:0 none}.selectize-dropdown .optgroup-header{color:#303030;background:#fff;cursor:default}.selectize-dropdown .active{background-color:#f5fafd;color:#495c68}.selectize-dropdown .active.create{color:#495c68}.selectize-dropdown .create{color:rgba(48,48,48,.5)}.selectize-dropdown-content{overflow-y:auto;overflow-x:hidden;max-height:200px;overflow-scrolling:touch}.selectize-dropdown-emptyoptionlabel{text-align:center}.selectize-dropdown .spinner{display:inline-block;width:30px;height:30px;margin:5px 8px}.selectize-dropdown .spinner:after{content:" ";display:block;width:24px;height:24px;margin:3px;border-radius:50%;border:5px solid #d0d0d0;border-color:#d0d0d0 rgba(0,0,0,0) #d0d0d0 rgba(0,0,0,0);animation:lds-dual-ring 1.2s linear infinite}@keyframes lds-dual-ring{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.selectize-control.single .selectize-input,.selectize-control.single .selectize-input input{cursor:pointer}.selectize-control.single .selectize-input.input-active,.selectize-control.single .selectize-input.input-active input{cursor:text}.selectize-control.single .selectize-input:after{content:" ";display:block;position:absolute;top:50%;right:15px;margin-top:-3px;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:gray rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0)}.selectize-control.single .selectize-input.dropdown-active:after{margin-top:-4px;border-width:0 5px 5px 5px;border-color:rgba(0,0,0,0) rgba(0,0,0,0) gray rgba(0,0,0,0)}.selectize-control.rtl{text-align:right}.selectize-control.rtl.single .selectize-input:after{left:15px;right:auto}.selectize-control.rtl .selectize-input>input{margin:0 4px 0 -2px !important}.selectize-control .selectize-input.disabled{opacity:.5;background-color:#fafafa}
......@@ -142,7 +142,7 @@ module Admin
resource: @project,
course_specific_role: csr,
unregistered_name: params[:name],
unregistered_email: params[:email]
unregistered_email: params[:email].downcase
)
end
end
......
......@@ -177,7 +177,7 @@ module Admin
def research_group_params_with_tags
params.require(:research_group).permit(
research_group_params_keys + [tags: %i[id name _destroy]]
research_group_params_keys + [tags: []]
)
end
......@@ -188,7 +188,7 @@ module Admin
end
def research_group_update_tags
update_tags(research_group_params_with_tags, @research_group)
update_tags_selectize(research_group_params_with_tags, @research_group)
end
def update_programmes
......
......@@ -155,12 +155,12 @@ module Admin
def theme_params_with_tags
params.require(:theme).permit(
theme_params_keys + [tags: %i[id name _destroy]]
theme_params_keys + [tags: []]
)
end
def theme_update_tags
update_tags(theme_params_with_tags, @theme)
update_tags_selectize(theme_params_with_tags, @theme)
end
end
end
......@@ -180,12 +180,12 @@ module Admin
def thesis_project_params_with_tags
params.require(:thesis_project).permit(
thesis_project_params_keys + [tags: %i[id name _destroy]]
thesis_project_params_keys + [tags: []]
)
end
def thesis_project_update_tags
update_tags(thesis_project_params_with_tags, @thesis_project)
update_tags_selectize(thesis_project_params_with_tags, @thesis_project)
end
end
end
......@@ -6,7 +6,7 @@ module Companies
load_and_authorize_resource :company
def create
email = role_invitation_params[:email].strip
email = role_invitation_params[:email].strip.downcase
match = email.match(/^.+ <(.+@.+\.[\w\-]+)>/)
email = match[1] if match
......
......@@ -24,4 +24,53 @@ module TagUpdateable
end
failed
end
# @param [ActionController::Parameters] params_with_tags the params that includes tags in the :tags property
# @param [Object] taggable the object that is taggable
# @return [Array] the failed ids
def update_tags_selectize(params_with_tags, taggable)
failed = []
tags = params_with_tags[:tags]&.map(&:downcase)&.to_set || []
existing_taggings = Tagging.includes(:tag).where(taggable: taggable)
# delete taggings that have been removed
delete_removed_taggings(failed, existing_taggings, tags)
# create newly-added taggings
create_new_taggings(failed, existing_taggings, tags, taggable)
failed
end
private
def delete_removed_taggings(failed, existing_taggings, tags)
existing_taggings.each do |tagging|
next if tags.include?(tagging.tag.name)
destroyed = tagging.destroy
failed << tagging.tag.name unless destroyed
end
end
def create_new_taggings(failed, existing_taggings, tags, taggable)
existing_tags = existing_taggings.map { |t| t.tag.name }.to_set
tags.each do |tag|
next if existing_tags.include?(tag) || tag.blank?
t = Tag.find_by(name: tag)
unless t
t = Tag.new(name: tag)
saved = t.save
unless saved
failed << tag
next
end
end
tagging = Tagging.new(tag: t, taggable: taggable)
saved = tagging.save
failed << tag unless saved
end
end
end
......@@ -5,7 +5,7 @@ module Projects
before_action :check_modifiable
def create
email = params[:email]
email = params[:email].downcase
return unless email
limit = @course_edition.configuration.student_preference_count
......@@ -37,7 +37,7 @@ module Projects
def destroy
# If there is no id and email is present, look up by email
if params[:id] == '-1' && params[:email].present?
student = User.find_by(email: params[:email])
student = User.find_by(email: params[:email].lower)
# If the student does not exist, we expect an error, which is what we want.
@student_preference = StudentPreference.find_by(user_id: current_user.id, student_id: student.id, course_edition_id: @course_edition.id)
else
......
......@@ -332,7 +332,7 @@ class ProjectsController < ApplicationController
def fill_role_assignments(role_hash, specific_params)
specific_params[:course_specific_role_selection]&.each do |csr|
csr_id = csr.second[:id]
csr_user_email = csr.second[:email]
csr_user_email = csr.second[:email].downcase
csr_user_name = csr.second[:name]
csr_user_email.strip! # trim spaces from the email
if csr_id.nil? || csr_user_email.nil? || csr_user_name.nil?
......
......@@ -20,12 +20,7 @@ module ActableHelper
raise StandardError, "Unable to reroute project_path for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("#{specific.model_name.name.underscore}_path".to_s, specific, *args)
send("#{project.actable_type.underscore}_path", project.actable_id, *args)
end
def project_url(project, *args)
......@@ -33,12 +28,7 @@ module ActableHelper
raise StandardError, "Unable to reroute project_url for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("#{specific.model_name.name.underscore}_url".to_s, specific, *args)
send("#{project.actable_type.underscore}_url", project.actable_id, *args)
end
def edit_project_path(project, *args)
......@@ -46,12 +36,7 @@ module ActableHelper
raise StandardError, "Unable to reroute edit_project_path for project='#{project}', args='#{args}'"
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("edit_#{specific.model_name.name.underscore}_path".to_s, specific, *args)
send("edit_#{project.actable_type.underscore}_path", project.actable_id, *args)
end
def edit_project_url(project, *args)
......@@ -59,12 +44,7 @@ module ActableHelper
raise StandardError, "Unable to reroute edit_project_url for project='#{project}', args='#{args}'"
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("edit_#{specific.model_name.name.underscore}_url".to_s, specific, *args)
send("edit_#{project.actable_type.underscore}_url", project.actable_id, *args)
end
def new_project_path(*args)
......@@ -85,12 +65,7 @@ module ActableHelper
raise StandardError, "Unable to reroute course_edition_project_path for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("course_edition_#{specific.model_name.name.underscore}_path".to_s, course_edition, specific, *args)
send("course_edition_#{project.actable_type.underscore}_path", course_edition, project.actable_id, *args)
end
def course_edition_project_url(course_edition, project, *args)
......@@ -100,12 +75,7 @@ module ActableHelper
raise StandardError, "Unable to reroute course_edition_project_url for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("course_edition_#{specific.model_name.name.underscore}_url".to_s, course_edition, specific, *args)
send("course_edition_#{project.actable_type.underscore}_url", course_edition, project.actable_id, *args)
end
# -----------------------------------------------------------------------------------------------
......@@ -119,12 +89,7 @@ module ActableHelper
raise StandardError, "Unable to reroute admin_project_path for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("admin_#{specific.model_name.name.underscore}_path".to_s, specific, *args)
send("admin_#{project.actable_type.underscore}_path", project.actable_id, *args)
end
def admin_project_url(project, *args)
......@@ -135,12 +100,7 @@ module ActableHelper
raise StandardError, "Unable to reroute admin_project_url for project='#{project}', args='#{args}'" \
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("admin_#{specific.model_name.name.underscore}_url".to_s, specific, *args)
send("admin_#{project.actable_type.underscore}_url", project.actable_id, *args)
end
def edit_admin_project_path(project, *args)
......@@ -150,12 +110,7 @@ module ActableHelper
raise StandardError, "Unable to reroute edit_admin_project_path for project='#{project}', args='#{args}'"
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("edit_admin_#{specific.model_name.name.underscore}_path".to_s, specific, *args)
send("edit_admin_#{project.actable_type.underscore}_path", project.actable_id, *args)
end
def edit_admin_project_url(project, *args)
......@@ -165,12 +120,7 @@ module ActableHelper
raise StandardError, "Unable to reroute edit_admin_project_url for project='#{project}', args='#{args}'"
end
specific = project.specific
if specific.nil?
raise StandardError, "Invalid project with actable=nil: #{project}"
end
send("edit_admin_#{specific.model_name.name.underscore}_url".to_s, specific, *args)
send("edit_admin_#{project.actable_type.underscore}_url", project.actable_id, *args)
end
def new_admin_project_path(*args)
......@@ -199,12 +149,7 @@ module ActableHelper
raise StandardError, "Unable to reroute admin_offerer_path for offerer='#{offerer}', args='#{args}'" \
end
specific = offerer.specific
if specific.nil?
raise StandardError, "Invalid offerer with actable=nil: #{offerer}"
end
send("admin_#{specific.model_name.name.underscore}_path".to_s, specific, *args)
send("admin_#{offerer.actable_type.underscore}_path", offerer.actable_id, *args)
end
def admin_offerer_url(offerer, *args)
......@@ -214,11 +159,6 @@ module ActableHelper
raise StandardError, "Unable to reroute admin_offerer_url for offerer='#{offerer}', args='#{args}'" \
end
specific = offerer.specific
if specific.nil?
raise StandardError, "Invalid offerer with actable=nil: #{offerer}"
end
send("admin_#{specific.model_name.name.underscore}_url".to_s, specific, *args)
send("admin_#{offerer.actable_type.underscore}_url", offerer.actable_id, *args)
end
end
......@@ -318,19 +318,17 @@ module UserConcerns
end
def active_offerer_projects(offerer_type = nil)
Project.where(id: cliented_projects).or(Project.where(offerer_id: involved_offerers))
.where(offerer_id: Offerer.with_type(offerer_type))
.active
.joins(:course_edition)
.where(course_editions: { id: CourseEdition.active })
offerer_projects(offerer_type)
.active
.joins(:course_edition)
.where(course_editions: { id: CourseEdition.active })
end
def archived_offerer_projects(offerer_type = nil)
Project.where(id: cliented_projects).or(Project.where(offerer_id: involved_offerers))
.where(offerer_id: Offerer.with_type(offerer_type))
.active
.joins(:course_edition)
.where(course_editions: { id: CourseEdition.inactive })
offerer_projects(offerer_type)
.joins(:course_edition)
.where(course_editions: { id: CourseEdition.inactive })
.or(offerer_projects(offerer_type).deactivated)
end
def show_projects?
......
......@@ -11,4 +11,8 @@ class Tag < ApplicationRecord
def destroy_if_unassociated
destroy if taggings.empty?
end
scope :regular, (lambda {
where('name NOT LIKE \'%:%\'')
})
end
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