mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #697 from raluka/toggle_button
Issue#690: fixed Attendance Button
This commit is contained in:
commit
a73ca335a9
3 changed files with 21 additions and 45 deletions
|
|
@ -36,27 +36,12 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def present
|
||||
@registration.attended = true
|
||||
def toggle_attendance
|
||||
@registration.attended = !@registration.attended
|
||||
if @registration.save
|
||||
flash[:notice] = "#{@user.email} has attended"
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
head :ok
|
||||
else
|
||||
flash[:notice] = "Update Attended for #{@user.email} failed!" \
|
||||
"#{@registration.errors.full_messages.join('. ')}"
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
end
|
||||
end
|
||||
|
||||
def absent
|
||||
@registration.attended = false
|
||||
if @registration.save
|
||||
flash[:notice] = "#{@user.email} has not attended"
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
else
|
||||
flash[:notice] = "Update Attended for #{@user.email} failed!" \
|
||||
"#{@registration.errors.full_messages.join('. ')}"
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
head :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -69,13 +54,13 @@ module Admin
|
|||
def registration_params
|
||||
params.require(:registration).
|
||||
permit(
|
||||
:conference_id, :arrival, :departure,
|
||||
:volunteer,
|
||||
vchoice_ids: [], qanswer_ids: [],
|
||||
qanswers_attributes: [],
|
||||
user_attributes: [
|
||||
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
||||
:nickname, :affiliation ])
|
||||
:conference_id, :arrival, :departure,
|
||||
:volunteer,
|
||||
vchoice_ids: [], qanswer_ids: [],
|
||||
qanswers_attributes: [],
|
||||
user_attributes: [
|
||||
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
||||
:nickname, :affiliation])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,24 +44,15 @@
|
|||
%td
|
||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||
%td
|
||||
= 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: "small",
|
||||
on_color: 'success',
|
||||
off_color: 'warning',
|
||||
on_text: 'Present',
|
||||
off_text: 'Absent' }
|
||||
.btn-group
|
||||
.btn-group
|
||||
- if registration.attended
|
||||
- btnclass = 'btn-success'
|
||||
- else
|
||||
- btnclass = 'btn-warning'
|
||||
%button{type: "button", class: "btn #{btnclass} dropdown-toggle", "data-toggle" => "dropdown", "aria-expanded" => "false"}
|
||||
- if registration.attended
|
||||
Present
|
||||
- else
|
||||
Absent
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
%li
|
||||
= link_to "Present", present_admin_conference_registration_path(@conference.short_title, id: registration.id),
|
||||
method: :patch
|
||||
= link_to "Absent" , absent_admin_conference_registration_path(@conference.short_title, id: registration.id),
|
||||
method: :patch
|
||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ Osem::Application.routes.draw do
|
|||
|
||||
resources :registrations, except: [:create, :new] do
|
||||
member do
|
||||
patch :present
|
||||
patch :absent
|
||||
patch :toggle_attendance
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue