Merge branch 'master' of github.com:warpc/rosa-build
This commit is contained in:
commit
e0e0dd1fed
|
@ -67,10 +67,27 @@ class MembersController < ApplicationController
|
|||
def destroy
|
||||
end
|
||||
|
||||
def add
|
||||
if params['user_id'] and !params['user_id'].empty?
|
||||
@user = User.find_by_uname(params['user_id'])
|
||||
unless parent.objects.exists? :object_id => @user.id, :object_type => 'User'
|
||||
relation = parent.objects.build(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
if relation.save
|
||||
flash[:notice] = t("flash.members.successfully_added")
|
||||
else
|
||||
flash[:error] = t("flash.members.error_in_adding")
|
||||
end
|
||||
else
|
||||
flash[:error] = t("flash.members.already_added")
|
||||
end
|
||||
end
|
||||
redirect_to edit_group_members_path(parent)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_users
|
||||
@users = User.all
|
||||
@users = parent.members #User.all
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ class UsersController < ApplicationController
|
|||
before_filter :find_user, :only => [:show, :edit, :update, :destroy]
|
||||
|
||||
load_and_authorize_resource
|
||||
autocomplete :user, :uname
|
||||
|
||||
def index
|
||||
@users = User.paginate(:page => params[:user_page])
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
= link_to user.name, user_path(user)
|
||||
%td
|
||||
- Relation::ROLES.each do |role|
|
||||
= check_box_tag "#{ role }[#{user.id}]", '1', ((parent.relations.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"}
|
||||
= check_box_tag "#{ role }[#{user.id}]", '1', ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"}
|
||||
= label_tag "#{ role }[#{user.id}]", t("layout.members.roles.#{ role }")
|
||||
%td
|
||||
= user.uname
|
||||
|
@ -33,3 +33,15 @@
|
|||
%span.text_button_padding= t("layout.or")
|
||||
= link_to t("layout.cancel"), group_path(parent), :class => "text_button_padding link_button"
|
||||
|
||||
= form_tag add_group_members_path(parent) do
|
||||
= javascript_include_tag 'autocomplete-rails.js'
|
||||
.group
|
||||
%h2.title= t("layout.members.add_member")
|
||||
= label_tag "", t("layout.members.input_username")
|
||||
= autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path
|
||||
%br
|
||||
.group.navform.wat-cf
|
||||
%button.button{:type => "submit"}
|
||||
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.add"))
|
||||
= t("layout.add")
|
||||
|
||||
|
|
|
@ -227,6 +227,8 @@ ru:
|
|||
back_to_group: Вернуться к группе
|
||||
edit: Редактировать список
|
||||
roles: Роли
|
||||
add_member: Добавить участника
|
||||
input_username: Псевдоним пользователя
|
||||
|
||||
groups:
|
||||
list: Список
|
||||
|
@ -334,6 +336,9 @@ ru:
|
|||
members:
|
||||
successfully_changed: Список участников успешно изменен
|
||||
error_in_changing: Ошибка изменения списка участников
|
||||
successfully_added: Участник успешно добавлен
|
||||
error_in_adding: Ошибка при добавлении участника
|
||||
already_added: Пользователь уже добавлен
|
||||
|
||||
auto_build_list:
|
||||
success: Сборка проекта автоматизорована!
|
||||
|
|
|
@ -8,6 +8,9 @@ Rosa::Application.routes.draw do
|
|||
|
||||
resources :users do
|
||||
resources :groups, :only => [:new, :create, :index]
|
||||
collection do
|
||||
get :autocomplete_user_uname
|
||||
end
|
||||
end
|
||||
|
||||
resources :event_logs, :only => :index
|
||||
|
@ -108,9 +111,10 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
|
||||
resources :groups do
|
||||
resources :members, :only => [:index, :edit, :update] do
|
||||
resources :members, :only => [:index, :edit, :update, :add] do
|
||||
collection do
|
||||
get :edit
|
||||
post :add
|
||||
post :update
|
||||
end
|
||||
member do
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
require 'highline/import'
|
||||
require 'open-uri'
|
||||
|
||||
namespace :import do
|
||||
desc "Load projects"
|
||||
task :projects => :environment do
|
||||
owner = User.find_by_uname(ENV['OWNER_UNAME']) || Group.find_by_uname(ENV['OWNER_UNAME']) || User.first
|
||||
platform = Platform.find_by_name(ENV['PLATFORM_NAME']) # 'mandriva2011'
|
||||
repo = platform.repositories.first rescue nil
|
||||
say "START import projects for '#{owner.uname}'.#{repo ? " To repo '#{platform.name}/#{repo.name}'." : ''}"
|
||||
ask 'Press enter to continue'
|
||||
open('http://dl.dropbox.com/u/984976/package_list.txt').readlines.each do |name|
|
||||
name.chomp!; name.strip! #; name.downcase!
|
||||
# name = name.match(/^([a-z\d_\-\+\.]+?)-(\d[a-z\d\-\.]+)\.src\.rpm$/)[1] # parse
|
||||
print "Import #{name}..."
|
||||
owner = User.find(1) # I am
|
||||
# owner = Group.find(1) # Core Team
|
||||
p = Project.find_or_create_by_name(name) {|p| p.owner = owner}
|
||||
puts p.persisted? ? "Ok!" : "Fail!"
|
||||
print "Import '#{name}'..."
|
||||
p = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
||||
print p.persisted? ? "Ok!" : "Fail!"
|
||||
if repo
|
||||
print " Add to repo '#{platform.name}/#{repo.name}'."
|
||||
repo.projects << p rescue print ' Fail!'
|
||||
end
|
||||
puts 'DONE'
|
||||
puts
|
||||
end
|
||||
say 'DONE'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe MembersController do
|
||||
|
||||
before(:each) do
|
||||
@group = Factory(:group)
|
||||
@user = @group.owner
|
||||
@another_user = Factory(:user)
|
||||
@add_params = {:group_id => @group.id, :user_id => @another_user.uname}
|
||||
end
|
||||
|
||||
context 'for owner user' do
|
||||
it 'should add member to group' do
|
||||
post :add, @add_params
|
||||
response.should redirect_to(:edit)
|
||||
Relation.by_target(@group).by_object(@another_user).count.should eql(1)
|
||||
end
|
||||
|
||||
it 'should add reader member to group' do
|
||||
post :add, @add_params
|
||||
Relation.by_target(@group).by_object(@another_user).role.should eql('reader')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue