Fix basic style issues with rubocop

This commit is contained in:
Artem Chernikov 2014-07-21 14:27:32 +02:00
parent f4a22851a1
commit 763f864dc9
36 changed files with 108 additions and 143 deletions

View file

@ -25,6 +25,5 @@ class Admin::DifficultyLevelsController < ApplicationController
flash[:error] = "Difficulty Levels update failed."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
end
end
end

View file

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

View file

@ -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
@ -91,6 +91,6 @@ class Admin::QuestionsController < ApplicationController
end
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id)
@questions_conference = @conference.questions
@questions_conference = @conference.questions
end
end

View file

@ -11,7 +11,5 @@ class Admin::SocialEventsController < ApplicationController
else
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.')
end
end
end

View file

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

View file

@ -19,5 +19,4 @@ class Admin::VenueController < ApplicationController
@venue = @conference.venue
render :venue_info
end
end

View file

@ -71,8 +71,10 @@ class EventAttachmentsController < ApplicationController
: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 }

View file

@ -1,5 +1,4 @@
class ScheduleController < ApplicationController
layout "application"
def index
@ -14,5 +13,4 @@ class ScheduleController < ApplicationController
@today = @conference.start_date.strftime("%Y-%m-%d")
end
end
end

View file

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

View file

@ -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)
@ -63,5 +61,4 @@ class Mailbot < ActionMailer::Base
:subject => subject,
:body => body)
end
end

View file

@ -102,7 +102,6 @@ class Conference < ActiveRecord::Base
return media_types
end
##
# Checks if the user is registered to the conference
#

View file

@ -18,7 +18,6 @@ class Datatable
}
end
def data
[]
end

View file

@ -3,5 +3,4 @@ class DietaryChoice < ActiveRecord::Base
belongs_to :conference
has_many :registrations
end

View file

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

View file

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

View file

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

View file

@ -15,5 +15,4 @@ class Room < ActiveRecord::Base
# end while Person.where(:guid => guid).exists?
self.guid = guid
end
end

View file

@ -14,5 +14,4 @@ class Track < ActiveRecord::Base
# end while Person.where(:guid => guid).exists?
self.guid = guid
end
end

View file

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

View file

@ -4,5 +4,4 @@ class Vote < ActiveRecord::Base
belongs_to :user
belongs_to :event
delegate :name, to: :user
end