diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index bb5107b..c1d75f4 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -14,10 +14,42 @@ module Management @profile = @user.speaker_profile 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 def find_user User.find(params[:id]) 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 diff --git a/app/views/management/users/edit.html.slim b/app/views/management/users/edit.html.slim new file mode 100644 index 0000000..c0316b9 --- /dev/null +++ b/app/views/management/users/edit.html.slim @@ -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' diff --git a/app/views/management/users/show.html.slim b/app/views/management/users/show.html.slim index 22b9aa2..d68b2dd 100644 --- a/app/views/management/users/show.html.slim +++ b/app/views/management/users/show.html.slim @@ -2,10 +2,14 @@ = @user.name .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 - // - if @profile.present? - // = image_tag(@profile.picture.medium.url) = @user.name - if @profile.present? diff --git a/config/locales/views.bg.yml b/config/locales/views.bg.yml index aefd993..bcb1c79 100644 --- a/config/locales/views.bg.yml +++ b/config/locales/views.bg.yml @@ -2,4 +2,6 @@ bg: views: conference: info: Информация за конференция - see_details: Повече информация \ No newline at end of file + see_details: Повече информация + user: + info: Информация за потребител diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index fbd6e96..60bbcc5 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -1,5 +1,7 @@ en: views: conference: - info: Details about conference - see_details: See details \ No newline at end of file + info: Conference details + see_details: See details + user: + info: User details