Merge pull request '新增 uuid' (#229) from KingChan/forgeplus:pm_project_develop into pm_project_develop
This commit is contained in:
commit
6ae4aded65
|
@ -147,7 +147,7 @@ class AttachmentsController < ApplicationController
|
|||
if params[:type] == 'history'
|
||||
AttachmentHistory.find params[:id]
|
||||
else
|
||||
Attachment.find params[:id]
|
||||
Attachment.find params[:id] || Attachment.find_by(uuid: params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -218,7 +218,7 @@ class AttachmentsController < ApplicationController
|
|||
def attachment_candown
|
||||
unless current_user.admin? || current_user.business?
|
||||
candown = true
|
||||
if @file.container
|
||||
if @file.container && @file.uuid.nil?
|
||||
if @file.container.is_a?(Issue)
|
||||
project = @file.container.project
|
||||
candown = project.is_public || (current_user.logged? && project.member?(current_user))
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# delay_publish :boolean default("0")
|
||||
# memo_image :boolean default("0")
|
||||
# extra_type :integer default("0")
|
||||
# uuid :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -97,6 +98,11 @@ class Attachment < ApplicationRecord
|
|||
downloads
|
||||
end
|
||||
|
||||
def generate_uuid
|
||||
self.uuid = uuid || SecureRandom.uuid
|
||||
save!
|
||||
end
|
||||
|
||||
def quotes_count
|
||||
quotes.nil? ? 0 : quotes
|
||||
end
|
||||
|
|
|
@ -103,7 +103,7 @@ class Issue < ApplicationRecord
|
|||
scope :closed, ->{where(status_id: 5)}
|
||||
scope :opened, ->{where.not(status_id: 5)}
|
||||
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic
|
||||
after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container, :refresh_root_issue_count
|
||||
after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container, :refresh_root_issue_count, :generate_uuid
|
||||
after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic
|
||||
|
||||
def incre_project_common
|
||||
|
@ -187,6 +187,11 @@ class Issue < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def generate_uuid
|
||||
return if pm_project_id.nil?
|
||||
attachments.map(&:generate_uuid)
|
||||
end
|
||||
|
||||
def is_collaborators?
|
||||
if self.assigned_to_id.present? && self.project.present?
|
||||
self.project.member?(self.assigned_to_id)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddUuidToAttachments < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :attachments, :uuid, :string, index: true
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue