Fix issue with user actions

This commit is contained in:
Andrew Radev 2015-07-26 14:58:56 +03:00
parent 8f2707ffe7
commit fd6317566d
4 changed files with 19 additions and 15 deletions

View File

@ -2,23 +2,28 @@
module Management module Management
class UsersController < ManagementController class UsersController < ManagementController
def index def index
@profiles = current_conference.participant_profiles @conference = find_conference
@profiles = @conference.participant_profiles
end end
def toggle_admin def toggle_admin
@conference = find_conference
@user = find_user @user = find_user
@user.toggle_admin! @user.toggle_admin!
redirect_to :back redirect_to :back
end end
def show def show
@conference = find_conference
@user = find_user @user = find_user
@profile = @user.personal_profile(current_conference) @profile = @user.personal_profile(@conference)
end end
def edit def edit
@conference = find_conference
@user = find_user @user = find_user
@profile = @user.personal_profile(current_conference) @profile = @user.personal_profile(@conference)
end end
def update def update
@ -44,6 +49,10 @@ module Management
User.find(params[:id]) User.find(params[:id])
end end
def find_conference
Conference.find(params[:conference_id])
end
def user_params def user_params
params.require(:user).permit( params.require(:user).permit(
:email, :email,

View File

@ -4,12 +4,12 @@
.row .row
.col-lg-12 .col-lg-12
= simple_nested_form_for [:management, @user], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f| = simple_nested_form_for [:management, @conference, @user], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
.panel.panel-primary .panel.panel-primary
.panel-heading .panel-heading
h1.panel-title h1.panel-title
= t 'views.user.info' = t 'views.user.info'
= link_to icon(:eye), [:management, @user], class: 'btn btn-xs btn-info pull-right' = link_to icon(:eye), [:management, @conference, @user], class: 'btn btn-xs btn-info pull-right'
.panel-body .panel-body
.row .row

View File

@ -27,9 +27,4 @@
td.actions td.actions
div.btn-group.btn-group-sm div.btn-group.btn-group-sm
= link_to management_user_path(user), title: t('actions.view.button', model: User.model_name.human), class: 'btn btn-info' = action_buttons(@conference, user, [:show, :edit, :destroy])
= icon :eye
= link_to edit_management_user_path(user), title: t('actions.edit.button', model: User.model_name.human), class: 'btn btn-primary'
= icon :edit
= link_to management_user_path(user), title: t('actions.destroy.button', model: User.model_name.human), class: ['btn', 'btn-danger'], method: :delete, data: {confirm: t('actions.are_you_sure')}
= icon :trash

View File

@ -7,7 +7,7 @@
.panel-heading .panel-heading
h1.panel-title h1.panel-title
= @profile.name = @profile.name
= link_to icon(:edit), edit_management_user_path(@user), class: 'btn btn-xs btn-danger pull-right' = link_to icon(:edit), [:edit, :management, @conference, @user], class: 'btn btn-xs btn-danger pull-right'
.panel-body .panel-body
.center .center
= image_tag @profile.picture.medium.url, class: "profile-image" = image_tag @profile.picture.medium.url, class: "profile-image"