forked from Gitlink/forgeplus
[FIX]join projects add org projects and update project private bug
This commit is contained in:
parent
11471b1520
commit
f7b7122d60
|
@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
|
|||
default_branch: params[:default_branch]
|
||||
}
|
||||
if [true, false].include? private
|
||||
new_project_params = project_params.merge(is_public: !private)
|
||||
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||
Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
|
||||
@project.repository.update_column(:hidden, private)
|
||||
end
|
||||
|
|
|
@ -17,15 +17,12 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
projects = Project.visible
|
||||
end
|
||||
|
||||
if params[:is_public].present?
|
||||
projects = projects.is_private.members_projects(user.id) if params[:is_public].to_s == "private"
|
||||
projects = projects.visible.members_projects(user.id) if params[:is_public].to_s == "public"
|
||||
end
|
||||
|
||||
if params[:category].blank?
|
||||
projects = projects.members_projects(user.id)
|
||||
elsif params[:category].to_s == "join"
|
||||
projects = projects.where.not(user_id: user.id).members_projects(user.id)
|
||||
normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql
|
||||
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
|
||||
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
|
||||
elsif params[:category].to_s == "manage"
|
||||
projects = projects.where(user_id: user.id)
|
||||
elsif params[:category].to_s == "watched" #我关注的
|
||||
|
@ -39,6 +36,11 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
# projects = projects.is_private.joins(:members).where(members: { user_id: user.id })
|
||||
end
|
||||
|
||||
if params[:is_public].present?
|
||||
projects = projects.is_private if params[:is_public].to_s == "private"
|
||||
projects = projects.visible if params[:is_public].to_s == "public"
|
||||
end
|
||||
|
||||
if params[:project_type].to_s === "common"
|
||||
projects = projects.common
|
||||
elsif params[:project_type].to_s === "mirror"
|
||||
|
|
Loading…
Reference in New Issue