首页只显示公开的项目
This commit is contained in:
parent
f073b66880
commit
e4ebf6e828
|
@ -4,19 +4,12 @@ class ProjectCategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_list
|
def group_list
|
||||||
# is_admin = current_user && current_user&.admin?
|
# if current_user&.logged?
|
||||||
# if is_admin
|
|
||||||
# projects = Project.all
|
|
||||||
# elsif current_user&.logged?
|
|
||||||
# projects = Project.list_user_projects(current_user.id)
|
# projects = Project.list_user_projects(current_user.id)
|
||||||
# else
|
# else
|
||||||
# projects = Project.visible
|
# projects = Project.visible
|
||||||
# end
|
# end
|
||||||
if current_user&.logged?
|
projects = Project.no_anomory_projects.visible
|
||||||
projects = Project.list_user_projects(current_user.id)
|
@category_group_list = projects.joins(:project_category).group("project_categories.id", "project_categories.name").size
|
||||||
else
|
|
||||||
projects = Project.visible
|
|
||||||
end
|
|
||||||
@category_group_list = projects.no_anomory_projects.joins(:project_category).group("project_categories.id", "project_categories.name").size
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,23 +40,13 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_type_list
|
def group_type_list
|
||||||
# is_admin = current_user && current_user&.admin?
|
# if current_user&.logged?
|
||||||
# if is_admin
|
|
||||||
# projects = Project.all
|
|
||||||
# elsif current_user&.logged?
|
|
||||||
#
|
|
||||||
# projects = Project.list_user_projects(current_user.id)
|
# projects = Project.list_user_projects(current_user.id)
|
||||||
# else
|
# else
|
||||||
# projects = Project.visible
|
# projects = Project.visible
|
||||||
# end
|
# end
|
||||||
#
|
projects = Project.no_anomory_projects.visible
|
||||||
if current_user&.logged?
|
@project_group_list = projects.group(:project_type).size
|
||||||
projects = Project.list_user_projects(current_user.id)
|
|
||||||
else
|
|
||||||
projects = Project.visible
|
|
||||||
end
|
|
||||||
# projects = Project.visible
|
|
||||||
@project_group_list = projects.no_anomory_projects.group(:project_type).size
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -10,20 +10,14 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
# if params[:is_admin]
|
|
||||||
# projects = Project.all
|
# if params[:user_id].to_i != 2 && params[:user_id].to_i != 0
|
||||||
# elsif params[:user_id].to_i != 2
|
|
||||||
# projects = Project.list_user_projects(params[:user_id])
|
# projects = Project.list_user_projects(params[:user_id])
|
||||||
# else
|
# else
|
||||||
# projects = Project.visible
|
# projects = Project.visible
|
||||||
# end
|
# end
|
||||||
|
projects = Project.no_anomory_projects.visible
|
||||||
if params[:user_id].to_i != 2 && params[:user_id].to_i != 0
|
scope = projects.includes(:project_category, :project_language, :repository, owner: :user_extension).like(params[:search])
|
||||||
projects = Project.list_user_projects(params[:user_id])
|
|
||||||
else
|
|
||||||
projects = Project.visible #匿名用户的项目
|
|
||||||
end
|
|
||||||
scope = projects.no_anomory_projects.includes(:project_category, :project_language, :repository, owner: :user_extension).like(params[:search])
|
|
||||||
.with_project_type(params[:project_type])
|
.with_project_type(params[:project_type])
|
||||||
.with_project_category(params[:category_id])
|
.with_project_category(params[:category_id])
|
||||||
.with_project_language(params[:language_id]).distinct
|
.with_project_language(params[:language_id]).distinct
|
||||||
|
|
Loading…
Reference in New Issue