Rebuild rubocop TODOs after auto-correcting
This commit is contained in:
parent
31c50255e9
commit
84dbb52d11
580 changed files with 3689 additions and 3133 deletions
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class BaseController < ApplicationController
|
||||
before_action :verify_user_admin
|
||||
|
|
@ -9,7 +11,7 @@ module Admin
|
|||
end
|
||||
|
||||
def verify_user_admin
|
||||
if (current_user.nil?)
|
||||
if current_user.nil?
|
||||
redirect_to sign_in_path
|
||||
return false
|
||||
end
|
||||
|
|
@ -17,7 +19,7 @@ module Admin
|
|||
(current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :organization_admin, :any) ||
|
||||
(current_user.has_cached_role? :volunteers_coordinator, :any) ||
|
||||
(current_user.has_cached_role? :track_organizer, :any) || current_user.is_admin
|
||||
raise CanCan::AccessDenied.new('You are not authorized to access this page.')
|
||||
raise CanCan::AccessDenied, 'You are not authorized to access this page.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class BoothsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -51,7 +53,7 @@ module Admin
|
|||
def update
|
||||
@url = admin_conference_booth_path(@conference.short_title, @booth.id)
|
||||
|
||||
@booth.update_attributes(booth_params)
|
||||
@booth.update(booth_params)
|
||||
|
||||
if @booth.save
|
||||
redirect_to admin_conference_booths_path,
|
||||
|
|
@ -67,9 +69,7 @@ module Admin
|
|||
@booth.accept!
|
||||
|
||||
if @booth.save
|
||||
if @conference.email_settings.send_on_booths_acceptance
|
||||
Mailbot.conference_booths_acceptance_mail(@booth).deliver
|
||||
end
|
||||
Mailbot.conference_booths_acceptance_mail(@booth).deliver if @conference.email_settings.send_on_booths_acceptance
|
||||
redirect_to admin_conference_booths_path(conference_id: @conference.short_title),
|
||||
notice: 'Booth successfully accepted!'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CampaignsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -25,7 +27,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @campaign.update_attributes(campaign_params)
|
||||
if @campaign.update(campaign_params)
|
||||
redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title),
|
||||
notice: "Campaign '#{@campaign.name}' successfully updated."
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CfpsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -33,7 +35,7 @@ module Admin
|
|||
|
||||
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
|
||||
|
||||
if @cfp.update_attributes(cfp_params)
|
||||
if @cfp.update(cfp_params)
|
||||
ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates
|
||||
redirect_to admin_conference_program_cfps_path(@conference.short_title),
|
||||
notice: 'Call for papers successfully updated.'
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CommentsController < Admin::BaseController
|
||||
load_and_authorize_resource
|
||||
|
|
@ -20,9 +22,9 @@ module Admin
|
|||
Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC')
|
||||
end
|
||||
|
||||
# Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}}
|
||||
# Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}}
|
||||
def grouped_comments(remarks)
|
||||
remarks.group_by{ |comment| comment.commentable.program.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
|
||||
remarks.group_by { |comment| comment.commentable.program.conference }.map { |conference, comments| [conference, comments.group_by(&:commentable)] }.to_h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CommercialsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource through: :conference, except: [:new, :create]
|
||||
load_and_authorize_resource through: :conference, except: %i[new create]
|
||||
|
||||
def index
|
||||
@commercials = @conference.commercials
|
||||
|
|
@ -43,7 +45,7 @@ module Admin
|
|||
def render_commercial
|
||||
result = Commercial.render_from_url(params[:url])
|
||||
if result[:error]
|
||||
render text: result[:error], status: 400
|
||||
render text: result[:error], status: :bad_request
|
||||
else
|
||||
render text: result[:html]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ConferencesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -22,11 +24,11 @@ module Admin
|
|||
|
||||
@total_withdrawn = Event.where(state: :withdrawn).count
|
||||
@new_withdrawn = Event
|
||||
.where('state = ? and created_at > ?', 'withdrawn', current_user.last_sign_in_at).count
|
||||
.where('state = ? and created_at > ?', 'withdrawn', current_user.last_sign_in_at).count
|
||||
|
||||
@active_conferences = Conference.get_active_conferences_for_dashboard # pending or the last two
|
||||
@deactive_conferences = Conference
|
||||
.get_conferences_without_active_for_dashboard(@active_conferences) # conferences without active
|
||||
.get_conferences_without_active_for_dashboard(@active_conferences) # conferences without active
|
||||
@conferences = @active_conferences + @deactive_conferences
|
||||
|
||||
@recent_users = User.limit(5).order(created_at: :desc)
|
||||
|
|
@ -99,7 +101,7 @@ module Admin
|
|||
@conference.assign_attributes(conference_params)
|
||||
send_mail_on_conf_update = @conference.notify_on_dates_changed?
|
||||
|
||||
if @conference.update_attributes(conference_params)
|
||||
if @conference.update(conference_params)
|
||||
ConferenceDateUpdateMailJob.perform_later(@conference) if send_mail_on_conf_update
|
||||
redirect_to edit_admin_conference_path(id: @conference.short_title),
|
||||
notice: 'Conference was successfully updated.'
|
||||
|
|
@ -121,7 +123,7 @@ module Admin
|
|||
|
||||
@total_submissions = @all_events.count
|
||||
@new_submissions = @all_events
|
||||
.where('created_at > ?', current_user.last_sign_in_at).count
|
||||
.where('created_at > ?', current_user.last_sign_in_at).count
|
||||
|
||||
@program_length = @conference.current_program_hours
|
||||
@new_program_length = @conference.new_program_hours(current_user.last_sign_in_at)
|
||||
|
|
@ -136,7 +138,7 @@ module Admin
|
|||
@conference_progress = @conference.get_status
|
||||
|
||||
# Line charts
|
||||
@registrations = {@conference.short_title => @conference.get_registrations_per_week}
|
||||
@registrations = { @conference.short_title => @conference.get_registrations_per_week }
|
||||
@registration_weeks = [0]
|
||||
@registration_weeks.push(@registrations[@conference.short_title].length)
|
||||
|
||||
|
|
@ -173,9 +175,9 @@ module Admin
|
|||
|
||||
@difficulty_levels_distribution = @conference.difficulty_levels_distribution
|
||||
@difficulty_levels_distribution_confirmed = @conference
|
||||
.difficulty_levels_distribution(:confirmed)
|
||||
.difficulty_levels_distribution(:confirmed)
|
||||
@difficulty_levels_distribution_withdrawn = @conference
|
||||
.difficulty_levels_distribution(:withdrawn)
|
||||
.difficulty_levels_distribution(:withdrawn)
|
||||
|
||||
@tracks_distribution = @conference.tracks_distribution
|
||||
@tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ContactsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class DifficultyLevelsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -5,7 +7,7 @@ module Admin
|
|||
load_and_authorize_resource through: :program
|
||||
|
||||
def index
|
||||
# authorize! :index, DifficultyLevel.new(program_id: @program.id)
|
||||
# authorize! :index, DifficultyLevel.new(program_id: @program.id)
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
|
@ -26,7 +28,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @difficulty_level.update_attributes(difficulty_level_params)
|
||||
if @difficulty_level.update(difficulty_level_params)
|
||||
redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
|
||||
notice: 'Difficulty level successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EmailsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -6,11 +8,13 @@ module Admin
|
|||
def update
|
||||
if @conference.email_settings.update(email_params)
|
||||
redirect_to admin_conference_emails_path(
|
||||
@conference.short_title),
|
||||
@conference.short_title
|
||||
),
|
||||
notice: 'Email settings have been successfully updated.'
|
||||
else
|
||||
redirect_to admin_conference_emails_path(
|
||||
@conference.short_title),
|
||||
@conference.short_title
|
||||
),
|
||||
error: "Updating email settings failed. #{@conference.email_settings.errors.to_a.join('. ')}."
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EventSchedulesController < Admin::BaseController
|
||||
load_and_authorize_resource :event_schedule
|
||||
|
|
@ -6,7 +8,7 @@ module Admin
|
|||
if @event_schedule.save
|
||||
render json: { event_schedule_id: @event_schedule.id }
|
||||
else
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -14,7 +16,7 @@ module Admin
|
|||
if @event_schedule.update(event_schedule_params)
|
||||
render json: { event_schedule_id: @event_schedule.id }
|
||||
else
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ module Admin
|
|||
if @event_schedule.destroy
|
||||
render json: {}
|
||||
else
|
||||
render json: { errors: "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
render json: { errors: "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EventTypesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -24,7 +26,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @event_type.update_attributes(event_type_params)
|
||||
if @event_type.update(event_type_params)
|
||||
redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
|
||||
notice: 'Event type successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class EventsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -7,7 +9,7 @@ module Admin
|
|||
# For some reason this doesn't work, so a workaround is used
|
||||
# load_and_authorize_resource :track, through: :program, only: [:index, :show, :edit]
|
||||
|
||||
before_action :assign_tracks, only: [:index, :show, :edit]
|
||||
before_action :assign_tracks, only: %i[index show edit]
|
||||
|
||||
def index
|
||||
@difficulty_levels = @program.difficulty_levels
|
||||
|
|
@ -17,7 +19,7 @@ module Admin
|
|||
@scheduled_event_distribution = @conference.scheduled_event_distribution
|
||||
@file_name = "events_for_#{@conference.short_title}"
|
||||
@event_export_option = params[:event_export_option]
|
||||
@export_formats = [:pdf, :csv, :xlsx]
|
||||
@export_formats = %i[pdf csv xlsx]
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
@ -69,7 +71,7 @@ module Admin
|
|||
|
||||
def update
|
||||
@languages = @program.languages_list
|
||||
if @event.update_attributes(event_params)
|
||||
if @event.update(event_params)
|
||||
|
||||
if request.xhr?
|
||||
render js: 'index'
|
||||
|
|
@ -139,8 +141,8 @@ module Admin
|
|||
def vote
|
||||
@votes = @event.votes.includes(:user)
|
||||
|
||||
if (votes = current_user.votes.find_by_event_id(params[:id]))
|
||||
votes.update_attributes(rating: params[:rating])
|
||||
if (votes = current_user.votes.find_by(event_id: params[:id]))
|
||||
votes.update(rating: params[:rating])
|
||||
else
|
||||
@myvote = @event.votes.build
|
||||
@myvote.user = current_user
|
||||
|
|
@ -172,13 +174,14 @@ module Admin
|
|||
|
||||
def event_params
|
||||
params.require(:event).permit(
|
||||
# Set also in proposals controller
|
||||
:title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id,
|
||||
# Set only in admin/events controller
|
||||
:track_id, :state, :language, :is_highlight, :max_attendees,
|
||||
# Not used anymore?
|
||||
:proposal_additional_speakers, :user, :users_attributes,
|
||||
speaker_ids: [])
|
||||
# Set also in proposals controller
|
||||
:title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id,
|
||||
# Set only in admin/events controller
|
||||
:track_id, :state, :language, :is_highlight, :max_attendees,
|
||||
# Not used anymore?
|
||||
:proposal_additional_speakers, :user, :users_attributes,
|
||||
speaker_ids: []
|
||||
)
|
||||
end
|
||||
|
||||
def comment_params
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class LodgingsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :lodging, through: :conference
|
||||
|
||||
def index
|
||||
end
|
||||
def index; end
|
||||
|
||||
def new
|
||||
@lodging = @conference.lodgings.new
|
||||
|
|
@ -24,7 +25,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @lodging.update_attributes(lodging_params)
|
||||
if @lodging.update(lodging_params)
|
||||
redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title),
|
||||
notice: 'Lodging successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class OrganizationsController < Admin::BaseController
|
||||
load_and_authorize_resource :organization
|
||||
before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins]
|
||||
before_action :verify_user, only: %i[assign_org_admins unassign_org_admins]
|
||||
|
||||
def index
|
||||
@organizations = Organization.all
|
||||
|
|
@ -25,7 +27,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @organization.update_attributes(organization_params)
|
||||
if @organization.update(organization_params)
|
||||
redirect_to admin_organizations_path,
|
||||
notice: 'Organization successfully updated'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class PhysicalTicketsController < Admin::BaseController
|
||||
before_action :authenticate_user!
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ProgramsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -14,7 +16,7 @@ module Admin
|
|||
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
||||
event_schedules_count_was = @program.event_schedules.count
|
||||
|
||||
if @program.update_attributes(program_params)
|
||||
if @program.update(program_params)
|
||||
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
|
@ -30,7 +32,7 @@ module Admin
|
|||
flash.now[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
format.js { render json: { errors: "The selected schedule couldn't be updated #{@program.errors.to_a.join('. ')}" }, status: 422 }
|
||||
format.js { render json: { errors: "The selected schedule couldn't be updated #{@program.errors.to_a.join('. ')}" }, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class QuestionsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource through: :conference, except: [:new, :create]
|
||||
load_and_authorize_resource through: :conference, except: %i[new create]
|
||||
|
||||
def index
|
||||
authorize! :index, Question.new(conference_id: @conference.id)
|
||||
|
|
@ -24,9 +26,7 @@ module Admin
|
|||
@question.conference_id = @conference.id
|
||||
authorize! :create, @question
|
||||
|
||||
if @question.question_type_id == QuestionType.find_by(title: 'Yes/No').id
|
||||
@question.answers = [Answer.find_by(title: 'Yes'), Answer.find_by(title: 'No')]
|
||||
end
|
||||
@question.answers = [Answer.find_by(title: 'Yes'), Answer.find_by(title: 'No')] if @question.question_type_id == QuestionType.find_by(title: 'Yes/No').id
|
||||
|
||||
respond_to do |format|
|
||||
if @conference.save
|
||||
|
|
@ -39,14 +39,12 @@ module Admin
|
|||
|
||||
# GET questions/1/edit
|
||||
def edit
|
||||
if @question.global
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.'
|
||||
end
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.' if @question.global
|
||||
end
|
||||
|
||||
# PUT questions/1
|
||||
def update
|
||||
if @question.update_attributes(question_params)
|
||||
if @question.update(question_params)
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated."
|
||||
else
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed. #{@question.errors.full_messages.join('. ')}"
|
||||
|
|
@ -56,7 +54,7 @@ module Admin
|
|||
# Update questions used for the conference
|
||||
def update_conference
|
||||
authorize! :update, Question.new(conference_id: @conference.id)
|
||||
if @conference.update_attributes(conference_params)
|
||||
if @conference.update(conference_params)
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated."
|
||||
else
|
||||
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed."
|
||||
|
|
@ -73,12 +71,9 @@ module Admin
|
|||
# Delete question and its answers
|
||||
begin
|
||||
Question.transaction do
|
||||
|
||||
@question.destroy
|
||||
@question.answers.each do |a|
|
||||
a.destroy
|
||||
end
|
||||
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
|
||||
@question.answers.each(&:destroy)
|
||||
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map(&:title).join ','}"
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = 'Could not delete question.'
|
||||
|
|
@ -95,7 +90,7 @@ module Admin
|
|||
private
|
||||
|
||||
def question_params
|
||||
params.require(:question).permit(:title, :global, :answer_ids, :question_type_id, :conference_id, answers_attributes: [:id, :title])
|
||||
params.require(:question).permit(:title, :global, :answer_ids, :question_type_id, :conference_id, answers_attributes: %i[id title])
|
||||
end
|
||||
|
||||
def conference_params
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class RegistrationPeriodsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -21,11 +23,9 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
@registration_period.assign_attributes(registration_period_params)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class RegistrationsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -17,9 +19,9 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
@user.update_attributes(user_params)
|
||||
@user.update(user_params)
|
||||
|
||||
@registration.update_attributes(registration_params)
|
||||
@registration.update(registration_params)
|
||||
if @registration.save
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title),
|
||||
notice: "Successfully updated registration for #{@registration.user.email}!"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ReportsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -13,9 +15,9 @@ module Admin
|
|||
|
||||
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
|
||||
@missing_event_speakers = EventUser.joins(:event)
|
||||
.where('event_role = ? and program_id = ?', 'submitter', @program.id)
|
||||
.where.not(user_id: attended_registrants_ids)
|
||||
.includes(:user, :event)
|
||||
.where('event_role = ? and program_id = ?', 'submitter', @program.id)
|
||||
.where.not(user_id: attended_registrants_ids)
|
||||
.includes(:user, :event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ResourcesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :resource, only: [:show, :edit, :update, :destroy]
|
||||
load_and_authorize_resource :resource, only: %i[show edit update destroy]
|
||||
|
||||
def index; end
|
||||
|
||||
|
|
@ -23,7 +25,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @resource.update_attributes(resource_params)
|
||||
if @resource.update(resource_params)
|
||||
redirect_to admin_conference_resources_path(conference_id: @conference.short_title),
|
||||
notice: 'Resource successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class RolesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -34,7 +36,7 @@ module Admin
|
|||
def update
|
||||
role_name = @role.name
|
||||
|
||||
if @role.update_attributes(role_params)
|
||||
if @role.update(role_params)
|
||||
url = if @track
|
||||
admin_conference_program_track_role_path(@conference.short_title, @track, @role.name)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class RoomsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -24,7 +26,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @room.update_attributes(room_params)
|
||||
if @room.update(room_params)
|
||||
redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
|
||||
notice: 'Room successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class SchedulesController < Admin::BaseController
|
||||
# By authorizing 'conference' resource, we can ensure there will be no unauthorized access to
|
||||
# the schedule of a conference, which should not be accessed in the first place
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :program, through: :conference, singleton: true
|
||||
load_and_authorize_resource :schedule, through: :program, except: [:new, :create]
|
||||
load_and_authorize_resource :schedule, through: :program, except: %i[new create]
|
||||
load_resource :event_schedules, through: :schedule
|
||||
load_resource :selected_schedule, through: :program, singleton: true
|
||||
load_resource :venue, through: :conference, singleton: true
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class SplashpagesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -23,7 +25,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @splashpage.update_attributes(splashpage_params)
|
||||
if @splashpage.update(splashpage_params)
|
||||
redirect_to admin_conference_splashpage_path,
|
||||
notice: 'Splashpage successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class SponsorsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :sponsor, through: :conference
|
||||
before_action :sponsorship_level_required, only: [:index, :new]
|
||||
before_action :sponsorship_level_required, only: %i[index new]
|
||||
|
||||
def index
|
||||
authorize! :index, Sponsor.new(conference_id: @conference.id)
|
||||
|
|
@ -26,9 +28,10 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @sponsor.update_attributes(sponsor_params)
|
||||
if @sponsor.update(sponsor_params)
|
||||
redirect_to admin_conference_sponsors_path(
|
||||
conference_id: @conference.short_title),
|
||||
conference_id: @conference.short_title
|
||||
),
|
||||
notice: 'Sponsor successfully updated.'
|
||||
else
|
||||
flash.now[:error] = "Update sponsor failed: #{@sponsor.errors.full_messages.join('. ')}."
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class SponsorshipLevelsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -25,9 +27,10 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @sponsorship_level.update_attributes(sponsorship_level_params)
|
||||
if @sponsorship_level.update(sponsorship_level_params)
|
||||
redirect_to admin_conference_sponsorship_levels_path(
|
||||
conference_id: @conference.short_title),
|
||||
conference_id: @conference.short_title
|
||||
),
|
||||
notice: 'Sponsorship level successfully updated.'
|
||||
else
|
||||
flash.now[:error] = "Update Sponsorship level failed: #{@sponsorship_level.errors.full_messages.join('. ')}."
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class TargetsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -23,7 +25,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @target.update_attributes(target_params)
|
||||
if @target.update(target_params)
|
||||
redirect_to admin_conference_targets_path(conference_id: @conference.short_title),
|
||||
notice: 'Target successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class TicketScanningsController < Admin::BaseController
|
||||
before_action :authenticate_user!
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class TicketsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -27,7 +29,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @ticket.update_attributes(ticket_params)
|
||||
if @ticket.update(ticket_params)
|
||||
redirect_to admin_conference_tickets_path(conference_id: @conference.short_title),
|
||||
notice: 'Ticket successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class TracksController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -54,7 +56,7 @@ module Admin
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @track.update_attributes(track_params)
|
||||
if @track.update(track_params)
|
||||
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
||||
notice: 'Track successfully updated.'
|
||||
else
|
||||
|
|
@ -120,13 +122,13 @@ module Admin
|
|||
end
|
||||
|
||||
def update_selected_schedule
|
||||
if @track.update_attributes(params.require(:track).permit(:selected_schedule_id))
|
||||
if @track.update(params.require(:track).permit(:selected_schedule_id))
|
||||
respond_to do |format|
|
||||
format.js { render json: {} }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js { render json: { errors: "The selected schedule couldn't be updated #{@track.errors.to_a.join('. ')}" }, status: 422 }
|
||||
format.js { render json: { errors: "The selected schedule couldn't be updated #{@track.errors.to_a.join('. ')}" }, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class UsersController < Admin::BaseController
|
||||
load_and_authorize_resource
|
||||
|
|
@ -36,9 +38,9 @@ module Admin
|
|||
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
||||
# If you want to change the attributes that are shown in the 'show' action of users
|
||||
# add/remove the attributes in the following string array
|
||||
@show_attributes = %w(name email username nickname affiliation biography registered attended roles created_at
|
||||
@show_attributes = %w[name email username nickname affiliation biography registered attended roles created_at
|
||||
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
||||
current_sign_in_ip last_sign_in_ip)
|
||||
current_sign_in_ip last_sign_in_ip]
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -49,7 +51,7 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
if @user.update_attributes(user_params)
|
||||
if @user.update(user_params)
|
||||
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message
|
||||
else
|
||||
redirect_to admin_users_path, error: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class VenueCommercialsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -38,7 +40,7 @@ module Admin
|
|||
def render_commercial
|
||||
result = Commercial.render_from_url(params[:url])
|
||||
if result[:error]
|
||||
render text: result[:error], status: 400
|
||||
render text: result[:error], status: :bad_request
|
||||
else
|
||||
render text: result[:html]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class VenuesController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
|
@ -23,7 +25,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @venue.update_attributes(venue_params)
|
||||
if @venue.update(venue_params)
|
||||
redirect_to admin_conference_venue_path(conference_id: @conference.short_title),
|
||||
notice: 'Venue was successfully updated.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class VersionsController < Admin::BaseController
|
||||
load_resource :conference, find_by: :short_title, only: :index
|
||||
load_and_authorize_resource class: PaperTrail::Version
|
||||
|
||||
def index
|
||||
@conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title)
|
||||
@conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role(%i[organizer cfp info_desk], current_user).pluck(:short_title)
|
||||
|
||||
if current_user.has_cached_role? :organization_admin, :any
|
||||
@conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten
|
||||
end
|
||||
@conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten if current_user.has_cached_role? :organization_admin, :any
|
||||
@conferences_with_role.uniq!
|
||||
|
||||
return if @conference.blank?
|
||||
|
|
@ -16,7 +16,7 @@ module Admin
|
|||
end
|
||||
|
||||
def revert_attribute
|
||||
if params[:attribute] && @version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute])
|
||||
if params[:attribute] && @version.changeset.reject { |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute])
|
||||
if @version.item[params[:attribute]] == @version.changeset[params[:attribute]][0]
|
||||
flash[:error] = 'The item is already in the state that you are trying to revert it back to'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class VolunteersController < Admin::BaseController
|
||||
include VolunteersHelper
|
||||
|
|
@ -24,7 +26,7 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if @conference.update_attributes(conference_params)
|
||||
if @conference.update(conference_params)
|
||||
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.'
|
||||
else
|
||||
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), error: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue