Simple user updating
This will probably not be done through management, but 1) there should still be a way to update a user through the management interface, and 2) it'll be easy to copy this code over to the public interface later.
This commit is contained in:
parent
2b64461ac9
commit
cddab7a27e
|
@ -14,10 +14,42 @@ module Management
|
||||||
@profile = @user.speaker_profile
|
@profile = @user.speaker_profile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_user
|
def find_user
|
||||||
User.find(params[:id])
|
User.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
- content_for :title
|
||||||
|
=> t 'actions.edit.title', model: User.model_name.human
|
||||||
|
= @user.name
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
= simple_nested_form_for [:management, @user], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
||||||
|
.panel.panel-primary
|
||||||
|
.panel-heading
|
||||||
|
h1.panel-title = t 'views.user.info'
|
||||||
|
|
||||||
|
.panel-body
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
= f.input :email
|
||||||
|
hr
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
= f.simple_fields_for :speaker_profile do |ff|
|
||||||
|
= ff.input :picture, wrapper: :horizontal_file_input
|
||||||
|
|
||||||
|
-# Required
|
||||||
|
= ff.input :first_name
|
||||||
|
= ff.input :last_name
|
||||||
|
= ff.input :mobile_phone
|
||||||
|
= ff.input :biography
|
||||||
|
|
||||||
|
-# Optional
|
||||||
|
= ff.input :organisation
|
||||||
|
= ff.input :public_email
|
||||||
|
= ff.input :github
|
||||||
|
= ff.input :twitter
|
||||||
|
|
||||||
|
.panel-footer.text-right
|
||||||
|
= f.submit class: 'btn btn-primary'
|
|
@ -2,10 +2,14 @@
|
||||||
= @user.name
|
= @user.name
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-lg-12
|
.col-lg-2
|
||||||
|
- if @profile.present? and @profile.picture.present?
|
||||||
|
= image_tag(@profile.picture.medium.url)
|
||||||
|
- else
|
||||||
|
-# TODO photo placeholder, default user image
|
||||||
|
|
||||||
|
.col-lg-10
|
||||||
h1.page-header
|
h1.page-header
|
||||||
// - if @profile.present?
|
|
||||||
// = image_tag(@profile.picture.medium.url)
|
|
||||||
= @user.name
|
= @user.name
|
||||||
|
|
||||||
- if @profile.present?
|
- if @profile.present?
|
||||||
|
|
|
@ -3,3 +3,5 @@ bg:
|
||||||
conference:
|
conference:
|
||||||
info: Информация за конференция
|
info: Информация за конференция
|
||||||
see_details: Повече информация
|
see_details: Повече информация
|
||||||
|
user:
|
||||||
|
info: Информация за потребител
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
en:
|
en:
|
||||||
views:
|
views:
|
||||||
conference:
|
conference:
|
||||||
info: Details about conference
|
info: Conference details
|
||||||
see_details: See details
|
see_details: See details
|
||||||
|
user:
|
||||||
|
info: User details
|
||||||
|
|
Loading…
Reference in New Issue