Fix Rubocop issues
This commit is contained in:
parent
a4a6306198
commit
d63a22c54e
34 changed files with 151 additions and 137 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,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
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#
|
||||
# index_conferences_on_organization_id (organization_id)
|
||||
#
|
||||
# rubocop:disable Metrics/ClassLength
|
||||
class Conference < ApplicationRecord
|
||||
include RevisionCount
|
||||
require 'uri'
|
||||
|
|
@ -86,7 +87,7 @@ class Conference < ApplicationRecord
|
|||
has_many :highlighted_events,
|
||||
-> { where(state: :confirmed, is_highlight: true) },
|
||||
through: :program,
|
||||
source: :events
|
||||
source: :events
|
||||
has_many :event_types, through: :program
|
||||
|
||||
has_many :surveys, as: :surveyable, dependent: :destroy do
|
||||
|
|
@ -1234,3 +1235,4 @@ class Conference < ApplicationRecord
|
|||
]
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
|
|
|||
|
|
@ -310,7 +310,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
|
||||
#
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#
|
||||
class EventUser < ApplicationRecord
|
||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator],
|
||||
%w[Volunteer volunteer]]
|
||||
%w[Volunteer volunteer]]
|
||||
|
||||
belongs_to :event, touch: true
|
||||
belongs_to :user
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Payment < ApplicationRecord
|
|||
end
|
||||
|
||||
def stripe_description
|
||||
#"ticket purchases(#{user.username})"
|
||||
# "ticket purchases(#{user.username})"
|
||||
"Tickets for #{conference.title} #{user.name} #{user.email}"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class Registration < ApplicationRecord
|
|||
|
||||
def user_has_registration_ticket
|
||||
return if conference.registration_ticket_required? &&
|
||||
TicketPurchase.where(user: user, ticket: conference.registration_tickets).paid.any?
|
||||
TicketPurchase.where(user: user, ticket: conference.registration_tickets).paid.any?
|
||||
|
||||
errors.add(:base, 'You must purchase a registration ticket before registering')
|
||||
if TicketPurchase.where(user: user, ticket: conference.registration_tickets).unpaid.any?
|
||||
|
|
|
|||
|
|
@ -122,6 +122,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
|
||||
|
|
|
|||
|
|
@ -101,9 +101,8 @@ class User < ApplicationRecord
|
|||
[:database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
||||
:omniauthable,
|
||||
omniauth_providers: [:suse, :google, :facebook, :github, :discourse]
|
||||
omniauth_providers: [:suse, :google, :facebook, :github, :discourse]]
|
||||
# omniauth_providers: [:google, :discourse]
|
||||
]
|
||||
end
|
||||
|
||||
devise(*devise_modules)
|
||||
|
|
@ -206,6 +205,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
|
||||
|
|
@ -305,7 +305,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
|
||||
|
|
@ -346,7 +346,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue