Merge pull request #977 from differentreality/fix_admin_registrations
fix admin/registrations#update
This commit is contained in:
commit
65ee166570
4 changed files with 20 additions and 12 deletions
|
|
@ -14,6 +14,8 @@ module Admin
|
||||||
def edit; end
|
def edit; end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@user.update_attributes(user_params)
|
||||||
|
|
||||||
@registration.update_attributes(registration_params)
|
@registration.update_attributes(registration_params)
|
||||||
if @registration.save
|
if @registration.save
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title),
|
redirect_to admin_conference_registrations_path(@conference.short_title),
|
||||||
|
|
@ -51,11 +53,14 @@ module Admin
|
||||||
@user = User.find_by(id: @registration.user_id)
|
@user = User.find_by(id: @registration.user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
params.require(:user).permit(:name, :nickname, :affiliation)
|
||||||
|
end
|
||||||
|
|
||||||
def registration_params
|
def registration_params
|
||||||
params.require(:registration).permit(:user_id, :conference_id, :arrival, :departure, :attended,
|
params.require(:registration).permit(:user_id, :conference_id, :arrival, :departure, :attended,
|
||||||
:volunteer, :other_special_needs,
|
:volunteer, :other_special_needs,
|
||||||
vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], event_ids: [],
|
vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], event_ids: [])
|
||||||
user_attributes: [:nickname, :name, :affiliation, :tshirt, :mobile, :volunteer_experience, :languages])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@
|
||||||
.col-md-12
|
.col-md-12
|
||||||
.page-header
|
.page-header
|
||||||
%h1
|
%h1
|
||||||
Registration for #{@user.username}
|
Registration for #{@user.username} (#{@user.email})
|
||||||
|
|
||||||
|
= link_to 'Edit User', edit_admin_user_path(@user), class: 'btn btn-primary pull-right' if can? :edit, @user
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
= semantic_form_for(@registration, url: admin_conference_registration_path(@conference.short_title, @registration)) do |f|
|
= semantic_form_for(@registration, url: admin_conference_registration_path(@conference.short_title, @registration)) do |f|
|
||||||
= f.inputs 'Personal Information' do
|
= f.inputs 'Personal Information' do
|
||||||
= f.fields_for :user do |u|
|
= semantic_fields_for :user do |u|
|
||||||
= u.input :name, as: :string
|
= u.input :name, as: :string
|
||||||
= u.input :nickname, as: :string
|
= u.input :nickname, as: :string
|
||||||
= u.input :affiliation, placeholder: 'Company/User Group/nothing', as: :string
|
= u.input :affiliation, placeholder: 'Company/User Group/nothing', as: :string
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,11 @@
|
||||||
%td
|
%td
|
||||||
= registration.id
|
= registration.id
|
||||||
%td
|
%td
|
||||||
= registration.name
|
= registration.name.present? ? registration.name : registration.username
|
||||||
- registration.user.roles.each do |role|
|
%br
|
||||||
- if role.resource == @conference
|
- registration.user.roles.where(resource: @conference).each do |role|
|
||||||
%span.label.label-info= role.name.titleize
|
%span.label.label-info
|
||||||
|
= role.name.titleize
|
||||||
%td
|
%td
|
||||||
= registration.email
|
= registration.email
|
||||||
%td
|
%td
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@
|
||||||
= '...'
|
= '...'
|
||||||
- else
|
- else
|
||||||
None
|
None
|
||||||
- if can? :show, user
|
%td
|
||||||
%td
|
- if can? :show, user
|
||||||
= link_to 'View', admin_user_path(user), class: 'btn btn-success'
|
= link_to 'View', admin_user_path(user), class: 'btn btn-success'
|
||||||
- if can? :update, user
|
%td
|
||||||
%td
|
- if can? :update, user
|
||||||
= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary'
|
= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue