Merge pull request #349 from openSUSE/review_140721_basic_rubocop_rules
[Review] Request from 'KalabiYau' @ 'openSUSE/osem/review_140721_basic_rubocop_rules'
This commit is contained in:
commit
d9d72eae07
103 changed files with 686 additions and 260 deletions
|
|
@ -8,9 +8,9 @@ class Admin::DietchoicesController < ApplicationController
|
|||
def update
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.')
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}")
|
||||
redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), notice: 'Dietary choices were successfully updated.')
|
||||
rescue => e
|
||||
redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), alert: "Dietary choices update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,19 +12,18 @@ class Admin::DifficultyLevelsController < ApplicationController
|
|||
@conference.use_difficulty_levels = false
|
||||
@conference.save!
|
||||
flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = "Something went wrong. Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:notice] = "Difficulty Levels were successfully updated."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:error] = "Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module Admin
|
|||
|
||||
@mystates = []
|
||||
@mytypes = []
|
||||
@eventstats = Hash.new
|
||||
@eventstats = {}
|
||||
@totallength = 0
|
||||
|
||||
@machine_states.each do |mystate|
|
||||
|
|
@ -50,7 +50,7 @@ module Admin
|
|||
@totallength += myevent.event_type.length
|
||||
end
|
||||
|
||||
if @eventstats[mytype.title] == nil
|
||||
if @eventstats[mytype.title].nil?
|
||||
@eventstats[mytype.title] = { 'count' => events_mytype.count,
|
||||
'length' => events_mytype.count * mytype.length }
|
||||
end
|
||||
|
|
@ -150,7 +150,7 @@ module Admin
|
|||
@event = Event.find(params[:id])
|
||||
@ratings = @event.votes.includes(:user)
|
||||
|
||||
if votes = current_user.votes.find_by_event_id(params[:id])
|
||||
if (votes = current_user.votes.find_by_event_id(params[:id]))
|
||||
votes.update_attributes(rating: params[:rating])
|
||||
else
|
||||
@myvote = @event.votes.build
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Admin::EventtypesController < ApplicationController
|
|||
redirect_to(admin_conference_eventtypes_path(
|
||||
conference_id: @conference.short_title),
|
||||
notice: 'Event types were successfully updated.')
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
redirect_to(admin_conference_eventtypes_path(
|
||||
conference_id: @conference.short_title),
|
||||
alert: "Event types update failed: #{e.message}")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
|
||||
def index
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id)
|
||||
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
@new_question = @conference.questions.new
|
||||
end
|
||||
|
|
@ -34,7 +34,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
@question = Question.find(params[:id])
|
||||
|
||||
if @question.global == true && !has_role?(current_user, "Admin")
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :alert => "Sorry, you cannot edit global questions. Create a new one.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -45,9 +45,9 @@ class Admin::QuestionsController < ApplicationController
|
|||
@question = Question.find(params[:id])
|
||||
|
||||
if @question.update_attributes(params[:question])
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
|
||||
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.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,9 +56,9 @@ class Admin::QuestionsController < ApplicationController
|
|||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.")
|
||||
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.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
a.delete
|
||||
end
|
||||
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = "Could not delete question."
|
||||
end
|
||||
|
|
@ -90,7 +90,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
flash[:error] = "You must be an admin to delete a question."
|
||||
end
|
||||
|
||||
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module Admin
|
|||
@registration.update_attributes!(params[:registration])
|
||||
flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}"
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title))
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title),
|
||||
alert: 'Failed to update registration:' + e.message)
|
||||
|
|
@ -104,7 +104,7 @@ module Admin
|
|||
begin registration.destroy
|
||||
redirect_to admin_conference_registrations_path
|
||||
flash[:notice] = "Deleted registration for #{user.name} #{user.email}"
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title),
|
||||
alert: 'Failed to delete registration:' + e.message)
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ class Admin::SocialEventsController < ApplicationController
|
|||
|
||||
def update
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.')
|
||||
redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events were successfully updated.')
|
||||
else
|
||||
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.')
|
||||
redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events update failed.')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module Admin
|
|||
if @events.count > 0
|
||||
start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
|
||||
end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
|
||||
unless start_date == nil || end_date == nil
|
||||
unless start_date.nil? || end_date.nil?
|
||||
@events_time = var_time(start_date, end_date, @events, 'created_at')
|
||||
end
|
||||
end
|
||||
|
|
@ -87,7 +87,7 @@ module Admin
|
|||
typelength += myevent.event_type.length
|
||||
@totallength += myevent.event_type.length
|
||||
end
|
||||
if @eventstats[mytype.title] == nil
|
||||
if @eventstats[mytype.title].nil?
|
||||
@eventstats[mytype.title] = { 'count' => events_mytype.count,
|
||||
'length' => events_mytype.count * mytype.length }
|
||||
end
|
||||
|
|
@ -187,7 +187,7 @@ module Admin
|
|||
total = @conference.events.where(state: mystate).count
|
||||
status = "#{myvar.name}"
|
||||
|
||||
percent = 0
|
||||
percent = 0 # rubocop:disable Lint/UselessAssignment
|
||||
if value != 0
|
||||
percent = (value.to_f / total * 100).round(2)
|
||||
result << { 'status' => status, 'value' => value, 'percent' => percent }
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ class Admin::SupporterLevelsController < ApplicationController
|
|||
def update
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.')
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}")
|
||||
redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.')
|
||||
rescue => e
|
||||
redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), alert: "Supporter levels update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Admin::SupportersController < ApplicationController
|
|||
|
||||
def create
|
||||
params[:supporter_registration][:conference_id] = @conference.id
|
||||
supporter = SupporterRegistration.create!(params[:supporter_registration])
|
||||
redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added")
|
||||
SupporterRegistration.create!(params[:supporter_registration])
|
||||
redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: "Supporter added")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ class Admin::VenueController < ApplicationController
|
|||
@venue = @conference.venue
|
||||
render :venue_info
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Admin::VolunteersController < ApplicationController
|
|||
if @conference.use_vpositions
|
||||
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
||||
else
|
||||
@volunteers = @conference.registrations.where(:volunteer => true)
|
||||
@volunteers = @conference.registrations.where(volunteer: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -17,9 +17,9 @@ class Admin::VolunteersController < ApplicationController
|
|||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.")
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}")
|
||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
|
||||
rescue => e
|
||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ class Api::V1::ConferencesController < Api::BaseController
|
|||
else
|
||||
conferences = Conference.find_all_by_guid(params[:conference_id])
|
||||
end
|
||||
render :json => conferences, :serializer => ConferencesArraySerializer
|
||||
render json: conferences, serializer: ConferencesArraySerializer
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
Rails.logger.debug("Access denied!")
|
||||
redirect_to root_path, :alert => exception.message
|
||||
redirect_to root_path, alert: exception.message
|
||||
end
|
||||
helper_method :organizer_or_admin?
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ConferenceRegistrationController < ApplicationController
|
|||
else
|
||||
registration.update_attributes!(registration_params)
|
||||
end
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join('\n')
|
||||
redirect_to(register_conference_path(id: conference.short_title),
|
||||
alert: 'Registration failed:' + e.message)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class EventAttachmentsController < ApplicationController
|
||||
before_filter :verify_user
|
||||
skip_before_filter :verify_user, :only => [:show]
|
||||
skip_before_filter :verify_user, only: [:show]
|
||||
|
||||
def index
|
||||
@proposal = Event.find(params[:proposal_id])
|
||||
|
|
@ -52,8 +52,8 @@ class EventAttachmentsController < ApplicationController
|
|||
|
||||
if !organizer_or_admin?
|
||||
begin
|
||||
event = current_user.events.find(params[:proposal_id])
|
||||
rescue Exception => e
|
||||
current_user.events.find(params[:proposal_id])
|
||||
rescue
|
||||
# They certainly aren't allowed to attach a file to someone else's proposal
|
||||
raise ActionController::RoutingError.new('Invalid proposal')
|
||||
end
|
||||
|
|
@ -67,12 +67,14 @@ class EventAttachmentsController < ApplicationController
|
|||
respond_to do |format|
|
||||
if @upload.save
|
||||
format.html {
|
||||
render :json => [@upload.to_jq_upload].to_json,
|
||||
:content_type => 'text/html',
|
||||
:layout => false
|
||||
render json: [@upload.to_jq_upload].to_json,
|
||||
content_type: 'text/html',
|
||||
layout: false
|
||||
}
|
||||
format.json { render json: [@upload.to_jq_upload].to_json, status: :created,
|
||||
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) }
|
||||
format.json do
|
||||
render json: [@upload.to_jq_upload].to_json, status: :created,
|
||||
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload)
|
||||
end
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @upload.errors, status: :unprocessable_entity }
|
||||
|
|
@ -106,7 +108,7 @@ class EventAttachmentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
|
||||
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), :notice => "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
|
||||
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
|
||||
|
||||
format.json { head :no_content }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ProposalController < ApplicationController
|
|||
else
|
||||
@event = Event.find(params[:id])
|
||||
end
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug("Proposal failure in verify_access: #{e.message}")
|
||||
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
||||
alert: 'Invalid or uneditable proposal.')
|
||||
|
|
@ -91,7 +91,7 @@ class ProposalController < ApplicationController
|
|||
event.update_attributes!(params[:event])
|
||||
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
||||
notice: "'#{event.title}' was successfully updated.")
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message
|
||||
end
|
||||
end
|
||||
|
|
@ -131,7 +131,7 @@ class ProposalController < ApplicationController
|
|||
|
||||
begin
|
||||
@event.save!
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
@url = conference_proposal_index_path(@conference.short_title)
|
||||
@event_types = @conference.event_types
|
||||
@user = current_user
|
||||
|
|
@ -182,7 +182,6 @@ class ProposalController < ApplicationController
|
|||
end
|
||||
|
||||
def restart
|
||||
@event
|
||||
if @event.transition_possible? :restart
|
||||
begin
|
||||
@event.restart
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
class ScheduleController < ApplicationController
|
||||
|
||||
layout "application"
|
||||
|
||||
def index
|
||||
@conference = Conference.includes(:rooms, {:events => [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first
|
||||
@conference = Conference.includes(:rooms, {events: [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first
|
||||
@rooms = @conference.rooms
|
||||
@events = @conference.events
|
||||
@dates = @conference.start_date..@conference.end_date
|
||||
|
|
@ -14,5 +13,4 @@ class ScheduleController < ApplicationController
|
|||
@today = @conference.start_date.strftime("%Y-%m-%d")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module Users
|
|||
openid = Openid.find_for_oauth(auth_hash) # Get or create openid
|
||||
# If openid exists and is associated with a user, sign in with associated user,
|
||||
# even if the email of the associated user and the email of the provided openid are different
|
||||
unless user = openid.user
|
||||
unless (user = openid.user)
|
||||
user = User.find_for_auth(auth_hash, current_user) # Get or create users
|
||||
end
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ module Users
|
|||
|
||||
sign_in user
|
||||
redirect_to root_path, notice: user.email + " signed in successfully with #{provider}"
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def normalize_array_length(hashmap, length)
|
||||
hashmap.each do |key, value|
|
||||
hashmap.each do |_, value|
|
||||
if value.length < length
|
||||
value.fill(value[-1], value.length...length)
|
||||
end
|
||||
|
|
@ -126,15 +126,15 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def add_association_link(association_name, form_builder, div_class, html_options = {})
|
||||
link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success")
|
||||
link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(class: "assoc btn btn-success")
|
||||
end
|
||||
|
||||
def remove_association_link(association_name, form_builder)
|
||||
link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, :class => "assoc btn btn-danger") + tag(:hr)
|
||||
link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, class: "assoc btn btn-danger") + tag(:hr)
|
||||
end
|
||||
|
||||
def dynamic_association(association_name, title, form_builder, options = {})
|
||||
render "shared/dynamic_association", :association_name => association_name, :title => title, :f => form_builder, :hint => options[:hint]
|
||||
render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint]
|
||||
end
|
||||
|
||||
def has_role?(current_user, role)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ class Mailbot < ActionMailer::Base
|
|||
person.email,
|
||||
conference.email_settings.registration_subject,
|
||||
conference.email_settings.generate_registration_email(conference, person))
|
||||
|
||||
end
|
||||
|
||||
def acceptance_mail(event)
|
||||
|
|
@ -16,7 +15,6 @@ class Mailbot < ActionMailer::Base
|
|||
person.email,
|
||||
conference.email_settings.accepted_subject,
|
||||
conference.email_settings.generate_accepted_email(event))
|
||||
|
||||
end
|
||||
|
||||
def rejection_mail(event)
|
||||
|
|
@ -66,11 +64,10 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def build_email(conference, to, subject, body)
|
||||
mail(:to => to,
|
||||
:from => conference.contact_email,
|
||||
:reply_to => conference.contact_email,
|
||||
:subject => subject,
|
||||
:body => body)
|
||||
mail(to: to,
|
||||
from: conference.contact_email,
|
||||
reply_to: conference.contact_email,
|
||||
subject: subject,
|
||||
body: body)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
def initialize(user) # rubocop:disable Lint/UnusedMethodArgument
|
||||
# Define abilities for the passed in user here. For example:
|
||||
#
|
||||
# user ||= User.new # guest user (not logged in)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class Answer < ActiveRecord::Base
|
|||
attr_accessible :title
|
||||
|
||||
has_many :qanswers
|
||||
has_many :questions, :through => :qanswers
|
||||
has_many :questions, through: :qanswers
|
||||
|
||||
validates :title, :presence => true
|
||||
validates :title, presence: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class CallForPapers < ActiveRecord::Base
|
|||
belongs_to :conference
|
||||
|
||||
validates_presence_of :start_date, :end_date
|
||||
validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 }
|
||||
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
||||
|
||||
##
|
||||
# Calculates how many weeks the call for paper is.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class Comment < ActiveRecord::Base
|
||||
acts_as_nested_set :scope => [:commentable_id, :commentable_type]
|
||||
acts_as_nested_set scope: [:commentable_id, :commentable_type]
|
||||
attr_accessible :commentable, :body, :user_id
|
||||
validates_presence_of :body
|
||||
validates_presence_of :user
|
||||
|
|
@ -8,7 +8,7 @@ class Comment < ActiveRecord::Base
|
|||
# want user to vote on the quality of comments.
|
||||
#acts_as_votable
|
||||
|
||||
belongs_to :commentable, :polymorphic => true
|
||||
belongs_to :commentable, polymorphic: true
|
||||
|
||||
# NOTE: Comments belong to a user
|
||||
belongs_to :user
|
||||
|
|
@ -18,9 +18,9 @@ class Comment < ActiveRecord::Base
|
|||
# example in readme
|
||||
def self.build_from(obj, user_id, comment)
|
||||
new \
|
||||
:commentable => obj,
|
||||
:body => comment,
|
||||
:user_id => user_id
|
||||
commentable: obj,
|
||||
body: comment,
|
||||
user_id: user_id
|
||||
end
|
||||
|
||||
#helper method to check if a comment has children
|
||||
|
|
@ -31,13 +31,13 @@ class Comment < ActiveRecord::Base
|
|||
# Helper class method to lookup all comments assigned
|
||||
# to all commentable types for a given user.
|
||||
scope :find_comments_by_user, lambda { |user|
|
||||
where(:user_id => user.id).order('created_at DESC')
|
||||
where(user_id: user.id).order('created_at DESC')
|
||||
}
|
||||
|
||||
# Helper class method to look up all comments for
|
||||
# commentable class name and commentable id.
|
||||
scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id|
|
||||
where(:commentable_type => commentable_str.to_s, :commentable_id => commentable_id).order('created_at DESC')
|
||||
where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC')
|
||||
}
|
||||
|
||||
# Helper class method to look up a commentable object
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Conference < ActiveRecord::Base
|
|||
format: URI::regexp(%w(http https)), allow_blank: true
|
||||
|
||||
validates_uniqueness_of :short_title
|
||||
validates_format_of :short_title, :with => /\A[a-zA-Z0-9_-]*\z/
|
||||
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
||||
before_create :generate_guid
|
||||
before_create :create_venue
|
||||
before_create :create_event_types
|
||||
|
|
@ -102,7 +102,6 @@ class Conference < ActiveRecord::Base
|
|||
return media_types
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Checks if the user is registered to the conference
|
||||
#
|
||||
|
|
@ -640,7 +639,7 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +Fixnum+ -> Progress in Percent
|
||||
def calculate_setup_progress(result)
|
||||
(result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s
|
||||
(result.select { |_k, v| v }.length / result.length.to_f * 100).round(0).to_s
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Datatable
|
|||
@view = view
|
||||
end
|
||||
|
||||
def as_json(options = {})
|
||||
def as_json
|
||||
{
|
||||
sEcho: params[:sEcho].to_i,
|
||||
iTotalRecords: @klass.count,
|
||||
|
|
@ -18,7 +18,6 @@ class Datatable
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
def data
|
||||
[]
|
||||
end
|
||||
|
|
@ -56,10 +55,10 @@ class Datatable
|
|||
search_for = params[:sSearch].split(' ')
|
||||
terms = {}
|
||||
which_one = -1
|
||||
criteria = search_for.inject([]) do |criteria,atom|
|
||||
criteria = search_for.inject([]) do |mem, atom|
|
||||
which_one += 1
|
||||
terms["search#{which_one}".to_sym] = "%#{atom}%"
|
||||
criteria << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})"
|
||||
mem << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})"
|
||||
end.join(' and ')
|
||||
[criteria, terms]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,5 +3,4 @@ class DietaryChoice < ActiveRecord::Base
|
|||
|
||||
belongs_to :conference
|
||||
has_many :registrations
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ class DifficultyLevel < ActiveRecord::Base
|
|||
belongs_to :conference
|
||||
has_many :events
|
||||
|
||||
validates :title, :presence => true
|
||||
validates :title, presence: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -197,11 +197,15 @@ class Event < ActiveRecord::Base
|
|||
errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0
|
||||
end
|
||||
|
||||
# TODO: create a module to be mixed into model to perform same operation
|
||||
# venue.rb has same functionality which can be shared
|
||||
# TODO: rename guid to UUID as guid is specifically Microsoft term
|
||||
def generate_guid
|
||||
begin
|
||||
guid = SecureRandom.urlsafe_base64
|
||||
end while self.class.where(guid: guid).exists?
|
||||
self.guid = guid
|
||||
loop do
|
||||
@guid = SecureRandom.urlsafe_base64
|
||||
break if !self.class.where(guid: guid).any?
|
||||
end
|
||||
self.guid = @guid
|
||||
end
|
||||
|
||||
def set_week
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class EventAttachment < ActiveRecord::Base
|
|||
belongs_to :event
|
||||
attr_accessible :public, :attachment, :event_id, :title
|
||||
|
||||
has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
|
||||
has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
def to_jq_upload
|
||||
|
|
@ -18,12 +18,9 @@ class EventAttachment < ActiveRecord::Base
|
|||
"delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id),
|
||||
"delete_type" => "DELETE"
|
||||
}
|
||||
|
||||
end
|
||||
#:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
|
||||
# :url => "/system/:attachment/:id/:style/:filename"
|
||||
|
||||
#has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"}
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class EventType < ActiveRecord::Base
|
|||
belongs_to :conference
|
||||
|
||||
validates :title, presence: true
|
||||
validates :length, :numericality => {:greater_than => 0}
|
||||
validates :length, numericality: {greater_than: 0}
|
||||
validates :minimum_abstract_length, presence: true
|
||||
validates :maximum_abstract_length, presence: true
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Openid < ActiveRecord::Base
|
|||
|
||||
if openid.new_record?
|
||||
openid.email = auth.info.email
|
||||
if existing_openid = Openid.where(email: openid.email).first
|
||||
if (existing_openid = Openid.where(email: openid.email).first)
|
||||
openid.user_id = existing_openid.user_id
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class Qanswer < ActiveRecord::Base
|
|||
attr_accessible :question_id, :answer_id
|
||||
|
||||
belongs_to :question
|
||||
belongs_to :answer, :dependent => :delete
|
||||
belongs_to :answer, dependent: :delete
|
||||
|
||||
has_and_belongs_to_many :registrations
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ class Question < ActiveRecord::Base
|
|||
belongs_to :question_type
|
||||
has_and_belongs_to_many :conferences
|
||||
|
||||
has_many :qanswers, :dependent => :delete_all
|
||||
has_many :answers, :through => :qanswers, :dependent => :delete_all
|
||||
has_many :qanswers, dependent: :delete_all
|
||||
has_many :answers, through: :qanswers, dependent: :delete_all
|
||||
|
||||
validates :title, :presence => true
|
||||
validates :answers, :presence => true
|
||||
validates :title, presence: true
|
||||
validates :answers, presence: true
|
||||
|
||||
accepts_nested_attributes_for :answers, :allow_destroy => true
|
||||
accepts_nested_attributes_for :answers, allow_destroy: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,5 +15,4 @@ class Room < ActiveRecord::Base
|
|||
# end while Person.where(:guid => guid).exists?
|
||||
self.guid = guid
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ class Track < ActiveRecord::Base
|
|||
# end while Person.where(:guid => guid).exists?
|
||||
self.guid = guid
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ class Vday < ActiveRecord::Base
|
|||
belongs_to :conference
|
||||
|
||||
has_many :vchoices
|
||||
has_many :vpositions, :through => :vchoices, :dependent => :destroy
|
||||
has_many :vpositions, through: :vchoices, dependent: :destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,13 +11,17 @@ class Venue < ActiveRecord::Base
|
|||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
accepts_nested_attributes_for :lodgings, allow_destroy: true
|
||||
|
||||
private
|
||||
|
||||
# TODO: create a module to be mixed into model to perform same operation
|
||||
# event.rb has same functionality which can be shared
|
||||
# TODO: rename guid to UUID as guid is specifically Microsoft term
|
||||
def generate_guid
|
||||
begin
|
||||
guid = SecureRandom.urlsafe_base64
|
||||
end while Venue.where(:guid => guid).exists?
|
||||
self.guid = guid
|
||||
loop do
|
||||
@guid = SecureRandom.urlsafe_base64
|
||||
break if !Venue.where(guid: guid).any?
|
||||
end
|
||||
self.guid = @guid
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,5 +4,4 @@ class Vote < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :event
|
||||
delegate :name, to: :user
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class Vposition < ActiveRecord::Base
|
|||
belongs_to :conference
|
||||
|
||||
has_many :vchoices
|
||||
has_many :vdays, :through => :vchoices
|
||||
has_many :vdays, through: :vchoices
|
||||
|
||||
validates_presence_of :title, :vdays
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue