rubocop files update and auto correction
This commit is contained in:
parent
1a62dc930e
commit
1f82fbbdc6
88 changed files with 519 additions and 452 deletions
|
|
@ -50,12 +50,8 @@ class Ability
|
|||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||
can :show, User
|
||||
unless CONFIG['authentication']['ichain']['enabled']
|
||||
can [:show, :create], Registration do |registration|
|
||||
registration.new_record?
|
||||
end
|
||||
can [:show, :create], Event do |event|
|
||||
event.new_record?
|
||||
end
|
||||
can [:show, :create], Registration, &:new_record?
|
||||
can [:show, :create], Event, &:new_record?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class CallForPaper < ActiveRecord::Base
|
|||
&& !self.conference.email_settings.call_for_papers_dates_updates_subject.blank?\
|
||||
&& !self.conference.email_settings.call_for_papers_dates_updates_template.blank?
|
||||
end
|
||||
|
||||
##
|
||||
# Checks whether cfp dates is updated
|
||||
#
|
||||
|
|
@ -72,14 +73,14 @@ class CallForPaper < ActiveRecord::Base
|
|||
|
||||
def before_end_of_conference
|
||||
errors.
|
||||
add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
|
||||
add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
|
||||
|
||||
errors.
|
||||
add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
|
||||
add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
|
||||
end
|
||||
|
||||
def start_after_end_date
|
||||
errors.
|
||||
add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||
add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
##
|
||||
# This class represents a conference
|
||||
# rubocop:disable Style/ClassLength
|
||||
# rubocop:disable Metrics/ClassLength
|
||||
class Conference < ActiveRecord::Base
|
||||
require 'uri'
|
||||
serialize :events_per_week, Hash
|
||||
|
|
@ -218,7 +218,7 @@ class Conference < ActiveRecord::Base
|
|||
result[state] = pad_array_left_not_kumulative(start_week, values)
|
||||
end
|
||||
end
|
||||
result['Weeks'] = weeks > 0 ? (1..weeks).to_a : 0
|
||||
result['Weeks'] = weeks > 0 ? (1..weeks).to_a : 0
|
||||
end
|
||||
result
|
||||
end
|
||||
|
|
@ -232,9 +232,9 @@ class Conference < ActiveRecord::Base
|
|||
result = []
|
||||
|
||||
if registrations &&
|
||||
registration_period &&
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
registration_period &&
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
|
||||
reg = registrations.group(:week).count
|
||||
start_week = get_registration_start_week
|
||||
|
|
@ -253,10 +253,10 @@ class Conference < ActiveRecord::Base
|
|||
result = 0
|
||||
weeks = 0
|
||||
if registration_period &&
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
weeks = Date.new(registration_period.start_date.year, 12, 31).
|
||||
strftime('%W').to_i
|
||||
strftime('%W').to_i
|
||||
|
||||
result = get_registration_end_week - get_registration_start_week + 1
|
||||
end
|
||||
|
|
@ -353,8 +353,8 @@ class Conference < ActiveRecord::Base
|
|||
# * +hash+ -> user: submissions
|
||||
def get_top_submitter(limit = 5)
|
||||
submitter = EventUser.joins(:event).
|
||||
where('event_role = ? and conference_id = ?', 'submitter', id).
|
||||
limit(limit).group(:user_id)
|
||||
where('event_role = ? and conference_id = ?', 'submitter', id).
|
||||
limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count
|
||||
Conference.calculate_user_submission_hash(submitter, counter)
|
||||
end
|
||||
|
|
@ -476,12 +476,12 @@ class Conference < ActiveRecord::Base
|
|||
# * +ActiveRecord+
|
||||
def self.get_active_conferences_for_dashboard
|
||||
result = Conference.where('start_date > ?', Time.now).
|
||||
select('id, short_title, color, start_date')
|
||||
select('id, short_title, color, start_date')
|
||||
|
||||
if result.length == 0
|
||||
result = Conference.
|
||||
select('id, short_title, color, start_date').limit(2).
|
||||
order(start_date: :desc)
|
||||
select('id, short_title, color, start_date').limit(2).
|
||||
order(start_date: :desc)
|
||||
end
|
||||
result
|
||||
end
|
||||
|
|
@ -570,9 +570,9 @@ class Conference < ActiveRecord::Base
|
|||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||
def notify_on_dates_changed?
|
||||
(self.start_date_changed? || self.end_date_changed?) &&
|
||||
self.email_settings.send_on_updated_conference_dates &&
|
||||
!self.email_settings.updated_conference_dates_subject.blank? &&
|
||||
self.email_settings.updated_conference_dates_template
|
||||
self.email_settings.send_on_updated_conference_dates &&
|
||||
!self.email_settings.updated_conference_dates_subject.blank? &&
|
||||
self.email_settings.updated_conference_dates_template
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -583,10 +583,10 @@ class Conference < ActiveRecord::Base
|
|||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||
def notify_on_registration_dates_changed?
|
||||
registration_period &&
|
||||
(registration_period.start_date_changed? || registration_period.end_date_changed?) &&
|
||||
email_settings.send_on_updated_conference_registration_dates &&
|
||||
!email_settings.updated_conference_registration_dates_subject.blank? &&
|
||||
email_settings.updated_conference_registration_dates_template
|
||||
(registration_period.start_date_changed? || registration_period.end_date_changed?) &&
|
||||
email_settings.send_on_updated_conference_registration_dates &&
|
||||
!email_settings.updated_conference_registration_dates_subject.blank? &&
|
||||
email_settings.updated_conference_registration_dates_template
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Datatable
|
|||
def sort_order
|
||||
colnum = 0
|
||||
sort_by = []
|
||||
while true
|
||||
loop do
|
||||
break if !sorted?(colnum)
|
||||
sort_by << "#{sort_column(colnum)} #{sort_direction(colnum)}"
|
||||
colnum += 1
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ class EmailSettings < ActiveRecord::Base
|
|||
'conference_start_date' => conference.start_date,
|
||||
'conference_end_date' => conference.end_date,
|
||||
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registrations_url(
|
||||
conference.short_title, host: CONFIG['url_for_emails']),
|
||||
conference.short_title, host: CONFIG['url_for_emails']),
|
||||
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
||||
conference.short_title, host: CONFIG['url_for_emails']),
|
||||
conference.short_title, host: CONFIG['url_for_emails']),
|
||||
|
||||
'schedule_link' => Rails.application.routes.url_helpers.schedule_conference_url(
|
||||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
}
|
||||
|
||||
if conference.call_for_paper
|
||||
|
|
@ -52,7 +52,7 @@ class EmailSettings < ActiveRecord::Base
|
|||
if event
|
||||
h['eventtitle'] = event.title
|
||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_index_url(
|
||||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
end
|
||||
h
|
||||
end
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def process_confirmation
|
||||
if conference.email_settings.send_on_confirmed_without_registration? &&
|
||||
conference.email_settings.confirmed_email_template &&
|
||||
conference.email_settings.confirmed_without_registration_subject
|
||||
conference.email_settings.confirmed_email_template &&
|
||||
conference.email_settings.confirmed_without_registration_subject
|
||||
if conference.registrations.where(user_id: submitter.id).first.nil?
|
||||
Mailbot.delay.confirm_reminder_mail(self)
|
||||
end
|
||||
|
|
@ -122,9 +122,9 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def process_acceptance(options)
|
||||
if conference.email_settings.send_on_accepted &&
|
||||
conference.email_settings.accepted_email_template &&
|
||||
conference.email_settings.accepted_subject &&
|
||||
!options[:send_mail].blank?
|
||||
conference.email_settings.accepted_email_template &&
|
||||
conference.email_settings.accepted_subject &&
|
||||
!options[:send_mail].blank?
|
||||
Rails.logger.debug 'Sending event acceptance mail'
|
||||
Mailbot.delay.acceptance_mail(self)
|
||||
end
|
||||
|
|
@ -132,9 +132,9 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def process_rejection(options)
|
||||
if conference.email_settings.send_on_rejected &&
|
||||
conference.email_settings.rejected_email_template &&
|
||||
conference.email_settings.rejected_subject &&
|
||||
!options[:send_mail].blank?
|
||||
conference.email_settings.rejected_email_template &&
|
||||
conference.email_settings.rejected_subject &&
|
||||
!options[:send_mail].blank?
|
||||
Rails.logger.debug 'Sending rejected mail'
|
||||
Mailbot.delay.rejection_mail(self)
|
||||
end
|
||||
|
|
@ -244,7 +244,7 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def before_end_of_conference
|
||||
errors.
|
||||
add(:created_at, "can't be after the conference end date!") if conference.end_date &&
|
||||
(Date.today > conference.end_date)
|
||||
add(:created_at, "can't be after the conference end date!") if conference.end_date &&
|
||||
(Date.today > conference.end_date)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Target < ActiveRecord::Base
|
|||
numerator = conference.current_program_minutes
|
||||
end
|
||||
|
||||
progress = (numerator / target_count.to_f * 100).round(0).to_s
|
||||
progress = (numerator / target_count.to_f * 100).round(0).to_s
|
||||
result = {
|
||||
'target_name' => to_s,
|
||||
'campaign_name' => campaign.name,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Ticket < ActiveRecord::Base
|
|||
tickets.each do |ticket|
|
||||
price = ticket.total_price(user)
|
||||
if result
|
||||
result += price unless price.zero?
|
||||
result += price unless price.zero?
|
||||
else
|
||||
result = price
|
||||
end
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class User < ActiveRecord::Base
|
|||
result = {}
|
||||
Role::ACTIONABLES.each do |role|
|
||||
resources = self.roles.where(name: role.parameterize.underscore).map{ |myrole| Conference.find(myrole.resource_id).short_title }.join ', '
|
||||
result[role.parameterize.underscore] = "(#{ resources })" unless resources.blank?
|
||||
result[role.parameterize.underscore] = "(#{resources})" unless resources.blank?
|
||||
end
|
||||
result
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ class Venue < ActiveRecord::Base
|
|||
|
||||
def venue_notify?(conference)
|
||||
(self.name_changed? || self.street_changed?) &&
|
||||
(!self.name.blank? && !self.street.blank?) &&
|
||||
(conference.email_settings.send_on_venue_update &&
|
||||
!conference.email_settings.venue_update_subject.blank? &&
|
||||
conference.email_settings.venue_update_template)
|
||||
(!self.name.blank? && !self.street.blank?) &&
|
||||
(conference.email_settings.send_on_venue_update &&
|
||||
!conference.email_settings.venue_update_subject.blank? &&
|
||||
conference.email_settings.venue_update_template)
|
||||
end
|
||||
|
||||
# TODO: create a module to be mixed into model to perform same operation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue