Redo projects list. Allow view projects through groups. Hide delete from project link from project owners. Refs #195
This commit is contained in:
parent
d3184b846b
commit
d44de9f2bb
|
@ -4,8 +4,8 @@ class ProjectsController < ApplicationController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@projects = current_user.projects.paginate(:page => params[:page])
|
||||
#@projects = @projects.search(params[:query]).search_order if params[:query]
|
||||
@projects = Project.accessible_by(current_ability, :members).recent.paginate(:page => params[:page])
|
||||
# @projects = @projects.search(params[:query]).search_order if params[:query]
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -30,8 +30,8 @@ class Ability
|
|||
cannot :create, RegisterRequest
|
||||
cannot :approve, RegisterRequest, :approved => true
|
||||
cannot :reject, RegisterRequest, :rejected => true
|
||||
cannot [:owned, :related], BuildList
|
||||
cannot [:owned, :related], Platform
|
||||
cannot [:owned, :related], [BuildList, Platform]
|
||||
cannot :members, Project
|
||||
end
|
||||
|
||||
if user.user?
|
||||
|
@ -50,7 +50,7 @@ class Ability
|
|||
can :read, Project, :visibility => 'open'
|
||||
can :read, Project, :owner_type => 'User', :owner_id => user.id
|
||||
can :read, Project, :owner_type => 'Group', :owner_id => user.group_ids
|
||||
can(:read, Project, read_relations_for('projects')) {|project| local_reader? project}
|
||||
can([:read, :members], Project, read_relations_for('projects')) {|project| local_reader? project}
|
||||
can(:write, Project) {|project| local_writer? project} # for grack
|
||||
can([:update, :sections, :manage_collaborators], Project) {|project| local_admin? project}
|
||||
can(:fork, Project) {|project| can? :read, project}
|
||||
|
|
|
@ -9,6 +9,7 @@ class Relation < ActiveRecord::Base
|
|||
# validate { errors.add(:object, :taken) if Relation.where(:object_type => self.object_type, :object_id => self.object_id).present? }
|
||||
before_validation :add_default_role
|
||||
|
||||
scope :by_user_through_groups, lambda {|u| where("object_type = 'User' AND object_id = ? OR object_type = 'Group' AND object_id IN (?)", u.id, u.group_ids)}
|
||||
scope :by_object, lambda {|obj| {:conditions => ['object_id = ? AND object_type = ?', obj.id, obj.class.to_s]}}
|
||||
scope :by_target, lambda {|tar| {:conditions => ['target_id = ? AND target_type = ?', tar.id, tar.class.to_s]}}
|
||||
scope :by_role, lambda {|role| {:conditions => ['role = ?', role]}}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
.table-sort-left= image_tag visibility_icon(project.visibility)
|
||||
.table-sort-right #{project.owner.uname} / #{project.name}
|
||||
%td.td2= project.description
|
||||
%td= t("layout.collaborators.role_names.#{project.relations.by_object(current_user).first.role}")
|
||||
%td.td5= link_to image_tag('x.png'), remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm")
|
||||
%td= t("layout.collaborators.role_names.#{project.relations.by_user_through_groups(current_user).first.role}")
|
||||
%td.td5= link_to image_tag('x.png'), remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") unless project.owner == current_user
|
Loading…
Reference in New Issue