diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index 653a688..16e4d40 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -2,23 +2,28 @@ module Management class UsersController < ManagementController def index - @profiles = current_conference.participant_profiles + @conference = find_conference + @profiles = @conference.participant_profiles end def toggle_admin - @user = find_user + @conference = find_conference + @user = find_user + @user.toggle_admin! redirect_to :back end def show - @user = find_user - @profile = @user.personal_profile(current_conference) + @conference = find_conference + @user = find_user + @profile = @user.personal_profile(@conference) end def edit - @user = find_user - @profile = @user.personal_profile(current_conference) + @conference = find_conference + @user = find_user + @profile = @user.personal_profile(@conference) end def update @@ -44,6 +49,10 @@ module Management User.find(params[:id]) end + def find_conference + Conference.find(params[:conference_id]) + end + def user_params params.require(:user).permit( :email, diff --git a/app/views/management/users/edit.html.slim b/app/views/management/users/edit.html.slim index 79abe42..078f276 100644 --- a/app/views/management/users/edit.html.slim +++ b/app/views/management/users/edit.html.slim @@ -4,12 +4,12 @@ .row .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-heading h1.panel-title = 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 .row diff --git a/app/views/management/users/index.html.slim b/app/views/management/users/index.html.slim index 3229a06..06e105c 100644 --- a/app/views/management/users/index.html.slim +++ b/app/views/management/users/index.html.slim @@ -27,9 +27,4 @@ td.actions 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' - = 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 + = action_buttons(@conference, user, [:show, :edit, :destroy]) diff --git a/app/views/management/users/show.html.slim b/app/views/management/users/show.html.slim index 0ec415e..1004508 100644 --- a/app/views/management/users/show.html.slim +++ b/app/views/management/users/show.html.slim @@ -7,7 +7,7 @@ .panel-heading h1.panel-title = @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 .center = image_tag @profile.picture.medium.url, class: "profile-image"