mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-17 02:05:58 +08:00
add: user pinned projects
This commit is contained in:
@@ -164,6 +164,9 @@ class User < Owner
|
||||
|
||||
has_many :organization_users, dependent: :destroy
|
||||
has_many :organizations, through: :organization_users
|
||||
has_many :pinned_projects, dependent: :destroy
|
||||
has_many :is_pinned_projects, through: :pinned_projects, source: :project
|
||||
accepts_nested_attributes_for :is_pinned_projects
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||
@@ -195,6 +198,13 @@ class User < Owner
|
||||
validate :validate_sensitive_string
|
||||
validate :validate_password_length
|
||||
|
||||
# 用户参与的所有项目
|
||||
def full_member_projects
|
||||
normal_projects = Project.members_projects(self.id).to_sql
|
||||
org_projects = Project.joins(team_projects: [team: :team_users]).where(team_users: {user_id: self.id}).to_sql
|
||||
return Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
|
||||
end
|
||||
|
||||
def name
|
||||
login
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user