2014-09-17 14:23:36 +03:00
|
|
|
module Management
|
|
|
|
class UsersController < ManagementController
|
|
|
|
def index
|
|
|
|
@users = User.all
|
|
|
|
end
|
|
|
|
|
|
|
|
def toggle_admin
|
2015-05-10 13:36:29 +03:00
|
|
|
@user = find_user
|
2014-09-17 17:48:46 +03:00
|
|
|
@user.toggle_admin!
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2015-05-10 13:36:29 +03:00
|
|
|
@user = find_user
|
|
|
|
@profile = @user.speaker_profile
|
2014-09-17 14:23:36 +03:00
|
|
|
end
|
|
|
|
|
2015-05-24 12:28:05 +03:00
|
|
|
def edit
|
|
|
|
@user = find_user
|
|
|
|
@user.build_speaker_profile
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@user = find_user
|
|
|
|
|
|
|
|
if @user.update_attributes(user_params)
|
|
|
|
redirect_to [:management, @user]
|
|
|
|
else
|
|
|
|
render action: 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-17 14:23:36 +03:00
|
|
|
private
|
|
|
|
|
2015-05-10 13:36:29 +03:00
|
|
|
def find_user
|
|
|
|
User.find(params[:id])
|
2014-09-17 14:23:36 +03:00
|
|
|
end
|
2015-05-24 12:28:05 +03:00
|
|
|
|
|
|
|
def user_params
|
|
|
|
params.require(:user).permit(
|
|
|
|
:email,
|
|
|
|
speaker_profile_attributes: [
|
|
|
|
:picture,
|
|
|
|
:first_name,
|
|
|
|
:last_name,
|
|
|
|
:mobile_phone,
|
|
|
|
:biography,
|
|
|
|
:organisation,
|
|
|
|
:public_email,
|
|
|
|
:github,
|
|
|
|
:twitter,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
2014-09-17 14:23:36 +03:00
|
|
|
end
|
|
|
|
end
|