show expected message after add member error

This commit is contained in:
Alexander Machehin 2012-11-13 20:29:45 +06:00
parent 4d58ff5019
commit 21a32fba6c
4 changed files with 16 additions and 13 deletions

View File

@ -38,14 +38,14 @@ 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])
@user = User.find_by_uname(params[:user_id])
if !@user
flash[:error] = t("flash.collaborators.wrong_user", :uname => params[:user_id])
elsif parent.add_member(@user, params[:role])
flash[:notice] = t("flash.members.successfully_added")
else
flash[:error] = t("flash.members.error_in_adding")
end
end
redirect_to group_members_path(parent)
end
end

View File

@ -96,13 +96,14 @@ class Platforms::PlatformsController < Platforms::BaseController
end
def add_member
if member = User.where(:id => params[:member_id]).first
if @platform.add_member(member)
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
end
redirect_to members_platform_url(@platform)
end

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}' успешно обновлен