Rebuild rubocop TODOs after auto-correcting

This commit is contained in:
James Mason 2018-04-04 10:18:51 -07:00
parent 31c50255e9
commit 84dbb52d11
No known key found for this signature in database
GPG key ID: 1B3951886C449023
580 changed files with 3689 additions and 3133 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.'

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ContactsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class PhysicalTicketsController < Admin::BaseController
before_action :authenticate_user!

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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}!"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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('. ')}."

View file

@ -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('. ')}."

View file

@ -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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class TicketScanningsController < Admin::BaseController
before_action :authenticate_user!

View file

@ -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

View file

@ -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

View file

@ -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('. ')}."

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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 '. '}"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
class BaseController < ActionController::Base
protect_from_forgery with: :exception

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class ConferencesController < Api::BaseController

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class EventsController < Api::BaseController
@ -10,9 +12,7 @@ module Api
def index
events = Event.includes(:track, :event_type, event_users: :user)
if @conference
events = events.where(program: @conference.program)
end
events = events.where(program: @conference.program) if @conference
respond_with events.confirmed, callback: params[:callback]
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class RoomsController < Api::BaseController

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class SpeakersController < Api::BaseController
@ -9,13 +11,13 @@ module Api
def index
if @conference
users = User.joins(event_users: { event: { program: :conference} })
users = User.joins(event_users: { event: { program: :conference } })
users = users.where(conferences: { short_title: @conference.short_title })
else
users = User.joins(:event_users)
end
users = users.where(event_users: {event_role: :speaker}).uniq
users = users.where(event_users: { event_role: :speaker }).uniq
render json: users, each_serializer: SpeakerSerializer, callback: params['callback']
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V1
class TracksController < Api::BaseController

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
before_action :set_paper_trail_whodunnit
include ApplicationHelper
@ -11,24 +13,24 @@ class ApplicationController < ActionController::Base
def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited.
return unless request.get?
if (request.path != '/accounts/sign_in' &&
request.path != '/accounts/sign_up' &&
request.path != '/accounts/password/new' &&
request.path != '/accounts/password/edit' &&
request.path != '/accounts/confirmation' &&
request.path != '/accounts/sign_out' &&
request.path != '/users/ichain_registration/ichain_sign_up' &&
!request.path.starts_with?(Devise.ichain_base_url) &&
!request.xhr?) # don't store ajax calls
if request.path != '/accounts/sign_in' &&
request.path != '/accounts/sign_up' &&
request.path != '/accounts/password/new' &&
request.path != '/accounts/password/edit' &&
request.path != '/accounts/confirmation' &&
request.path != '/accounts/sign_out' &&
request.path != '/users/ichain_registration/ichain_sign_up' &&
!request.path.starts_with?(Devise.ichain_base_url) &&
!request.xhr? # don't store ajax calls
session[:return_to] = request.fullpath
end
end
def after_sign_in_path_for(_resource)
if (can? :view, Conference) &&
(!session[:return_to] ||
session[:return_to] &&
session[:return_to] == root_path)
(!session[:return_to] ||
session[:return_to] &&
session[:return_to] == root_path)
admin_conferences_path
else
session[:return_to] || root_path
@ -61,10 +63,10 @@ class ApplicationController < ActionController::Base
Rails.logger.debug('User is disabled!')
sign_out(current_user)
mail = User.admin.first ? User.admin.first.email : 'the admin!'
redirect_to User.ichain_logout_url, error: "This User is disabled. Please contact #{mail}!"
redirect_to User.ichain_logout_url, error: "This User is disabled. Please contact #{mail}!"
end
def not_found
raise ActionController::RoutingError.new('Not Found')
raise ActionController::RoutingError, 'Not Found'
end
end

View file

@ -1,8 +1,10 @@
# frozen_string_literal: true
class BoothsController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference
skip_authorize_resource only: [:withdraw, :confirm, :restart]
skip_authorize_resource only: %i[withdraw confirm restart]
def index
@booths = current_user.booths.where(conference_id: @conference.id).uniq
@ -34,7 +36,7 @@ class BoothsController < ApplicationController
def update
@url = conference_booth_path(@conference.short_title, @booth.id)
@booth.update_attributes(booth_params)
@booth.update(booth_params)
if @booth.save
redirect_to conference_booths_path,

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommercialsController < ApplicationController
load_resource :conference, find_by: :short_title
before_action :set_event
@ -35,7 +37,7 @@ class CommercialsController < ApplicationController
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

