mirror of
https://github.com/openSUSE/osem.git
synced 2026-02-05 11:41:06 -05:00
Update config with rails app:update Update schema.rb rails db:migrate Add puma Make jobs and models inherit from ApplicationJob and ApplicationRecord Update acts_as_list to 0.9.7 in order to fix "undefined method `sanitize_sql_hash_for_conditions'" error Update web-console to 2.3.0 to fix a 500 internal server error Replace before_filter with before_action Add rails-controller-testing gem Add prepend: :true to protect_from_forgery in ApplicationController to avoid ActionController::InvalidAuthenticityToken exceptions Remove activeuuid Update formtastic to 3.1.5 to fix deprecation warnings and issues with the Input class Update ahoy_matey to 1.6.0 Update cancancan to 2.0.0 to fix issues with malformed sql queries Fix program spec Fix issue with the picture being nil in admin/Organizations#new and #edit and Organizations#show Fix ActiveRecord::Base.raise_in_transactional_callbacks= deprecation warning by removing an unnecessary line in application.rb Fix failing versions specs
70 lines
2.4 KiB
Ruby
70 lines
2.4 KiB
Ruby
module Admin
|
|
class RegistrationsController < Admin::BaseController
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
load_and_authorize_resource :registration, through: :conference
|
|
before_action :set_user, except: [:index]
|
|
|
|
def index
|
|
authorize! :show, Registration.new(conference_id: @conference.id)
|
|
@pdf_filename = "#{@conference.title}.pdf"
|
|
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
|
@attended = @conference.registrations.where('attended = ?', true).count
|
|
|
|
@registration_distribution = @conference.registration_distribution
|
|
@affiliation_distribution = @conference.affiliation_distribution
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
@user.update_attributes(user_params)
|
|
|
|
@registration.update_attributes(registration_params)
|
|
if @registration.save
|
|
redirect_to admin_conference_registrations_path(@conference.short_title),
|
|
notice: "Successfully updated registration for #{@registration.user.email}!"
|
|
else
|
|
flash.now[:error] = "An error prohibited the Registration for #{@registration.user.email}: "\
|
|
"#{@registration.errors.full_messages.join('. ')}."
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if can? :destroy, @registration
|
|
@registration.destroy
|
|
redirect_to admin_conference_registrations_path(@conference.short_title),
|
|
notice: "Deleted registration for #{@user.name}!"
|
|
else
|
|
redirect_to admin_conference_registrations_path(@conference.short_title),
|
|
error: 'You must be an admin to delete a registration.'
|
|
end
|
|
end
|
|
|
|
def toggle_attendance
|
|
@registration.attended = !@registration.attended
|
|
if @registration.save
|
|
head :ok
|
|
else
|
|
head :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_user
|
|
@user = User.find_by(id: @registration.user_id)
|
|
end
|
|
|
|
def user_params
|
|
params.require(:user).permit(:name, :nickname, :affiliation)
|
|
end
|
|
|
|
def registration_params
|
|
params.require(:registration).permit(:user_id, :conference_id, :arrival, :departure, :attended,
|
|
:volunteer, :other_special_needs,
|
|
vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], event_ids: [])
|
|
end
|
|
end
|
|
end
|