mirror of
https://github.com/openSUSE/osem.git
synced 2025-12-23 22:28:15 -05:00
Autocorrect new rubocop offenses
This commit is contained in:
@@ -8,7 +8,7 @@ module Admin
|
||||
|
||||
def index
|
||||
# Redirect to new form if there is no conference
|
||||
if Conference.count == 0
|
||||
if Conference.none?
|
||||
redirect_to new_admin_conference_path
|
||||
return
|
||||
end
|
||||
|
||||
@@ -69,7 +69,7 @@ module Admin
|
||||
end
|
||||
|
||||
# The conference must have at least 1 organizer
|
||||
if @role.name == 'organizer' && state == 'false' && @role.users.count == 1
|
||||
if @role.name == 'organizer' && state == 'false' && @role.users.one?
|
||||
redirect_to admin_conference_role_path(@conference.short_title, @role.name),
|
||||
error: 'The conference must have at least 1 organizer!'
|
||||
return
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
module Admin
|
||||
class VolunteersController < Admin::BaseController
|
||||
include VolunteersHelper
|
||||
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
||||
def index
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :set_paper_trail_whodunnit
|
||||
include ApplicationHelper
|
||||
|
||||
add_flash_types :error
|
||||
protect_from_forgery with: :exception, prepend: true
|
||||
before_action :store_location
|
||||
|
||||
@@ -50,14 +50,14 @@ class ConferencesController < ApplicationController
|
||||
).order('tracks.name')
|
||||
end
|
||||
if splashpage.include_booths
|
||||
@booths = @conference.confirmed_booths.order('title')
|
||||
@booths = @conference.confirmed_booths.order(:title)
|
||||
end
|
||||
end
|
||||
if splashpage.include_registrations || splashpage.include_tickets
|
||||
@tickets = @conference.tickets.order('price_cents')
|
||||
@tickets = @conference.tickets.order(:price_cents)
|
||||
end
|
||||
if splashpage.include_lodgings
|
||||
@lodgings = @conference.lodgings.order('name')
|
||||
@lodgings = @conference.lodgings.order(:name)
|
||||
end
|
||||
if splashpage.include_sponsors
|
||||
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
|
||||
|
||||
@@ -39,7 +39,7 @@ module EventsHelper
|
||||
end
|
||||
|
||||
def canceled_replacement_event_label(event, event_schedule, *label_classes)
|
||||
if event.state == 'canceled' || event.state == 'withdrawn'
|
||||
if ['canceled', 'withdrawn'].include?(event.state)
|
||||
content_tag :span, 'CANCELED', class: (['label', 'label-danger'] + label_classes)
|
||||
elsif event_schedule.present? && event_schedule.replacement?(@withdrawn_event_schedules)
|
||||
content_tag :span, 'REPLACEMENT', class: (['label', 'label-info'] + label_classes)
|
||||
|
||||
@@ -141,7 +141,7 @@ class AdminAbility
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
['Conference', 'Track'].include?(role.resource_type)
|
||||
end
|
||||
|
||||
can [:edit, :update, :toggle_user], Role do |role|
|
||||
@@ -180,7 +180,7 @@ class AdminAbility
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
['Conference', 'Track'].include?(role.resource_type)
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
@@ -218,7 +218,7 @@ class AdminAbility
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
['Conference', 'Track'].include?(role.resource_type)
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
@@ -242,7 +242,7 @@ class AdminAbility
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
['Conference', 'Track'].include?(role.resource_type)
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
@@ -278,7 +278,7 @@ class AdminAbility
|
||||
|
||||
# Show Roles in the admin sidebar and allow authorization of the index action
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
['Conference', 'Track'].include?(role.resource_type)
|
||||
end
|
||||
|
||||
can :toggle_user, Role do |role|
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Booth < ApplicationRecord
|
||||
include ActiveRecord::Transitions
|
||||
|
||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||
|
||||
belongs_to :conference
|
||||
|
||||
@@ -35,13 +35,13 @@ class Comment < ApplicationRecord
|
||||
# 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)
|
||||
}
|
||||
|
||||
scope :find_since_last_login, lambda { |user|
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
class Conference < ApplicationRecord
|
||||
include RevisionCount
|
||||
|
||||
require 'uri'
|
||||
serialize :events_per_week, Hash
|
||||
# Needed to call 'Conference.with_role' in /models/ability.rb
|
||||
# Dependent destroy will fail as roles#destroy will be cancelled,hence delete_all
|
||||
resourcify :roles, dependent: :delete_all
|
||||
|
||||
default_scope { order('start_date DESC') }
|
||||
default_scope { order(start_date: :desc) }
|
||||
scope :upcoming, (-> { where(end_date: Date.current..) })
|
||||
scope :past, (-> { where(end_date: ...Date.current) })
|
||||
|
||||
@@ -39,7 +40,7 @@ class Conference < ApplicationRecord
|
||||
has_many :participants, through: :registrations, source: :user
|
||||
has_many :vdays, dependent: :destroy
|
||||
has_many :vpositions, dependent: :destroy
|
||||
has_many :sponsorship_levels, -> { order('position ASC') }, dependent: :destroy
|
||||
has_many :sponsorship_levels, -> { order(:position) }, dependent: :destroy
|
||||
has_many :sponsors, dependent: :destroy
|
||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||
has_many :subscriptions, dependent: :destroy
|
||||
@@ -107,7 +108,7 @@ class Conference < ApplicationRecord
|
||||
# * +false+ -> If the user is registered
|
||||
# * +true+ - If the user isn't registered
|
||||
def user_registered? user
|
||||
user.present? && registrations.where(user_id: user.id).count > 0
|
||||
user.present? && registrations.where(user_id: user.id).any?
|
||||
end
|
||||
|
||||
##
|
||||
@@ -350,7 +351,7 @@ class Conference < ApplicationRecord
|
||||
# * +hash+ -> user: submissions
|
||||
def self.get_top_submitter(limit = 5)
|
||||
submitter = EventUser.select(:user_id).where('event_role = ?', 'submitter').limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count(:all)
|
||||
counter = submitter.order(count_all: :desc).count(:all)
|
||||
calculate_user_submission_hash(submitter, counter)
|
||||
end
|
||||
|
||||
@@ -363,7 +364,7 @@ class Conference < ApplicationRecord
|
||||
submitter = EventUser.joins(:event).select(:user_id)
|
||||
.where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id)
|
||||
.limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count(:all)
|
||||
counter = submitter.order(count_all: :desc).count(:all)
|
||||
Conference.calculate_user_submission_hash(submitter, counter)
|
||||
end
|
||||
|
||||
@@ -921,7 +922,7 @@ class Conference < ApplicationRecord
|
||||
# * +True+ -> One difficulty level or more
|
||||
# * +False+ -> No diffculty level
|
||||
def difficulty_levels_set?
|
||||
program.difficulty_levels.count > 0
|
||||
program.difficulty_levels.any?
|
||||
end
|
||||
|
||||
##
|
||||
@@ -931,7 +932,7 @@ class Conference < ApplicationRecord
|
||||
# * +True+ -> One difficulty level or more
|
||||
# * +False+ -> No diffculty level
|
||||
def event_types_set?
|
||||
program.event_types.count > 0
|
||||
program.event_types.any?
|
||||
end
|
||||
|
||||
##
|
||||
@@ -941,7 +942,7 @@ class Conference < ApplicationRecord
|
||||
# * +True+ -> One track or more
|
||||
# * +False+ -> No track
|
||||
def tracks_set?
|
||||
program.tracks.count > 0
|
||||
program.tracks.any?
|
||||
end
|
||||
|
||||
##
|
||||
@@ -951,7 +952,7 @@ class Conference < ApplicationRecord
|
||||
# * +True+ -> One room or more
|
||||
# * +False+ -> No room
|
||||
def rooms_set?
|
||||
venue.present? && venue.rooms.count > 0
|
||||
venue.present? && venue.rooms.any?
|
||||
end
|
||||
|
||||
# Checks if the conference has a venue object.
|
||||
|
||||
@@ -4,6 +4,7 @@ class Event < ApplicationRecord
|
||||
include ActionView::Helpers::NumberHelper # for number_with_precision
|
||||
include ActiveRecord::Transitions
|
||||
include RevisionCount
|
||||
|
||||
has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
|
||||
|
||||
acts_as_commentable
|
||||
|
||||
@@ -82,13 +82,13 @@ class EventSchedule < ApplicationRecord
|
||||
end
|
||||
|
||||
def start_after_end_hour
|
||||
return unless event && start_time && event.program&.conference && event.program.conference.end_hour
|
||||
return unless event && start_time && event.program&.conference&.end_hour
|
||||
|
||||
errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour
|
||||
end
|
||||
|
||||
def start_before_start_hour
|
||||
return unless event && start_time && event.program&.conference && event.program.conference.start_hour
|
||||
return unless event && start_time && event.program&.conference&.start_hour
|
||||
|
||||
errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Room < ApplicationRecord
|
||||
include RevisionCount
|
||||
|
||||
belongs_to :venue
|
||||
has_many :event_schedules, dependent: :destroy
|
||||
has_many :tracks
|
||||
|
||||
@@ -25,7 +25,7 @@ class Survey < ActiveRecord::Base
|
||||
now = Time.current.in_time_zone(timezone)
|
||||
|
||||
if start_date && end_date
|
||||
now >= start_date && now <= end_date
|
||||
now.between?(start_date, end_date)
|
||||
elsif start_date && !end_date
|
||||
now >= start_date
|
||||
elsif !start_date && end_date
|
||||
|
||||
@@ -81,7 +81,7 @@ class Ticket < ApplicationRecord
|
||||
|
||||
def tickets_of_conference_have_same_currency
|
||||
tickets = Ticket.where(conference_id: conference_id)
|
||||
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
|
||||
return if tickets.none? || (tickets.one? && self == tickets.first)
|
||||
|
||||
unless tickets.all?{|t| t.price_currency == price_currency }
|
||||
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
|
||||
|
||||
@@ -97,8 +97,6 @@ class TicketPurchase < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_week
|
||||
self.week = created_at.strftime('%W')
|
||||
save!
|
||||
|
||||
@@ -233,8 +233,8 @@ class Track < ApplicationRecord
|
||||
(program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track|
|
||||
next unless existing_track.room == room && existing_track.start_date && existing_track.end_date
|
||||
|
||||
if start_date >= existing_track.start_date && start_date <= existing_track.end_date ||
|
||||
end_date >= existing_track.start_date && end_date <= existing_track.end_date ||
|
||||
if start_date.between?(existing_track.start_date, existing_track.end_date) ||
|
||||
end_date.between?(existing_track.start_date, existing_track.end_date) ||
|
||||
start_date <= existing_track.start_date && end_date >= existing_track.end_date
|
||||
errors.add(:track, 'has overlapping dates with a confirmed or accepted track in the same room')
|
||||
break
|
||||
|
||||
@@ -30,6 +30,7 @@ class User < ApplicationRecord
|
||||
:avatar_content_type, :avatar_file_size, :avatar_updated_at, :updated_at, :confirmation_sent_at, :confirmation_token, :reset_password_token]
|
||||
|
||||
include Gravtastic
|
||||
|
||||
gravtastic size: 32
|
||||
|
||||
before_create :setup_role
|
||||
@@ -238,7 +239,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def registered
|
||||
if registrations.count == 0
|
||||
if registrations.none?
|
||||
'None'
|
||||
else
|
||||
registrations.map { |r| r.conference.title }.join ', '
|
||||
@@ -247,7 +248,7 @@ class User < ApplicationRecord
|
||||
|
||||
def attended
|
||||
registrations_attended = registrations.where(attended: true)
|
||||
if registrations_attended.count == 0
|
||||
if registrations_attended.none?
|
||||
'None'
|
||||
else
|
||||
registrations_attended.map { |r| r.conference.title }.join ', '
|
||||
@@ -271,7 +272,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.empty?
|
||||
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
||||
User.one? && User.first.email == 'deleted@localhost.osem'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,7 +8,7 @@ class MigrateRolesForCancancan < ActiveRecord::Migration
|
||||
Role.all.each do |role|
|
||||
role.users.each do |user|
|
||||
Conference.all.each do |conference|
|
||||
if role.name == 'Admin' || role.name == 'Organizer'
|
||||
if ['Admin', 'Organizer'].include?(role.name)
|
||||
user.add_role :organizer, conference
|
||||
user.update_columns(is_admin: true)
|
||||
else
|
||||
|
||||
@@ -13,7 +13,7 @@ class MoveConferencesToOrganizations < ActiveRecord::Migration
|
||||
add_reference :conferences, :organization, index: true
|
||||
|
||||
TempConference.reset_column_information
|
||||
if TempConference.count != 0
|
||||
if TempConference.any?
|
||||
organization = TempOrganization.create(name: 'organization', description: 'Default organization')
|
||||
TempConference.all.each do |conference|
|
||||
conference.organization_id = organization.id
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace :data do
|
||||
|
||||
task demo: :environment do
|
||||
include FactoryBot::Syntax::Methods
|
||||
|
||||
conference = create(:full_conference, title: 'Open Source Event Manager Demo', short_title: 'osemdemo' ,description: "This is a [Open Source Event Manager](http://osem.io/) demo instance. You can log in as **admin** with the password **password123** or just you just [sign up](/accounts/sign_up) with your own user. We hope you enjoy checking out all the functionality, if you have questions don't hesitate to [contact us](http://osem.io/#contact)!\r\n\r\n## Data will be destroyed every thirty minutes or whenever someone updates the [OSEM source code on github](https://github.com/openSUSE/osem/commits/master).")
|
||||
conference.contact.update(email: 'osemdemo@osem.io', sponsor_email: 'osemdemo@osem.io')
|
||||
create(:admin, email: 'admin@osem.io', username: 'admin', password: 'password123', password_confirmation: 'password123')
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace :events_registrations do
|
||||
duplicates = EventsRegistration.all.map { |er| er.id if er.valid? == false}.compact
|
||||
|
||||
puts "Duplicates found: #{duplicates.count}"
|
||||
if duplicates.count > 0
|
||||
if duplicates.any?
|
||||
puts "With IDs: #{duplicates}"
|
||||
end
|
||||
|
||||
EventsRegistration.all.each do |er|
|
||||
records = EventsRegistration.where(registration_id: er.registration_id, event_id: er.event_id)
|
||||
if records.count > 1
|
||||
if records.many?
|
||||
# Iterate through duplicates (excluding 1st record)
|
||||
(1..(records.count - 1)).each do |i|
|
||||
puts "Deleting EventsRegistration record with ID #{records[i].id} ..."
|
||||
|
||||
@@ -32,7 +32,7 @@ describe Mailbot do
|
||||
end
|
||||
|
||||
describe '.registration_mail' do
|
||||
include_examples 'mailer actions' do
|
||||
it_behaves_like 'mailer actions' do
|
||||
let(:mail) { Mailbot.registration_mail(conference, user).deliver_now }
|
||||
end
|
||||
end
|
||||
@@ -44,7 +44,7 @@ describe Mailbot do
|
||||
accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
it_behaves_like 'mailer actions' do
|
||||
let(:mail) { Mailbot.acceptance_mail(event).deliver_now }
|
||||
end
|
||||
end
|
||||
@@ -56,7 +56,7 @@ describe Mailbot do
|
||||
rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
it_behaves_like 'mailer actions' do
|
||||
let(:mail) { Mailbot.rejection_mail(event).deliver_now }
|
||||
end
|
||||
end
|
||||
@@ -68,7 +68,7 @@ describe Mailbot do
|
||||
confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
it_behaves_like 'mailer actions' do
|
||||
let(:mail) { Mailbot.confirm_reminder_mail(event).deliver_now }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module LoginMacros
|
||||
include Warden::Test::Helpers
|
||||
|
||||
Warden.test_mode!
|
||||
|
||||
def sign_in(user)
|
||||
|
||||
Reference in New Issue
Block a user