Browse Source

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

tags/v1
sylor_huang@126.com 6 years ago
parent
commit
db437eb191
2 changed files with 6 additions and 2 deletions
  1. +1
    -0
      app/models/concerns/publicable.rb
  2. +5
    -2
      app/models/project.rb

+ 1
- 0
app/models/concerns/publicable.rb 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

+ 5
- 2
app/models/project.rb 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

Loading…
Cancel
Save