[refs #2249] Some ACL changes

This commit is contained in:
konstantin.grabar 2011-12-01 13:29:04 +04:00
parent e45ba6692a
commit 6d8e4f98b9
7 changed files with 27 additions and 0 deletions

View File

@ -32,6 +32,8 @@ gem 'delayed_job'
# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.git'
gem "rails-xmlrpc", '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git'
gem 'rails3-jquery-autocomplete'
group :production do
gem "airbrake", '~> 3.0.5'
# gem 'newrelic_rpm', '~> 3.1.1'

View File

@ -145,6 +145,8 @@ GEM
rails-xmlrpc (0.3.6)
rails3-generators (0.17.4)
railties (>= 3.0.0)
rails3-jquery-autocomplete (1.0.4)
rails (~> 3.0)
railties (3.0.11)
actionpack (= 3.0.11)
activesupport (= 3.0.11)
@ -225,6 +227,7 @@ DEPENDENCIES
rails (= 3.0.11)
rails-xmlrpc (~> 0.3.6)
rails3-generators
rails3-jquery-autocomplete
rr
rspec-rails (~> 2.7.0)
ruby-debug

View File

@ -5,6 +5,7 @@ class PlatformsController < ApplicationController
before_filter :get_paths, :only => [:new, :create, :clone]
load_and_authorize_resource
autocomplete :user, :uname
def build_all
@platform.repositories.each do |repository|

View File

@ -6,6 +6,7 @@ class Product < ActiveRecord::Base
after_validation :merge_tar_errors
before_save :destroy_tar?
after_create :add_admin_relations
has_attached_file :tar
@ -76,4 +77,11 @@ class Product < ActiveRecord::Base
errors[:tar_content_type] = []
end
def add_admin_relations
repository.relations.where(:role => 'admin').each do |rel|
r = relations.build(:role => 'admin', :object_id => rel.object_id, :object_type => rel.object_type)
r.save
end
end
end

View File

@ -18,6 +18,7 @@ class Repository < ActiveRecord::Base
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy
after_create :add_admin_relation
attr_accessible :description, :name #, :platform_id
@ -50,4 +51,11 @@ class Repository < ActiveRecord::Base
raise "Failed to delete repository #{name} inside platform #{platform.name}."
end
end
def add_admin_relations
platform.relations.where(:role => 'admin').each do |rel|
r = relations.build(:role => 'admin', :object_id => rel.object_id, :object_type => rel.object_type)
r.save
end
end
end

View File

@ -17,6 +17,10 @@
.group
= f.label :released, :class => :label
= f.check_box :released, :class => 'check_box'
.group
= label_tag "ID Хозяина", :class => :label
= autocomplete_field_tag 'admin_id', '', user_name_autocomplete_path, :class => 'text_field'
.group.navform.wat-cf
%button.button{:type => "submit"}

View File

@ -48,6 +48,7 @@ Rosa::Application.routes.draw do
collection do
get 'easy_urpmi'
get :autocomplete_user_uname
end
resources :products do