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

Merge branch 'development' into 'master'

Project Forum Release v2.8.9 - 13-09-2022

See merge request !866
parents 01ce4156 4090baff
......@@ -87,6 +87,8 @@ module Admin
@course_edition.course_specific_roles.push csr.dup
end
@override_tags = old_course_edition.tags.sort_by_name
@override_staff_roles = {}
old_course_edition.staffmembers.each do |staffmember|
r = nil
......
......@@ -136,6 +136,7 @@ class Project < ApplicationRecord
end
copy_recurrent_course_specific_roles(course_edition, new_project, validation_attribute, validation_object)
copy_recurrent_tags(course_edition, new_project, validation_attribute, validation_object)
User.with_role(:client, self).each do |user|
user.add_role(:client, new_project)
......@@ -487,4 +488,15 @@ class Project < ApplicationRecord
"the '#{display_name}' project"
end
end
def copy_recurrent_tags(course_edition, new_project, validation_attribute, validation_object)
if course_edition.tags.map(&:id).sort != self.course_edition.tags.map(&:id).sort
validation_object.errors.add validation_attribute,
"'#{course_edition.display_name}' must have identical project tags " \
"to '#{self.course_edition.display_name}'"
return
end
new_project.tags = tags.to_a
end
end
......@@ -22,6 +22,12 @@
<% end %>
<% end %>
<% @override_tags&.each do |tag| %>
<%= f_tags.fields_for (tag.id + 1000000).to_s, tag do |f_tag| %>
<%= render 'admin/application/tag_fields_new', f: f_tag %>
<% end %>
<% end %>
<a class="list-group-item list-group-item--button add_fields" data-association-insertion-node="this"
data-association="tag" data-associations="tags" id="tag_add"
data-association-insertion-template="
......
class FixRecurrentProjectTags < ActiveRecord::Migration[6.1]
def up
# Copy tags of recurrent course editions to descendent editions
CourseEdition.recurrent.each do |recurrent_edition|
CourseEdition.descendants_of(recurrent_edition).each do |edition|
recurrent_edition.tags.each do |tag|
edition.tags << tag
end
edition.save!
end
end
# Copy recurrent project tags
CourseEdition.recurrent.each do |recurrent_edition|
recurrent_edition.projects.each do |recurrent_project|
recurrent_project.copies.each do |project|
recurrent_project.tags.each do |tag|
project.tags << tag
end
project.save!
end
end
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_08_30_133912) do
ActiveRecord::Schema.define(version: 2022_09_15_114808) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
......
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