Commit 34c2d8e82eec046bd73a2ed145210bdc83bbe90e

Authored by Alex Denisov
1 parent 15a72a3b

authorized_for scope added to project

app/models/project.rb
@@ -73,6 +73,7 @@ class Project < ActiveRecord::Base @@ -73,6 +73,7 @@ class Project < ActiveRecord::Base
73 scope :public_only, where(private_flag: false) 73 scope :public_only, where(private_flag: false)
74 scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } 74 scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
75 scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } 75 scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
  76 + scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } }
76 77
77 class << self 78 class << self
78 def active 79 def active
app/views/dashboard/_groups.html.haml
@@ -17,4 +17,4 @@ @@ -17,4 +17,4 @@
17 &rarr; 17 &rarr;
18 %span.last_activity 18 %span.last_activity
19 %strong Projects: 19 %strong Projects:
20 - %span= group.projects.count 20 + %span= group.projects.authorized_for(current_user).count