25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/issue_tags_controller.rb', line 25
def update
if AdditionalTags.setting?(:active_issue_tags) &&
User.current.allowed_to?(:edit_issue_tags, @projects.first)
tags = params[:issue] && params[:issue][:tag_list] ? params[:issue][:tag_list].reject(&:empty?) : []
unless User.current.allowed_to?(:create_issue_tags, @projects.first) || Issue.allowed_tags?(tags)
flash[:error] = t :notice_failed_to_add_tags
return
end
Issue.transaction do
@issues.each do |issue|
issue.init_journal User.current
params[:append] == 'true' ? issue.tag_list << tags : issue.tag_list = tags
issue.tags_to_journal issue.tag_list_was&.to_s, issue.tag_list.to_s
issue.save!
end
end
flash[:notice] = t :notice_tags_added
else
flash[:error] = t :notice_failed_to_add_tags
end
rescue StandardError => e
Rails.logger.warn "Failed to add tags: #{e.inspect}"
flash[:error] = t :notice_failed_to_add_tags
ensure
redirect_to_referer_or { render text: 'Tags updated.', layout: true }
end
|