修改项目成员可以项目的问题

This commit is contained in:
sylor_huang@126.com 2020-04-03 17:55:13 +08:00
parent bfbcb350f7
commit db437eb191
2 changed files with 6 additions and 2 deletions

View File

@ -3,5 +3,6 @@ module Publicable
included do
scope :visible, -> { where(is_public: true) }
scope :is_private, -> {where(is_public: false)}
end
end

View File

@ -100,8 +100,11 @@ class Project < ApplicationRecord
end
def self.list_user_projects(user_id)
user_not_show = Project.joins(:members).where("projects.is_public = ? and projects.user_id != ? and members.user_id != ?", false, user_id,user_id).pluck(:id).uniq
Project.where.not(id: user_not_show)
projects = Project.is_private.select(:id)
user_not_show_1 = projects.where(user_id: user_id).pluck(:id).uniq
user_show_2 = projects.joins(:members).where("members.user_id = ?", user_id).pluck(:id).uniq
Project.where.not(id: (user_not_show_1 - user_show_2.uniq))
end
end