View file

@ -1,8 +1,10 @@
# frozen_string_literal: true
class ConferenceRegistrationsController < ApplicationController
before_action :authenticate_user!, except: [:new, :create]
before_action :authenticate_user!, except: %i[new create]
load_resource :conference, find_by: :short_title
authorize_resource :conference_registrations, class: Registration, except: [:new, :create]
before_action :set_registration, only: [:edit, :update, :destroy, :show]
authorize_resource :conference_registrations, class: Registration, except: %i[new create]
before_action :set_registration, only: %i[edit update destroy show]
def new
@registration = Registration.new(conference_id: @conference.id)
@ -54,9 +56,7 @@ class ConferenceRegistrationsController < ApplicationController
ahoy.track 'Registered', title: 'New registration'
# Sign in the new user
unless current_user
sign_in(@registration.user)
end
sign_in(@registration.user) unless current_user
if @conference.tickets.any? && !current_user.supports?(@conference)
redirect_to conference_tickets_path(@conference.short_title),
@ -73,7 +73,7 @@ class ConferenceRegistrationsController < ApplicationController
end
def update
if @registration.update_attributes(registration_params)
if @registration.update(registration_params)
redirect_to conference_conference_registration_path(@conference.short_title),
notice: 'Registration was successfully updated.'
else
@ -110,14 +110,15 @@ class ConferenceRegistrationsController < ApplicationController
def registration_params
params.require(:registration)
.permit(
:conference_id, :arrival, :departure,
:volunteer,
vchoice_ids: [], qanswer_ids: [],
qanswers_attributes: [],
event_ids: [],
user_attributes: [
:username, :email, :name, :password, :password_confirmation]
)
.permit(
:conference_id, :arrival, :departure,
:volunteer,
vchoice_ids: [], qanswer_ids: [],
qanswers_attributes: [],
event_ids: [],
user_attributes: %i[
username email name password password_confirmation
]
)
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ConferencesController < ApplicationController
protect_from_forgery with: :null_session
before_action :respond_to_options
@ -21,9 +23,7 @@ class ConferencesController < ApplicationController
splashpage = @conference.splashpage
unless splashpage.present?
redirect_to admin_conference_splashpage_path(@conference.short_title) && return
end
redirect_to admin_conference_splashpage_path(@conference.short_title) && return if splashpage.blank?
if splashpage.include_cfp
cfps = @conference.program.cfps
@ -42,16 +42,10 @@ class ConferencesController < ApplicationController
:room
).order('tracks.name')
end
if splashpage.include_booths
@booths = @conference.confirmed_booths.order('title')
end
end
if splashpage.include_registrations || splashpage.include_tickets
@tickets = @conference.tickets.order('price_cents')
end
if splashpage.include_lodgings
@lodgings = @conference.lodgings.order('name')
@booths = @conference.confirmed_booths.order('title') if splashpage.include_booths
end
@tickets = @conference.tickets.order('price_cents') if splashpage.include_registrations || splashpage.include_tickets
@lodgings = @conference.lodgings.order('name') if splashpage.include_lodgings
if splashpage.include_sponsors
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
:sponsors
@ -71,8 +65,10 @@ class ConferencesController < ApplicationController
end
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
if request.options?
respond_to do |format|
format.html { head :ok }
end
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ConfirmationsController < Devise::ConfirmationsController
protected

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class OpenidsController < ApplicationController
load_and_authorize_resource :user
load_and_authorize_resource through: :user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class OrganizationsController < ApplicationController
load_and_authorize_resource :organization

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PaymentsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
@ -10,9 +12,7 @@ class PaymentsController < ApplicationController
def new
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
if @total_amount_to_pay.zero?
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)
end
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) if @total_amount_to_pay.zero?
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PhysicalTicketsController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title

View file

