style: if ! changed by unless
- if ! changed by unless as it is more readable - !object.blank? is equivalent to object.present?, also more readable
This commit is contained in:
parent
96155eb87f
commit
7e5d20c89d
18 changed files with 27 additions and 28 deletions
|
|
@ -103,7 +103,7 @@ module Admin
|
||||||
comment.commentable = @event
|
comment.commentable = @event
|
||||||
comment.user_id = current_user.id
|
comment.user_id = current_user.id
|
||||||
comment.save!
|
comment.save!
|
||||||
if !params[:parent].nil?
|
unless params[:parent].nil?
|
||||||
comment.move_to_child_of(params[:parent])
|
comment.move_to_child_of(params[:parent])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ module Admin
|
||||||
|
|
||||||
def get_event
|
def get_event
|
||||||
@event = @conference.program.events.find(params[:id])
|
@event = @conference.program.events.find(params[:id])
|
||||||
if !@event
|
unless @event
|
||||||
redirect_to admin_conference_program_events_path(conference_id: @conference.short_title),
|
redirect_to admin_conference_program_events_path(conference_id: @conference.short_title),
|
||||||
error: 'Error! Could not find event!'
|
error: 'Error! Could not find event!'
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ module Admin
|
||||||
def destroy
|
def destroy
|
||||||
if can? :destroy, @question
|
if can? :destroy, @question
|
||||||
# Do not delete global questions
|
# Do not delete global questions
|
||||||
if !@question.global
|
unless @question.global
|
||||||
|
|
||||||
# Delete question and its answers
|
# Delete question and its answers
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
|
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
|
||||||
message = exception.message
|
message = exception.message
|
||||||
message << ' Maybe you need to sign in?' if !current_user
|
message << ' Maybe you need to sign in?' unless current_user
|
||||||
redirect_to root_path, alert: message
|
redirect_to root_path, alert: message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
ahoy.track 'Registered', title: 'New registration'
|
ahoy.track 'Registered', title: 'New registration'
|
||||||
|
|
||||||
# Sign in the new user
|
# Sign in the new user
|
||||||
if !current_user
|
unless current_user
|
||||||
sign_in(@registration.user)
|
sign_in(@registration.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
|
|
||||||
def set_registration
|
def set_registration
|
||||||
@registration = Registration.find_by(conference: @conference, user: current_user)
|
@registration = Registration.find_by(conference: @conference, user: current_user)
|
||||||
if !@registration
|
unless @registration
|
||||||
redirect_to new_conference_conference_registration_path(@conference.short_title),
|
redirect_to new_conference_conference_registration_path(@conference.short_title),
|
||||||
error: "Can't find a registration for #{@conference.title} for you. Please register."
|
error: "Can't find a registration for #{@conference.title} for you. Please register."
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ class Conference < ActiveRecord::Base
|
||||||
result[state.name] = count
|
result[state.name] = count
|
||||||
end
|
end
|
||||||
|
|
||||||
if !conference.events_per_week
|
unless conference.events_per_week
|
||||||
conference.events_per_week = {}
|
conference.events_per_week = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -692,7 +692,7 @@ class Conference < ActiveRecord::Base
|
||||||
events_per_week.each do |week, values|
|
events_per_week.each do |week, values|
|
||||||
values.each do |state, value|
|
values.each do |state, value|
|
||||||
if [:confirmed, :unconfirmed].include?(state)
|
if [:confirmed, :unconfirmed].include?(state)
|
||||||
if !result[state.to_s.capitalize]
|
unless result[state.to_s.capitalize]
|
||||||
result[state.to_s.capitalize] = {}
|
result[state.to_s.capitalize] = {}
|
||||||
end
|
end
|
||||||
result[state.to_s.capitalize][week.strftime('%W').to_i] = value
|
result[state.to_s.capitalize][week.strftime('%W').to_i] = value
|
||||||
|
|
@ -768,7 +768,7 @@ class Conference < ActiveRecord::Base
|
||||||
def assert_keys_are_continuously(hash)
|
def assert_keys_are_continuously(hash)
|
||||||
keys = hash.keys
|
keys = hash.keys
|
||||||
(keys.min..keys.max).each do |key|
|
(keys.min..keys.max).each do |key|
|
||||||
if !hash[key]
|
unless hash[key]
|
||||||
hash[key] = 0
|
hash[key] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1004,7 +1004,7 @@ class Conference < ActiveRecord::Base
|
||||||
# Adds a random color to the conference
|
# Adds a random color to the conference
|
||||||
#
|
#
|
||||||
def add_color
|
def add_color
|
||||||
if !color
|
unless color
|
||||||
self.color = get_color
|
self.color = get_color
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class Contact < ActiveRecord::Base
|
||||||
format: URI::regexp(%w(http https)), allow_blank: true
|
format: URI::regexp(%w(http https)), allow_blank: true
|
||||||
|
|
||||||
def has_social_media?
|
def has_social_media?
|
||||||
return true if !facebook.blank? || !twitter.blank? || !googleplus.blank? || !instagram.blank? || !email.blank?
|
return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || email.present?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,7 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
def submitter
|
def submitter
|
||||||
result = event_users.where(event_role: 'submitter').first
|
result = event_users.where(event_role: 'submitter').first
|
||||||
if !result.nil?
|
if result.nil?
|
||||||
result.user
|
|
||||||
else
|
|
||||||
user = nil
|
user = nil
|
||||||
# Perhaps the event_users haven't been saved, if this is a new proposal
|
# Perhaps the event_users haven't been saved, if this is a new proposal
|
||||||
event_users.each do |u|
|
event_users.each do |u|
|
||||||
|
|
@ -126,6 +124,8 @@ class Event < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user
|
user
|
||||||
|
else
|
||||||
|
result.user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -281,7 +281,7 @@ class Event < ActiveRecord::Base
|
||||||
def generate_guid
|
def generate_guid
|
||||||
loop do
|
loop do
|
||||||
@guid = SecureRandom.urlsafe_base64
|
@guid = SecureRandom.urlsafe_base64
|
||||||
break if !self.class.where(guid: guid).any?
|
break unless self.class.where(guid: guid).any?
|
||||||
end
|
end
|
||||||
self.guid = @guid
|
self.guid = @guid
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Venue < ActiveRecord::Base
|
||||||
def generate_guid
|
def generate_guid
|
||||||
loop do
|
loop do
|
||||||
@guid = SecureRandom.urlsafe_base64
|
@guid = SecureRandom.urlsafe_base64
|
||||||
break if !Venue.where(guid: guid).any?
|
break unless Venue.where(guid: guid).any?
|
||||||
end
|
end
|
||||||
self.guid = @guid
|
self.guid = @guid
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,13 @@
|
||||||
%td
|
%td
|
||||||
= @event.language
|
= @event.language
|
||||||
|
|
||||||
- if !@event.room.nil?
|
- unless @event.room.nil?
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Room
|
%b Room
|
||||||
%td
|
%td
|
||||||
= @event.room.name
|
= @event.room.name
|
||||||
- if !@event.start_time.nil?
|
- unless @event.start_time.nil?
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Scheduled time
|
%b Scheduled time
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
- bgcolor=""
|
- bgcolor=""
|
||||||
%td{:style=>"background-color: #{bgcolor}"}
|
%td{:style=>"background-color: #{bgcolor}"}
|
||||||
- if @program.show_voting?
|
- if @program.show_voting?
|
||||||
- if !event.submitter.nil?
|
- unless event.submitter.nil?
|
||||||
=link_to event.submitter.name, admin_user_path(event.submitter)
|
=link_to event.submitter.name, admin_user_path(event.submitter)
|
||||||
- if event.submitter.registrations.count < 1
|
- if event.submitter.registrations.count < 1
|
||||||
(Unregistered!)
|
(Unregistered!)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
- @event.versions.each do |version|
|
- @event.versions.each do |version|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
- if !version.whodunnit.nil?
|
- unless version.whodunnit.nil?
|
||||||
= User.find(version.whodunnit).name
|
= User.find(version.whodunnit).name
|
||||||
- else
|
- else
|
||||||
No user (probably via the console)
|
No user (probably via the console)
|
||||||
|
|
@ -35,4 +35,3 @@
|
||||||
- version.changeset.each_key do |key|
|
- version.changeset.each_key do |key|
|
||||||
= "#{key}: #{version.changeset[key][0]} -> #{version.changeset[key][1]}"
|
= "#{key}: #{version.changeset[key][0]} -> #{version.changeset[key][1]}"
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
- slice.each do |lodging|
|
- slice.each do |lodging|
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.thumbnail
|
.thumbnail
|
||||||
- if !lodging.picture?
|
- unless lodging.picture?
|
||||||
%p.text-center
|
%p.text-center
|
||||||
%i.fa.fa-home.fa-5x
|
%i.fa.fa-home.fa-5x
|
||||||
- else
|
- else
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
- if conference.venue
|
- if conference.venue
|
||||||
%p
|
%p
|
||||||
= "#{conference.venue.city}/#{conference.venue.country_name}"
|
= "#{conference.venue.city}/#{conference.venue.country_name}"
|
||||||
- if !conference.description.blank?
|
- unless conference.description.blank?
|
||||||
%p
|
%p
|
||||||
= markdown(conference.description)
|
= markdown(conference.description)
|
||||||
.col-md-2
|
.col-md-2
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
- slice.each do |lodging|
|
- slice.each do |lodging|
|
||||||
.col-md-4.col-sm-4.ticket.col-centered.col-top
|
.col-md-4.col-sm-4.ticket.col-centered.col-top
|
||||||
.thumbnail
|
.thumbnail
|
||||||
- if !lodging.picture?
|
- unless lodging.picture?
|
||||||
%p.text-center
|
%p.text-center
|
||||||
%i.fa.fa-home.fa-5x
|
%i.fa.fa-home.fa-5x
|
||||||
- else
|
- else
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
= @conference.title
|
= @conference.title
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
- if !current_user
|
- unless current_user
|
||||||
%legend
|
%legend
|
||||||
%span
|
%span
|
||||||
=link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
=link_to('#signup', role: 'tab', "aria-controls" => "home", "data-toggle" => "tab") do
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
%h4.media-heading
|
%h4.media-heading
|
||||||
= ticket.title
|
= ticket.title
|
||||||
%h5.media-heading
|
%h5.media-heading
|
||||||
-if !ticket.description.blank?
|
-unless ticket.description.blank?
|
||||||
= markdown(ticket.description)
|
= markdown(ticket.description)
|
||||||
%td.col-sm-1.col-md-1
|
%td.col-sm-1.col-md-1
|
||||||
= text_field_tag("tickets[][#{ticket.id}]", 0, type: 'number', min: 0,
|
= text_field_tag("tickets[][#{ticket.id}]", 0, type: 'number', min: 0,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
= render partial: 'encouragement_text'
|
= render partial: 'encouragement_text'
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
- if !current_user
|
- unless current_user
|
||||||
%legend
|
%legend
|
||||||
%span
|
%span
|
||||||
=link_to('#signup', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
=link_to('#signup', role: 'tab', 'aria-controls' => 'home', 'data-toggle' => 'tab') do
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
%h4.media-heading
|
%h4.media-heading
|
||||||
= ticket.title
|
= ticket.title
|
||||||
%h5.media-heading
|
%h5.media-heading
|
||||||
-if !ticket.description.blank?
|
- unless ticket.description.blank?
|
||||||
= markdown(ticket.description)
|
= markdown(ticket.description)
|
||||||
%td.col-sm-1.col-md-1
|
%td.col-sm-1.col-md-1
|
||||||
- if ticket.bought?(current_user)
|
- if ticket.bought?(current_user)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue