Merge branch '195-new_design_for_projects' of github.com:warpc/rosa-build into 195-new_design_for_projects

This commit is contained in:
George Vinogradov 2012-03-25 01:38:32 +04:00
commit d03f364b18
4 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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}

View File

@ -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]}}

View File

@ -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