Commit 34c2d8e8 authored by Alex Denisov's avatar Alex Denisov

authorized_for scope added to project

parent 15a72a3b
...@@ -73,6 +73,7 @@ class Project < ActiveRecord::Base ...@@ -73,6 +73,7 @@ class Project < ActiveRecord::Base
scope :public_only, where(private_flag: false) scope :public_only, where(private_flag: false)
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
scope :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } }
class << self class << self
def active def active
......
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
&rarr; &rarr;
%span.last_activity %span.last_activity
%strong Projects: %strong Projects:
%span= group.projects.count %span= group.projects.authorized_for(current_user).count
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment