Fix Rubocop issues
This commit is contained in:
parent
a4a6306198
commit
d63a22c54e
34 changed files with 151 additions and 137 deletions
|
|
@ -9,7 +9,7 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@events = Event.accessible_by(current_ability).where(program: @program,
|
@events = Event.accessible_by(current_ability).where(program: @program,
|
||||||
state: [:confirmed, :unconfirmed])
|
state: [:confirmed, :unconfirmed])
|
||||||
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
|
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
|
||||||
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
|
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
|
||||||
@events_with_requirements = @events.where.not(description: ['', nil])
|
@events_with_requirements = @events.where.not(description: ['', nil])
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,22 @@ class ApplicationController < ActionController::Base
|
||||||
check_authorization unless: :devise_controller?
|
check_authorization unless: :devise_controller?
|
||||||
skip_authorization_check if:
|
skip_authorization_check if:
|
||||||
|
|
||||||
def store_location
|
def store_location
|
||||||
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
||||||
return unless request.get?
|
return unless request.get?
|
||||||
|
|
||||||
if (request.path != '/accounts/sign_in' &&
|
if (request.path != '/accounts/sign_in' &&
|
||||||
request.path != '/accounts/sign_up' &&
|
request.path != '/accounts/sign_up' &&
|
||||||
request.path != '/accounts/password/new' &&
|
request.path != '/accounts/password/new' &&
|
||||||
request.path != '/accounts/password/edit' &&
|
request.path != '/accounts/password/edit' &&
|
||||||
request.path != '/accounts/confirmation' &&
|
request.path != '/accounts/confirmation' &&
|
||||||
request.path != '/accounts/sign_out' &&
|
request.path != '/accounts/sign_out' &&
|
||||||
request.path != '/users/ichain_registration/ichain_sign_up' &&
|
request.path != '/users/ichain_registration/ichain_sign_up' &&
|
||||||
!request.path.starts_with?(Devise.ichain_base_url) &&
|
!request.path.starts_with?(Devise.ichain_base_url) &&
|
||||||
!request.xhr?) # don't store ajax calls
|
!request.xhr?) # don't store ajax calls
|
||||||
session[:return_to] = request.fullpath
|
session[:return_to] = request.fullpath
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(_resource)
|
def after_sign_in_path_for(_resource)
|
||||||
if (can? :view, Conference) &&
|
if (can? :view, Conference) &&
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class ConferenceRegistrationsController < ApplicationController
|
||||||
end
|
end
|
||||||
elsif @conference.registration_ticket_required? && !current_user.supports?(@conference)
|
elsif @conference.registration_ticket_required? && !current_user.supports?(@conference)
|
||||||
redirect_to conference_tickets_path(@conference.short_title),
|
redirect_to conference_tickets_path(@conference.short_title),
|
||||||
error: 'You must buy a registration ticket before registering.'
|
error: 'You must buy a registration ticket before registering.'
|
||||||
else
|
else
|
||||||
flash.now[:error] = "Could not create your registration for #{@conference.title}: "\
|
flash.now[:error] = "Could not create your registration for #{@conference.title}: "\
|
||||||
"#{@registration.errors.full_messages.join('. ')}."
|
"#{@registration.errors.full_messages.join('. ')}."
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,13 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
|
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
|
||||||
:picture, :picture_cache)
|
:picture, :picture_cache)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Somewhat of a hack: users/current/edit
|
# Somewhat of a hack: users/current/edit
|
||||||
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
||||||
def load_user
|
def load_user
|
||||||
@user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id]) || current_user)
|
@user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id]) || current_user)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Naming/MemoizedInstanceVariableName
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UserDatatable < AjaxDatatablesRails::Base
|
class UserDatatable < AjaxDatatablesRails::Base
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ module ApplicationHelper
|
||||||
concurrent_events << other_event_schedule.event
|
concurrent_events << other_event_schedule.event
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
concurrent_events.sort_by { |event_schedule| event_schedule.room&.order }
|
concurrent_events.sort_by { |schedule| schedule.room&.order }
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_links(event)
|
def speaker_links(event)
|
||||||
|
|
@ -188,7 +188,7 @@ module ApplicationHelper
|
||||||
'hidden' if Date.today > conference.end_date
|
'hidden' if Date.today > conference.end_date
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO:Snap!Con: Replace this with a search for a conference logo.
|
# TODO: Snap!Con: Replace this with a search for a conference logo.
|
||||||
def nav_root_link_for(conference = nil)
|
def nav_root_link_for(conference = nil)
|
||||||
path = conference&.id.present? ? conference_path(conference) : root_path
|
path = conference&.id.present? ? conference_path(conference) : root_path
|
||||||
link_to(
|
link_to(
|
||||||
|
|
@ -201,8 +201,8 @@ module ApplicationHelper
|
||||||
|
|
||||||
def nav_link_text(conference)
|
def nav_link_text(conference)
|
||||||
conference.try(:organization).try(:name) ||
|
conference.try(:organization).try(:name) ||
|
||||||
ENV['OSEM_NAME'] ||
|
ENV['OSEM_NAME'] ||
|
||||||
'OSEM'
|
'OSEM'
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the url to be used for logo on basis of sponsorship level position
|
# returns the url to be used for logo on basis of sponsorship level position
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ module ConferenceHelper
|
||||||
|
|
||||||
def short_ticket_description(ticket)
|
def short_ticket_description(ticket)
|
||||||
return unless ticket.description
|
return unless ticket.description
|
||||||
|
|
||||||
markdown(ticket.description.split("\n").first&.strip)
|
markdown(ticket.description.split("\n").first&.strip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# TODO: Split this module into smaller modules
|
||||||
|
# rubocop:disable Metrics/ModuleLength
|
||||||
module EventsHelper
|
module EventsHelper
|
||||||
##
|
##
|
||||||
# Includes functions related to events
|
# Includes functions related to events
|
||||||
|
|
@ -164,7 +166,7 @@ module EventsHelper
|
||||||
conference_id,
|
conference_id,
|
||||||
event.id,
|
event.id,
|
||||||
event.send(attribute),
|
event.send(attribute),
|
||||||
url: admin_conference_program_event_path(
|
url: admin_conference_program_event_path(
|
||||||
conference_id,
|
conference_id,
|
||||||
event,
|
event,
|
||||||
event: { attribute => nil }
|
event: { attribute => nil }
|
||||||
|
|
@ -183,7 +185,7 @@ module EventsHelper
|
||||||
if current_user.roles.where(id: conference.roles).any?
|
if current_user.roles.where(id: conference.roles).any?
|
||||||
# Show Pre-Event links for any memeber of the conference team.
|
# Show Pre-Event links for any memeber of the conference team.
|
||||||
link_to("Join Live Event #{'(Admin link)' unless is_now}",
|
link_to("Join Live Event #{'(Admin link)' unless is_now}",
|
||||||
event.url, target: '_blank')
|
event.url, target: '_blank')
|
||||||
elsif current_user.registered_to_event?(conference)
|
elsif current_user.registered_to_event?(conference)
|
||||||
if is_now
|
if is_now
|
||||||
link_to('Join Live Event', event.url, target: '_blank')
|
link_to('Join Live Event', event.url, target: '_blank')
|
||||||
|
|
@ -193,7 +195,7 @@ module EventsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def calendar_timestamp(timestamp, timezone)
|
def calendar_timestamp(timestamp, _timezone)
|
||||||
timestamp = timestamp.in_time_zone('GMT')
|
timestamp = timestamp.in_time_zone('GMT')
|
||||||
timestamp -= timestamp.utc_offset
|
timestamp -= timestamp.utc_offset
|
||||||
timestamp.strftime('%Y%m%dT%H%M%S')
|
timestamp.strftime('%Y%m%dT%H%M%S')
|
||||||
|
|
@ -206,12 +208,12 @@ module EventsHelper
|
||||||
start_timestamp = calendar_timestamp(event_schedule.start_time, conference.timezone)
|
start_timestamp = calendar_timestamp(event_schedule.start_time, conference.timezone)
|
||||||
end_timestamp = calendar_timestamp(event_schedule.end_time, conference.timezone)
|
end_timestamp = calendar_timestamp(event_schedule.end_time, conference.timezone)
|
||||||
event_details = {
|
event_details = {
|
||||||
action: 'TEMPLATE',
|
action: 'TEMPLATE',
|
||||||
text: "#{event.title} at #{conference.title}",
|
text: "#{event.title} at #{conference.title}",
|
||||||
details: calendar_event_text(event, event_schedule, conference),
|
details: calendar_event_text(event, event_schedule, conference),
|
||||||
location: "#{event.room.name} #{event.url}",
|
location: "#{event.room.name} #{event.url}",
|
||||||
dates: "#{start_timestamp}/#{end_timestamp}",
|
dates: "#{start_timestamp}/#{end_timestamp}",
|
||||||
ctz: event_schedule.timezone
|
ctz: event_schedule.timezone
|
||||||
}
|
}
|
||||||
"#{calendar_base}?#{event_details.to_param}"
|
"#{calendar_base}?#{event_details.to_param}"
|
||||||
end
|
end
|
||||||
|
|
@ -220,13 +222,13 @@ module EventsHelper
|
||||||
|
|
||||||
def calendar_event_text(event, event_schedule, conference)
|
def calendar_event_text(event, event_schedule, conference)
|
||||||
<<~TEXT
|
<<~TEXT
|
||||||
#{conference.title} - #{event.title}
|
#{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)}
|
More Info: #{conference_program_proposal_url(conference, event)}
|
||||||
Join: #{event.url}
|
Join: #{event.url}
|
||||||
|
|
||||||
#{truncate(event.abstract, length: 200)}
|
#{truncate(event.abstract, length: 200)}
|
||||||
TEXT
|
TEXT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -256,3 +258,4 @@ module EventsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/ModuleLength
|
||||||
|
|
|
||||||
|
|
@ -184,12 +184,12 @@ module FormatHelper
|
||||||
return '' if text.nil?
|
return '' if text.nil?
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
autolink: true,
|
autolink: true,
|
||||||
space_after_headers: true,
|
space_after_headers: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
strikethrough: true,
|
strikethrough: true,
|
||||||
footnotes: true,
|
footnotes: true,
|
||||||
superscript: true
|
superscript: true
|
||||||
}
|
}
|
||||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options)
|
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options)
|
||||||
markdown.render(text).html_safe
|
markdown.render(text).html_safe
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ class Ability
|
||||||
end
|
end
|
||||||
|
|
||||||
# Abilities for signed in users
|
# Abilities for signed in users
|
||||||
|
# TODO: Refactor into multiple functions
|
||||||
|
# rubocop:disable Metrics/AbcSize
|
||||||
def signed_in(user)
|
def signed_in(user)
|
||||||
# Abilities from not_signed_in user are also inherited
|
# Abilities from not_signed_in user are also inherited
|
||||||
not_signed_in
|
not_signed_in
|
||||||
|
|
@ -140,6 +142,7 @@ class Ability
|
||||||
user == track.submitter && !(track.accepted? || track.confirmed?)
|
user == track.submitter && !(track.accepted? || track.confirmed?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/AbcSize
|
||||||
|
|
||||||
# Abilities for users with roles wandering around in non-admin views.
|
# Abilities for users with roles wandering around in non-admin views.
|
||||||
def common_abilities_for_admins(user)
|
def common_abilities_for_admins(user)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class Commercial < ApplicationRecord
|
||||||
begin
|
begin
|
||||||
resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315)
|
resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315)
|
||||||
{ html: resource.html.html_safe }
|
{ html: resource.html.html_safe }
|
||||||
rescue StandardError => exception
|
rescue StandardError
|
||||||
{ html: iframe_fallback(url) }
|
{ html: iframe_fallback(url) }
|
||||||
# { error: exception.message }
|
# { error: exception.message }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#
|
#
|
||||||
# index_conferences_on_organization_id (organization_id)
|
# index_conferences_on_organization_id (organization_id)
|
||||||
#
|
#
|
||||||
|
# rubocop:disable Metrics/ClassLength
|
||||||
class Conference < ApplicationRecord
|
class Conference < ApplicationRecord
|
||||||
include RevisionCount
|
include RevisionCount
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|
@ -86,7 +87,7 @@ class Conference < ApplicationRecord
|
||||||
has_many :highlighted_events,
|
has_many :highlighted_events,
|
||||||
-> { where(state: :confirmed, is_highlight: true) },
|
-> { where(state: :confirmed, is_highlight: true) },
|
||||||
through: :program,
|
through: :program,
|
||||||
source: :events
|
source: :events
|
||||||
has_many :event_types, through: :program
|
has_many :event_types, through: :program
|
||||||
|
|
||||||
has_many :surveys, as: :surveyable, dependent: :destroy do
|
has_many :surveys, as: :surveyable, dependent: :destroy do
|
||||||
|
|
@ -1234,3 +1235,4 @@ class Conference < ApplicationRecord
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
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?)
|
event_schedules.find_by(schedule_id: selected_schedule_id).try(:happening_now?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns true or false, if the event is already over or not
|
# Returns true or false, if the event is already over or not
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#
|
#
|
||||||
class EventUser < ApplicationRecord
|
class EventUser < ApplicationRecord
|
||||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator],
|
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator],
|
||||||
%w[Volunteer volunteer]]
|
%w[Volunteer volunteer]]
|
||||||
|
|
||||||
belongs_to :event, touch: true
|
belongs_to :event, touch: true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class Payment < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def stripe_description
|
def stripe_description
|
||||||
#"ticket purchases(#{user.username})"
|
# "ticket purchases(#{user.username})"
|
||||||
"Tickets for #{conference.title} #{user.name} #{user.email}"
|
"Tickets for #{conference.title} #{user.name} #{user.email}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class Registration < ApplicationRecord
|
||||||
|
|
||||||
def user_has_registration_ticket
|
def user_has_registration_ticket
|
||||||
return if conference.registration_ticket_required? &&
|
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')
|
errors.add(:base, 'You must purchase a registration ticket before registering')
|
||||||
if TicketPurchase.where(user: user, ticket: conference.registration_tickets).unpaid.any?
|
if TicketPurchase.where(user: user, ticket: conference.registration_tickets).unpaid.any?
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ end
|
||||||
def count_purchased_registration_tickets(conference, purchases)
|
def count_purchased_registration_tickets(conference, purchases)
|
||||||
# TODO: WHAT CAUSED THIS???
|
# TODO: WHAT CAUSED THIS???
|
||||||
return 0 unless purchases
|
return 0 unless purchases
|
||||||
|
|
||||||
conference.tickets.for_registration.inject(0) do |sum, registration_ticket|
|
conference.tickets.for_registration.inject(0) do |sum, registration_ticket|
|
||||||
sum + purchases[registration_ticket.id.to_s].to_i
|
sum + purchases[registration_ticket.id.to_s].to_i
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,8 @@ class User < ApplicationRecord
|
||||||
[:database_authenticatable, :registerable,
|
[:database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
||||||
:omniauthable,
|
:omniauthable,
|
||||||
omniauth_providers: [:suse, :google, :facebook, :github, :discourse]
|
omniauth_providers: [:suse, :google, :facebook, :github, :discourse]]
|
||||||
# omniauth_providers: [:google, :discourse]
|
# omniauth_providers: [:google, :discourse]
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
devise(*devise_modules)
|
devise(*devise_modules)
|
||||||
|
|
@ -206,6 +205,7 @@ class User < ApplicationRecord
|
||||||
# Partials should *not* directly call `gravatar_url`
|
# Partials should *not* directly call `gravatar_url`
|
||||||
def profile_picture(opts = {})
|
def profile_picture(opts = {})
|
||||||
return gravatar_url(opts) unless picture.present?
|
return gravatar_url(opts) unless picture.present?
|
||||||
|
|
||||||
size = (opts[:size] || 0).to_i
|
size = (opts[:size] || 0).to_i
|
||||||
if size < 50
|
if size < 50
|
||||||
picture.tiny.url
|
picture.tiny.url
|
||||||
|
|
@ -305,7 +305,7 @@ class User < ApplicationRecord
|
||||||
# TODO: Use a real authorization in the right place....
|
# TODO: Use a real authorization in the right place....
|
||||||
def manages_volunteers?(conference)
|
def manages_volunteers?(conference)
|
||||||
organizer_roles = get_roles['organizer']
|
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
|
end
|
||||||
|
|
||||||
def registered
|
def registered
|
||||||
|
|
@ -346,7 +346,6 @@ class User < ApplicationRecord
|
||||||
events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer')
|
events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.empty?
|
def self.empty?
|
||||||
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,11 @@ module Osem
|
||||||
|
|
||||||
config.before_configuration do
|
config.before_configuration do
|
||||||
env_file = File.join(Rails.root, 'config', 'local_env.yml')
|
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)
|
||||||
ENV[key.to_s] = value
|
YAML.safe_load(File.open(env_file)).each do |key, value|
|
||||||
end if File.exists?(env_file)
|
ENV[key.to_s] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Devise.setup do |config|
|
||||||
|
|
||||||
# TODO-SNAPCON: This ought to be configurable. Use OSEM_DISCOURSE_KEY?
|
# TODO-SNAPCON: This ought to be configurable. Use OSEM_DISCOURSE_KEY?
|
||||||
config.omniauth :discourse,
|
config.omniauth :discourse,
|
||||||
sso_url: 'https://forum.snap.berkeley.edu/session/sso_provider',
|
sso_url: 'https://forum.snap.berkeley.edu/session/sso_provider',
|
||||||
sso_secret: ENV['OSEM_DISCOURSE_SECRET']
|
sso_secret: ENV['OSEM_DISCOURSE_SECRET']
|
||||||
|
|
||||||
config.omniauth :facebook,
|
config.omniauth :facebook,
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@ end
|
||||||
lowlevel_error_handler do |ex, env|
|
lowlevel_error_handler do |ex, env|
|
||||||
Sentry.capture_exception(
|
Sentry.capture_exception(
|
||||||
ex,
|
ex,
|
||||||
:message => ex.message,
|
message: ex.message,
|
||||||
:extra => { :puma => env },
|
extra: { puma: env },
|
||||||
:transaction => "Puma"
|
transaction: "Puma"
|
||||||
)
|
)
|
||||||
# note the below is just a Rack response
|
# 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"]]
|
[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
|
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'
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
devise_for :users, controllers: { registrations: :registrations }
|
devise_for :users, controllers: { registrations: :registrations }
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class AddVisibleToTickets < ActiveRecord::Migration[5.0]
|
||||||
def up
|
def up
|
||||||
add_column :tickets, :visible, :boolean, default: true
|
add_column :tickets, :visible, :boolean, default: true
|
||||||
Ticket.reset_column_information
|
Ticket.reset_column_information
|
||||||
Ticket.update_all(visible: true) # rubocop:disable Rails/SkipsModelValidations
|
Ticket.update_all(visible: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
||||||
|
|
@ -7,51 +7,51 @@ if Rails.env.development?
|
||||||
# You can override any of these by setting an environment variable of the
|
# You can override any of these by setting an environment variable of the
|
||||||
# same name.
|
# same name.
|
||||||
Annotate.set_defaults(
|
Annotate.set_defaults(
|
||||||
'active_admin' => 'false',
|
'active_admin' => 'false',
|
||||||
'additional_file_patterns' => [],
|
'additional_file_patterns' => [],
|
||||||
'routes' => 'false',
|
'routes' => 'false',
|
||||||
'models' => 'true',
|
'models' => 'true',
|
||||||
'position_in_routes' => 'before',
|
'position_in_routes' => 'before',
|
||||||
'position_in_class' => 'before',
|
'position_in_class' => 'before',
|
||||||
'position_in_test' => 'before',
|
'position_in_test' => 'before',
|
||||||
'position_in_fixture' => 'before',
|
'position_in_fixture' => 'before',
|
||||||
'position_in_factory' => 'before',
|
'position_in_factory' => 'before',
|
||||||
'position_in_serializer' => 'before',
|
'position_in_serializer' => 'before',
|
||||||
'show_foreign_keys' => 'true',
|
'show_foreign_keys' => 'true',
|
||||||
'show_complete_foreign_keys' => 'false',
|
'show_complete_foreign_keys' => 'false',
|
||||||
'show_indexes' => 'true',
|
'show_indexes' => 'true',
|
||||||
'simple_indexes' => 'false',
|
'simple_indexes' => 'false',
|
||||||
'model_dir' => 'app/models',
|
'model_dir' => 'app/models',
|
||||||
'root_dir' => '',
|
'root_dir' => '',
|
||||||
'include_version' => 'false',
|
'include_version' => 'false',
|
||||||
'require' => '',
|
'require' => '',
|
||||||
'exclude_tests' => 'false',
|
'exclude_tests' => 'false',
|
||||||
'exclude_fixtures' => 'false',
|
'exclude_fixtures' => 'false',
|
||||||
'exclude_factories' => 'false',
|
'exclude_factories' => 'false',
|
||||||
'exclude_serializers' => 'false',
|
'exclude_serializers' => 'false',
|
||||||
'exclude_scaffolds' => 'true',
|
'exclude_scaffolds' => 'true',
|
||||||
'exclude_controllers' => 'true',
|
'exclude_controllers' => 'true',
|
||||||
'exclude_helpers' => 'true',
|
'exclude_helpers' => 'true',
|
||||||
'exclude_sti_subclasses' => 'false',
|
'exclude_sti_subclasses' => 'false',
|
||||||
'ignore_model_sub_dir' => 'false',
|
'ignore_model_sub_dir' => 'false',
|
||||||
'ignore_columns' => nil,
|
'ignore_columns' => nil,
|
||||||
'ignore_routes' => nil,
|
'ignore_routes' => nil,
|
||||||
'ignore_unknown_models' => 'false',
|
'ignore_unknown_models' => 'false',
|
||||||
'hide_limit_column_types' => 'integer,bigint,boolean',
|
'hide_limit_column_types' => 'integer,bigint,boolean',
|
||||||
'hide_default_column_types' => 'json,jsonb,hstore',
|
'hide_default_column_types' => 'json,jsonb,hstore',
|
||||||
'skip_on_db_migrate' => 'false',
|
'skip_on_db_migrate' => 'false',
|
||||||
'format_bare' => 'true',
|
'format_bare' => 'true',
|
||||||
'format_rdoc' => 'false',
|
'format_rdoc' => 'false',
|
||||||
'format_yard' => 'false',
|
'format_yard' => 'false',
|
||||||
'format_markdown' => 'false',
|
'format_markdown' => 'false',
|
||||||
'sort' => 'false',
|
'sort' => 'false',
|
||||||
'force' => 'false',
|
'force' => 'false',
|
||||||
'frozen' => 'false',
|
'frozen' => 'false',
|
||||||
'classified_sort' => 'true',
|
'classified_sort' => 'true',
|
||||||
'trace' => 'false',
|
'trace' => 'false',
|
||||||
'wrapper_open' => nil,
|
'wrapper_open' => nil,
|
||||||
'wrapper_close' => nil,
|
'wrapper_close' => nil,
|
||||||
'with_comment' => 'true'
|
'with_comment' => 'true'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,24 +13,24 @@ namespace :db do
|
||||||
end
|
end
|
||||||
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|
|
task :import, [:path] => :environment do |_t, args|
|
||||||
dump_path = args.path
|
dump_path = args.path
|
||||||
connection_config = ActiveRecord::Base.connection_config
|
connection_config = ActiveRecord::Base.connection_config
|
||||||
|
|
||||||
case connection_config[:adapter]
|
case connection_config[:adapter]
|
||||||
when "postgresql"
|
when 'postgresql'
|
||||||
system("PGPASSWORD=#{connection_config[:password]} pg_restore " \
|
system("PGPASSWORD=#{connection_config[:password]} pg_restore " \
|
||||||
"--verbose --clean --no-acl --no-owner " \
|
'--verbose --clean --no-acl --no-owner ' \
|
||||||
"--username=#{connection_config[:username]} " \
|
"--username=#{connection_config[:username]} " \
|
||||||
"-d #{connection_config[:database]} #{dump_path}")
|
"-d #{connection_config[:database]} #{dump_path}")
|
||||||
when "mysql", "mysql2"
|
when 'mysql', 'mysql2'
|
||||||
system("mysql -u #{connection_config[:username]} " \
|
system("mysql -u #{connection_config[:username]} " \
|
||||||
"-p#{connection_config[:password]} " \
|
"-p#{connection_config[:password]} " \
|
||||||
"#{connection_config[:database]} < #{dump_path}")
|
"#{connection_config[:database]} < #{dump_path}")
|
||||||
else
|
else
|
||||||
raise NotImplementedError, "An importer hasn't been implemented for: " \
|
raise NotImplementedError.new("An importer hasn't been implemented for: " \
|
||||||
"#{connection_config[:adapter]}"
|
"#{connection_config[:adapter]}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
namespace :registrations do
|
namespace :registrations do
|
||||||
desc "Create missing registrations for those how have a registration ticket."
|
desc 'Create missing registrations for those how have a registration ticket.'
|
||||||
task :create_missing, [:conference] => :environment do |t, args|
|
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)
|
conf = Conference.find_by(short_title: args.conference)
|
||||||
# Check if a user is found based on the supplied email address
|
# 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)
|
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 "Found #{unregistered.count} unregistered users for #{purchases.count} ticket purchases."
|
||||||
puts "There are currently #{conf.participants.count} registered users."
|
puts "There are currently #{conf.participants.count} registered users."
|
||||||
|
|
||||||
|
|
@ -19,17 +19,17 @@ namespace :registrations do
|
||||||
puts "Creating registration for #{tp.user.email}"
|
puts "Creating registration for #{tp.user.email}"
|
||||||
Registration.create(user: tp.user, conference: conf)
|
Registration.create(user: tp.user, conference: conf)
|
||||||
end
|
end
|
||||||
puts "Done."
|
puts 'Done.'
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Show User emails who have not paid, but did register"
|
desc 'Show User emails who have not paid, but did register'
|
||||||
task :list_unpaid, [:conference] => :environment do |t, args|
|
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)
|
conf = Conference.find_by(short_title: args.conference)
|
||||||
# Check if a user is found based on the supplied email address
|
# 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
|
registered = conf.participants
|
||||||
unpaid = registered.select do |user|
|
unpaid = registered.select do |user|
|
||||||
|
|
@ -41,6 +41,6 @@ namespace :registrations do
|
||||||
unpaid.each do |user|
|
unpaid.each do |user|
|
||||||
puts "'#{user.name}'<#{user.email}>, "
|
puts "'#{user.name}'<#{user.email}>, "
|
||||||
end
|
end
|
||||||
puts ""
|
puts ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ describe Admin::TicketsController do
|
||||||
it 'creates new ticket' do
|
it 'creates new ticket' do
|
||||||
expect do
|
expect do
|
||||||
post :create, params: {
|
post :create, params: {
|
||||||
ticket: attributes_for(:ticket),
|
ticket: attributes_for(:ticket),
|
||||||
conference_id: conference
|
conference_id: conference
|
||||||
}
|
}
|
||||||
end.to change{ conference.tickets.count }.from(ticket_count).to(ticket_count + 1)
|
end.to change{ conference.tickets.count }.from(ticket_count).to(ticket_count + 1)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ feature Commercial do
|
||||||
|
|
||||||
scenario 'does not add an invalid commercial of an event', feature: true, js: true do
|
scenario 'does not add an invalid commercial of an event', feature: true, js: true do
|
||||||
# TODO-SNAPCON
|
# TODO-SNAPCON
|
||||||
skip("Snap!Con allows all materials to be saved.")
|
skip('Snap!Con allows all materials to be saved.')
|
||||||
visit edit_conference_program_proposal_path(conference.short_title, event.id)
|
visit edit_conference_program_proposal_path(conference.short_title, event.id)
|
||||||
click_link 'Materials'
|
click_link 'Materials'
|
||||||
fill_in 'commercial_url', with: 'invalid_commercial_url'
|
fill_in 'commercial_url', with: 'invalid_commercial_url'
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ feature 'Has correct abilities' do
|
||||||
other_user = create(:user)
|
other_user = create(:user)
|
||||||
ticket = conference.registration_tickets.first
|
ticket = conference.registration_tickets.first
|
||||||
create(:paid_ticket_purchase,
|
create(:paid_ticket_purchase,
|
||||||
user: other_user, ticket: ticket, quantity: 1, conference: conference)
|
user: other_user, ticket: ticket, quantity: 1, conference: conference)
|
||||||
create(:registration, user: other_user, conference: conference)
|
create(:registration, user: other_user, conference: conference)
|
||||||
visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)
|
visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)
|
||||||
expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first))
|
expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first))
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ feature 'Has correct abilities' do
|
||||||
other_user = create(:user)
|
other_user = create(:user)
|
||||||
ticket = conference.registration_tickets.first
|
ticket = conference.registration_tickets.first
|
||||||
create(:paid_ticket_purchase,
|
create(:paid_ticket_purchase,
|
||||||
user: other_user, ticket: ticket, quantity: 1, conference: conference)
|
user: other_user, ticket: ticket, quantity: 1, conference: conference)
|
||||||
create(:registration, user: other_user, conference: conference)
|
create(:registration, user: other_user, conference: conference)
|
||||||
visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)
|
visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)
|
||||||
expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first))
|
expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first))
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ describe FormatHelper, type: :helper do
|
||||||
expect(Redcarpet::Markdown).to receive(:new)
|
expect(Redcarpet::Markdown).to receive(:new)
|
||||||
.with(
|
.with(
|
||||||
Redcarpet::Render::HTML,
|
Redcarpet::Render::HTML,
|
||||||
autolink: true,
|
autolink: true,
|
||||||
space_after_headers: true,
|
space_after_headers: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
strikethrough: true,
|
strikethrough: true,
|
||||||
footnotes: true,
|
footnotes: true,
|
||||||
superscript: true
|
superscript: true
|
||||||
)
|
)
|
||||||
.and_call_original
|
.and_call_original
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
#
|
#
|
||||||
# index_conferences_on_organization_id (organization_id)
|
# index_conferences_on_organization_id (organization_id)
|
||||||
#
|
#
|
||||||
#!/bin/env ruby
|
# !/bin/env ruby
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Conference do
|
describe Conference do
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,6 @@ def mock_commercial_request
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_image_request
|
def mock_image_request
|
||||||
WebMock.stub_request(:post, "https://api.cloudinary.com/v1_1/snapcon/image/destroy").
|
WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy')
|
||||||
to_return(status: 200, body: {}.to_json, headers: {})
|
.to_return(status: 200, body: {}.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@ module OmniauthMacros
|
||||||
ENV['OSEM_DISCOURSE_KEY'] = 'test key discourse'
|
ENV['OSEM_DISCOURSE_KEY'] = 'test key discourse'
|
||||||
ENV['OSEM_DISCOURSE_SECRET'] = 'test secret discourse'
|
ENV['OSEM_DISCOURSE_SECRET'] = 'test secret discourse'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def mock_auth_new_user
|
def mock_auth_new_user
|
||||||
OmniAuth.config.mock_auth[:google] =
|
OmniAuth.config.mock_auth[:google] =
|
||||||
OmniAuth::AuthHash.new(
|
OmniAuth::AuthHash.new(
|
||||||
|
|
@ -90,6 +88,10 @@ module OmniauthMacros
|
||||||
# account is available for every supported omniauth provider.
|
# account is available for every supported omniauth provider.
|
||||||
# These must be identical to the ones in /config/environments/development.rb
|
# These must be identical to the ones in /config/environments/development.rb
|
||||||
# Remember to keep them in sync with development.rb
|
# Remember to keep them in sync with development.rb
|
||||||
|
#
|
||||||
|
# Note that the method length check is disabled to allow for better formatting
|
||||||
|
# of the user params.
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
def mock_auth_accounts
|
def mock_auth_accounts
|
||||||
OmniAuth.config.mock_auth[:facebook] =
|
OmniAuth.config.mock_auth[:facebook] =
|
||||||
OmniAuth::AuthHash.new(
|
OmniAuth::AuthHash.new(
|
||||||
|
|
@ -166,4 +168,5 @@ module OmniauthMacros
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue