Merge pull request #721 from warpc/member_add_message

[refs #721] Fix 500 for member add action in group and platform
This commit is contained in:
Vladimir Sharshov 2012-11-14 02:03:39 -08:00
commit 76860a0df1
5 changed files with 17 additions and 14 deletions

View File

@ -38,13 +38,13 @@ class Groups::MembersController < Groups::BaseController
end
def add
if params['user_id'].present?
@user = User.find_by_uname(params['user_id'])
if parent.add_member(@user, params[:role])
flash[:notice] = t("flash.members.successfully_added")
else
flash[:error] = t("flash.members.error_in_adding")
end
@user = User.find_by_uname(params[:user_uname])
if !@user
flash[:error] = t("flash.collaborators.wrong_user", :uname => params[:user_uname])
elsif parent.add_member(@user, params[:role])
flash[:notice] = t("flash.members.successfully_added")
else
flash[:error] = t("flash.members.error_in_adding")
end
redirect_to group_members_path(parent)
end

View File

@ -96,12 +96,13 @@ class Platforms::PlatformsController < Platforms::BaseController
end
def add_member
if member = User.where(:id => params[:member_id]).first
if @platform.add_member(member)
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
else
flash[:error] = t('flash.platform.members.error_in_adding', :name => member.uname)
end
member = User.where(:id => params[:member_id]).first
if !member
flash[:error] = t("flash.collaborators.wrong_user", :uname => params[:member_id])
elsif @platform.add_member(member)
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
else
flash[:error] = t('flash.platform.members.error_in_adding', :name => member.uname)
end
redirect_to members_platform_url(@platform)
end

View File

@ -25,7 +25,7 @@
.hr.top
= form_tag add_group_members_path(parent) do
.admin-search= autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_autocompletes_path#, :id_element => '#member_id_field'
.admin-search= autocomplete_field_tag 'user_uname', params[:user_uname], autocomplete_user_uname_autocompletes_path
.admin-role
.lineForm= select_tag 'role', options_for_collaborators_roles_select
.both

View File

@ -148,6 +148,7 @@ en:
group_already_added: Group already added
successfully_added: Member %s successfully added
error_in_adding: Member %s adding error
wrong_user: User with nickname '%{uname}' not found!
blob:
successfully_updated: File '%{name}' successfully updated

View File

@ -148,6 +148,7 @@ ru:
group_already_added: Группа уже добавлена
successfully_added: Участник %s успешно добавлен
error_in_adding: Ошибка при добавлении участника %s
wrong_user: Пользователь с ником '%{uname}' не найден.
blob:
successfully_updated: Файл '%{name}' успешно обновлен