created action for attendance-button
This commit is contained in:
parent
bd0cfb99bc
commit
522f0b31d9
3 changed files with 23 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
def present
|
def present
|
||||||
@registration.attended = true
|
@registration.attended = true
|
||||||
if @registration.save
|
if @registration.save
|
||||||
|
|
@ -59,6 +60,22 @@ module Admin
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
=end
|
||||||
|
|
||||||
|
def toggle_attendance
|
||||||
|
if params[:attended] == "true"
|
||||||
|
flash[:notice] = "#{@user.email} is attended."
|
||||||
|
@registration.attended = true
|
||||||
|
elsif params[:attended] == "false"
|
||||||
|
flash[:notice] = "#{@user.email} is not attended."
|
||||||
|
@registration.attended = false
|
||||||
|
end
|
||||||
|
unless @registration.save
|
||||||
|
flash[:notice] = "Update Attended for #{@user.email} failed!" \
|
||||||
|
"#{@registration.errors.full_messages.join('. ')}"
|
||||||
|
end
|
||||||
|
render json: {attended: @registration.attended}
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
@ -77,5 +94,6 @@ module Admin
|
||||||
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
||||||
:nickname, :affiliation ])
|
:nickname, :affiliation ])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,15 @@
|
||||||
-if @conference.questions.any?
|
-if @conference.questions.any?
|
||||||
%td
|
%td
|
||||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||||
%td
|
%td{'data-order' => "#{registration.attended}"}
|
||||||
= check_box_tag @conference.short_title, registration.id, true, class: 'switch-checkbox', method: :patch,
|
= check_box_tag "#{@conference.short_title}_#{registration.id}", registration.id, registration.attended, class: 'switch-checkbox',
|
||||||
|
method: :patch, url: toggle_attendance_admin_conference_registration_path(@conference.short_title, id: registration.id)+"?attended=",
|
||||||
data: { size: "large",
|
data: { size: "large",
|
||||||
on_color: 'success',
|
on_color: 'success',
|
||||||
off_color: 'warning',
|
off_color: 'warning',
|
||||||
on_text: 'Present',
|
on_text: 'Present',
|
||||||
off_text: 'Absent' }
|
off_text: 'Absent' }
|
||||||
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
.btn-group
|
.btn-group
|
||||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
resources :registrations, except: [:create, :new] do
|
resources :registrations, except: [:create, :new] do
|
||||||
member do
|
member do
|
||||||
patch :present
|
patch :toggle_attendance
|
||||||
patch :absent
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue