Fix Rubocop issues
This commit is contained in:
parent
a45008640f
commit
7f5d06b23c
27 changed files with 94 additions and 83 deletions
2
Gemfile
2
Gemfile
|
|
@ -116,8 +116,8 @@ end
|
|||
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
|
||||
|
||||
# data tables
|
||||
gem 'jquery-datatables'
|
||||
gem 'ajax-datatables-rails'
|
||||
gem 'jquery-datatables'
|
||||
|
||||
# for charts
|
||||
gem 'chartkick'
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
# Somewhat of a hack: users/current/edit
|
||||
# rubocop:disable Naming/MemoizedInstanceVariableName
|
||||
def load_user
|
||||
@user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id]) || current_user)
|
||||
end
|
||||
# rubocop:enable Naming/MemoizedInstanceVariableName
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserDatatable < AjaxDatatablesRails::Base
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ module ApplicationHelper
|
|||
concurrent_events << other_event_schedule.event
|
||||
end
|
||||
end
|
||||
concurrent_events.sort_by { |event_schedule| event_schedule.room&.order }
|
||||
concurrent_events.sort_by { |schedule| schedule.room&.order }
|
||||
end
|
||||
|
||||
def speaker_links(event)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ module ConferenceHelper
|
|||
|
||||
def short_ticket_description(ticket)
|
||||
return unless ticket.description
|
||||
|
||||
markdown(ticket.description.split("\n").first&.strip)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# TODO: Split this module into smaller modules
|
||||
# rubocop:disable Metrics/ModuleLength
|
||||
module EventsHelper
|
||||
##
|
||||
# Includes functions related to events
|
||||
|
|
@ -193,7 +195,7 @@ module EventsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def calendar_timestamp(timestamp, timezone)
|
||||
def calendar_timestamp(timestamp, _timezone)
|
||||
timestamp = timestamp.in_time_zone('GMT')
|
||||
timestamp -= timestamp.utc_offset
|
||||
timestamp.strftime('%Y%m%dT%H%M%S')
|
||||
|
|
@ -221,7 +223,7 @@ module EventsHelper
|
|||
def calendar_event_text(event, event_schedule, conference)
|
||||
<<~TEXT
|
||||
#{conference.title} - #{event.title}
|
||||
#{event_schedule.start_time.strftime("%Y %B %e - %H:%M")} #{event_schedule.timezone}
|
||||
#{event_schedule.start_time.strftime('%Y %B %e - %H:%M')} #{event_schedule.timezone}
|
||||
|
||||
More Info: #{conference_program_proposal_url(conference, event)}
|
||||
Join: #{event.url}
|
||||
|
|
@ -256,3 +258,4 @@ module EventsHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ModuleLength
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ class Ability
|
|||
end
|
||||
|
||||
# Abilities for signed in users
|
||||
# TODO: Refactor into multiple functions
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def signed_in(user)
|
||||
# Abilities from not_signed_in user are also inherited
|
||||
not_signed_in
|
||||
|
|
@ -140,6 +142,7 @@ class Ability
|
|||
user == track.submitter && !(track.accepted? || track.confirmed?)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
# Abilities for users with roles wandering around in non-admin views.
|
||||
def common_abilities_for_admins(user)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Commercial < ApplicationRecord
|
|||
begin
|
||||
resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315)
|
||||
{ html: resource.html.html_safe }
|
||||
rescue StandardError => exception
|
||||
rescue StandardError
|
||||
{ html: iframe_fallback(url) }
|
||||
# { error: exception.message }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# rubocop:disable Metrics/ClassLength
|
||||
class Conference < ApplicationRecord
|
||||
include RevisionCount
|
||||
require 'uri'
|
||||
|
|
@ -1199,3 +1200,4 @@ class Conference < ApplicationRecord
|
|||
]
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@ class Event < ApplicationRecord
|
|||
event_schedules.find_by(schedule_id: selected_schedule_id).try(:happening_now?)
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Returns true or false, if the event is already over or not
|
||||
#
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ end
|
|||
def count_purchased_registration_tickets(conference, purchases)
|
||||
# TODO: WHAT CAUSED THIS???
|
||||
return 0 unless purchases
|
||||
|
||||
conference.tickets.for_registration.inject(0) do |sum, registration_ticket|
|
||||
sum + purchases[registration_ticket.id.to_s].to_i
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ class User < ApplicationRecord
|
|||
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
||||
:omniauthable,
|
||||
# omniauth_providers: [:suse, :google, :facebook, :github, :discourse]
|
||||
omniauth_providers: [:google, :discourse]
|
||||
]
|
||||
omniauth_providers: [:google, :discourse]]
|
||||
end
|
||||
|
||||
devise(*devise_modules)
|
||||
|
|
@ -160,6 +159,7 @@ class User < ApplicationRecord
|
|||
# Partials should *not* directly call `gravatar_url`
|
||||
def profile_picture(opts = {})
|
||||
return gravatar_url(opts) unless picture.present?
|
||||
|
||||
size = (opts[:size] || 0).to_i
|
||||
if size < 50
|
||||
picture.tiny.url
|
||||
|
|
@ -259,7 +259,7 @@ class User < ApplicationRecord
|
|||
# TODO: Use a real authorization in the right place....
|
||||
def manages_volunteers?(conference)
|
||||
organizer_roles = get_roles['organizer']
|
||||
organizer_roles&.include?(conference.short_title) # TODO or Volunteer Coorinator.
|
||||
organizer_roles&.include?(conference.short_title) # TODO: or Volunteer Coorinator.
|
||||
end
|
||||
|
||||
def registered
|
||||
|
|
@ -300,7 +300,6 @@ class User < ApplicationRecord
|
|||
events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer')
|
||||
end
|
||||
|
||||
|
||||
def self.empty?
|
||||
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -68,9 +68,11 @@ module Osem
|
|||
|
||||
config.before_configuration do
|
||||
env_file = File.join(Rails.root, 'config', 'local_env.yml')
|
||||
YAML.load(File.open(env_file)).each do |key, value|
|
||||
if File.exist?(env_file)
|
||||
YAML.safe_load(File.open(env_file)).each do |key, value|
|
||||
ENV[key.to_s] = value
|
||||
end if File.exists?(env_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ end
|
|||
lowlevel_error_handler do |ex, env|
|
||||
Raven.capture_exception(
|
||||
ex,
|
||||
:message => ex.message,
|
||||
:extra => { :puma => env },
|
||||
:transaction => "Puma"
|
||||
message: ex.message,
|
||||
extra: { puma: env },
|
||||
transaction: "Puma"
|
||||
)
|
||||
# note the below is just a Rack response
|
||||
[500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact conference@snap.berkeley.edu\n"]]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Osem::Application.routes.draw do
|
||||
|
||||
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
|
||||
mount LetterOpenerWeb::Engine, at: '/letter_opener' if Rails.env.development?
|
||||
|
||||
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
devise_for :users, controllers: { registrations: :registrations }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class AddVisibleToTickets < ActiveRecord::Migration[5.0]
|
|||
def up
|
||||
add_column :tickets, :visible, :boolean, default: true
|
||||
Ticket.reset_column_information
|
||||
Ticket.update_all(visible: true) # rubocop:disable Rails/SkipsModelValidations
|
||||
Ticket.update_all(visible: true)
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
|||
|
|
@ -13,24 +13,24 @@ namespace :db do
|
|||
end
|
||||
end
|
||||
|
||||
desc "Import a given file into the database"
|
||||
desc 'Import a given file into the database'
|
||||
task :import, [:path] => :environment do |_t, args|
|
||||
dump_path = args.path
|
||||
connection_config = ActiveRecord::Base.connection_config
|
||||
|
||||
case connection_config[:adapter]
|
||||
when "postgresql"
|
||||
when 'postgresql'
|
||||
system("PGPASSWORD=#{connection_config[:password]} pg_restore " \
|
||||
"--verbose --clean --no-acl --no-owner " \
|
||||
'--verbose --clean --no-acl --no-owner ' \
|
||||
"--username=#{connection_config[:username]} " \
|
||||
"-d #{connection_config[:database]} #{dump_path}")
|
||||
when "mysql", "mysql2"
|
||||
when 'mysql', 'mysql2'
|
||||
system("mysql -u #{connection_config[:username]} " \
|
||||
"-p#{connection_config[:password]} " \
|
||||
"#{connection_config[:database]} < #{dump_path}")
|
||||
else
|
||||
raise NotImplementedError, "An importer hasn't been implemented for: " \
|
||||
"#{connection_config[:adapter]}"
|
||||
raise NotImplementedError.new("An importer hasn't been implemented for: " \
|
||||
"#{connection_config[:adapter]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
namespace :registrations do
|
||||
desc "Create missing registrations for those how have a registration ticket."
|
||||
task :create_missing, [:conference] => :environment do |t, args|
|
||||
desc 'Create missing registrations for those how have a registration ticket.'
|
||||
task :create_missing, [:conference] => :environment do |_t, args|
|
||||
|
||||
fail 'Please supply a conference short name.' unless args.conference
|
||||
raise 'Please supply a conference short name.' unless args.conference
|
||||
|
||||
conf = Conference.find_by(short_title: args.conference)
|
||||
# Check if a user is found based on the supplied email address
|
||||
fail "Coud not find conference #{args.conference}" unless conf
|
||||
raise "Coud not find conference #{args.conference}" unless conf
|
||||
|
||||
purchases = conf.ticket_purchases.where(ticket: conf.registration_tickets, paid: true)
|
||||
unregistered = purchases.select { |tp| !conf.user_registered?(tp.user) }
|
||||
unregistered = purchases.reject { |tp| conf.user_registered?(tp.user) }
|
||||
puts "Found #{unregistered.count} unregistered users for #{purchases.count} ticket purchases."
|
||||
puts "There are currently #{conf.participants.count} registered users."
|
||||
|
||||
|
|
@ -19,17 +19,17 @@ namespace :registrations do
|
|||
puts "Creating registration for #{tp.user.email}"
|
||||
Registration.create(user: tp.user, conference: conf)
|
||||
end
|
||||
puts "Done."
|
||||
puts 'Done.'
|
||||
end
|
||||
|
||||
desc "Show User emails who have not paid, but did register"
|
||||
task :list_unpaid, [:conference] => :environment do |t, args|
|
||||
desc 'Show User emails who have not paid, but did register'
|
||||
task :list_unpaid, [:conference] => :environment do |_t, args|
|
||||
|
||||
fail 'Please supply a conference short name.' unless args.conference
|
||||
raise 'Please supply a conference short name.' unless args.conference
|
||||
|
||||
conf = Conference.find_by(short_title: args.conference)
|
||||
# Check if a user is found based on the supplied email address
|
||||
fail "Coud not find conference #{args.conference}" unless conf
|
||||
raise "Coud not find conference #{args.conference}" unless conf
|
||||
|
||||
registered = conf.participants
|
||||
unpaid = registered.select do |user|
|
||||
|
|
@ -41,6 +41,6 @@ namespace :registrations do
|
|||
unpaid.each do |user|
|
||||
puts "'#{user.name}'<#{user.email}>, "
|
||||
end
|
||||
puts ""
|
||||
puts ''
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue