You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
881 B
32 lines
881 B
class Project < ApplicationRecord
|
|
belongs_to :owner, class_name: 'User', foreign_key: :user_id
|
|
|
|
has_many :members
|
|
has_many :manager_members, -> { joins(:roles).where(roles: { name: 'Manager' }) }, class_name: 'Member'
|
|
has_one :project_score, dependent: :destroy
|
|
|
|
has_many :issues
|
|
has_many :user_grades, dependent: :destroy
|
|
has_many :attachments, as: :container, dependent: :destroy
|
|
has_one :project_score, dependent: :destroy
|
|
has_many :versions, -> { order("versions.effective_date DESC, versions.name DESC") }, dependent: :destroy
|
|
|
|
after_create do
|
|
SyncTrustieJob.perform_later("project", 1) if allow_sync_to_trustie?
|
|
end #同步到trustie
|
|
|
|
# 创建者
|
|
def creator
|
|
User.find(user_id).full_name
|
|
end
|
|
|
|
def project_members
|
|
self.members
|
|
end
|
|
|
|
def member?(user)
|
|
members.exists?(user_id: user.id)
|
|
end
|
|
|
|
end
|