@ -1,10 +1,12 @@
# frozen_string_literal: true
class ProposalsController < ApplicationController
before_action :authenticate_user!, except: [:show, :new, :create]
before_action :authenticate_user!, except: %i[show new create]
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true
load_and_authorize_resource :event, parent: false, through: :program
# We authorize manually in these actions
skip_authorize_resource :event, only: [:confirm, :restart, :withdraw]
skip_authorize_resource :event, only: %i[confirm restart withdraw]
def index
@event = @program.events.new
@ -168,8 +170,7 @@ class ProposalsController < ApplicationController
params.require(:event).permit(:event_type_id, :track_id, :difficulty_level_id,
:title, :subtitle, :abstract, :description,
:require_registration, :max_attendees, :language,
speaker_ids: []
)
speaker_ids: [])
end
def user_params

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
prepend_before_action :check_captcha, only: [:create]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SchedulesController < ApplicationController
load_and_authorize_resource
protect_from_forgery with: :null_session
@ -8,11 +10,9 @@ class SchedulesController < ApplicationController
def show
@rooms = @conference.venue.rooms if @conference.venue
schedules = @program.selected_event_schedules
unless schedules
redirect_to events_conference_schedule_path(@conference.short_title)
end
redirect_to events_conference_schedule_path(@conference.short_title) unless schedules
@events_xml = schedules.map(&:event).group_by{ |event| event.time.to_date } if schedules
@events_xml = schedules.map(&:event).group_by { |event| event.time.to_date } if schedules
@dates = @conference.start_date..@conference.end_date
@step_minutes = @program.schedule_interval.minutes
@conf_start = @conference.start_hour
@ -20,7 +20,7 @@ class SchedulesController < ApplicationController
# the schedule takes you to today if it is a date of the schedule
@current_day = @conference.current_conference_day
@day = @current_day.present? ? @current_day : @dates.first
@day = @current_day.presence || @dates.first
unless @current_day
# the schedule takes you to the current time if it is beetween the start and the end time.
@hour_column = @conference.hours_from_start_time(@conf_start, @conference.end_hour)
@ -37,7 +37,7 @@ class SchedulesController < ApplicationController
@dates = @conference.start_date..@conference.end_date
@events_schedules = @program.selected_event_schedules
@events_schedules = [] unless @events_schedules
@events_schedules ||= []
@unscheduled_events = @program.events.confirmed - @events_schedules.map(&:event)
@ -48,8 +48,10 @@ class SchedulesController < ApplicationController
private
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
if request.options?
respond_to do |format|
format.html { head :ok }
end
end
end
end

View file

@ -1,7 +1,9 @@
# frozen_string_literal: true
class SubscriptionsController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title
load_and_authorize_resource only: [:create, :destroy], through: :conference
load_and_authorize_resource only: %i[create destroy], through: :conference
def create
@subscription = current_user.subscriptions.build(conference_id: @conference.id)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class TicketPurchasesController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class TicketsController < ApplicationController
before_action :authenticate_user!
load_resource :conference, find_by: :short_title
@ -8,8 +10,6 @@ class TicketsController < ApplicationController
def index; end
def check_load_resource
if @tickets.empty?
redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!"
end
redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!" if @tickets.empty?
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class TracksController < ApplicationController
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true
@ -29,7 +31,7 @@ class TracksController < ApplicationController
end
def update
if @track.update_attributes(track_params)
if @track.update(track_params)
redirect_to conference_program_tracks_path(conference_id: @conference.short_title),
notice: 'Track request successfully updated.'
else

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_authenticity_token
skip_before_action :verify_authenticity_token
skip_authorization_check
User.omniauth_providers.each do |provider|
@ -11,7 +13,7 @@ module Users
def handle(provider)
auth_hash = request.env['omniauth.auth']
unless auth_hash.info.email.present?
if auth_hash.info.email.blank?
flash[:error] = "Email field is missing in your #{provider} account"
redirect_to new_user_registration_path
return
@ -27,15 +29,13 @@ module Users
begin
user.save!
if openid.user != user
openid.user = user
end
openid.user = user if openid.user != user
openid.save!
sign_in user
redirect_to request.env['omniauth.origin'] || root_path,
notice: "#{user.email} signed in successfully with #{provider}"
rescue => e
rescue StandardError => e
flash[:error] = e.message
redirect_back_or_to new_user_registration_path
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UsersController < ApplicationController
load_and_authorize_resource
@ -7,8 +9,7 @@ class UsersController < ApplicationController
end
# GET /users/1/edit
def edit
end
def edit; end
# PATCH/PUT /users/1
def update
@ -22,8 +23,8 @@ class UsersController < ApplicationController
private
# Only allow a trusted parameter "white list" through.
def user_params
params.require(:user).permit(:name, :biography, :nickname, :affiliation)
end
# Only allow a trusted parameter "white list" through.
def user_params
params.require(:user).permit(:name, :biography, :nickname, :affiliation)
end
end