Merge branch 'pre_trustie_server' into trustie_server

# Conflicts:
#	app/models/issue.rb
#	app/models/journal.rb
This commit is contained in:
xxq250 2023-10-24 20:46:02 +08:00
commit 6a989f972a
3 changed files with 7 additions and 4 deletions

View File

@ -224,6 +224,9 @@ class AttachmentsController < ApplicationController
elsif @file.container.is_a?(Journal) elsif @file.container.is_a?(Journal)
project = @file.container.issue.project project = @file.container.issue.project
candown = project.is_public || (current_user.logged? && project.member?(current_user)) candown = project.is_public || (current_user.logged? && project.member?(current_user))
elsif @file.container.is_a?(Project)
project = @file.container
candown = project.is_public || (current_user.logged? && project.member?(current_user))
else else
project = nil project = nil
end end

View File

@ -228,11 +228,11 @@ class Issue < ApplicationRecord
att_ids += self.description.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]} att_ids += self.description.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]}
att_ids += self.description.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]} att_ids += self.description.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]}
if att_ids.present? if att_ids.present?
Attachment.where(id: att_ids).where(container_type: nil).update_all(container_id: self.id, container_type: self.class.name) Attachment.where(id: att_ids).where("container_type IS NULL OR container_type = 'Issue'").update_all(container_id: self.project_id, container_type: "Project")
end end
end end
def to_builder def to_builder
Jbuilder.new do |issue| Jbuilder.new do |issue|
issue.(self, :id, :project_issues_index, :subject, :description, :branch_name, :start_date, :due_date) issue.(self, :id, :project_issues_index, :subject, :description, :branch_name, :start_date, :due_date)
issue.created_at self.created_on.strftime("%Y-%m-%d %H:%M") issue.created_at self.created_on.strftime("%Y-%m-%d %H:%M")

View File

@ -67,11 +67,11 @@ class Journal < ApplicationRecord
att_ids += self.notes.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]} att_ids += self.notes.to_s.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]}
att_ids += self.notes.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]} att_ids += self.notes.to_s.scan(/\/api\/attachments\/\d+/).map{|s|s.match(/\d+/)[0]}
if att_ids.present? if att_ids.present?
Attachment.where(id: att_ids).where(container_type: nil).update_all(container_id: self.id, container_type: self.class.name) Attachment.where(id: att_ids).where("container_type IS NULL OR container_type = 'Journal'").update_all(container_id: self.issue.project_id, container_type: "Project")
end end
end end
def operate_content def operate_content
content = "" content = ""
detail = self.journal_details.take detail = self.journal_details.take
case detail.property case detail.property