From 46d1b5caf5e5b67151e29f121c050270e91d847b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 10 Feb 2021 17:10:18 -0800 Subject: [PATCH 01/55] Add ability to use local environment variables via config/local_env.yml --- .gitignore | 1 + config/application.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 8331c5c8..ee9739f8 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docker-compose.override.yml .buildconfig osem_development osem_test +config/local_env.yml diff --git a/config/application.rb b/config/application.rb index e3483d4a..874f4456 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,5 +65,12 @@ module Osem config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' } config.active_job.queue_adapter = :delayed_job + + config.before_configuration do + env_file = File.join(Rails.root, 'config', 'local_env.yml') + YAML.load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end if File.exists?(env_file) + end end end From a45008640f9308303ad8c2efd63bfd905bc4c38d Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Feb 2021 16:17:13 -0800 Subject: [PATCH 02/55] Add back user/password loading --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index ecf07a0f..e8a3d502 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,8 +11,8 @@ default: &default encoding: <%= encoding %> host: <%= ENV['OSEM_DB_HOST'] || 'database' %> port: <%= ENV['OSEM_DB_PORT'] || '5432' %> - # username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> - # password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> + username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> + password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> pool: 5 timeout: 50000 From 5746ae80aa1408ce8dd7d7116ec18b641b626531 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Wed, 17 Feb 2021 12:44:25 -0800 Subject: [PATCH 03/55] gitignore for Mac --- .gitignore | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/.gitignore b/.gitignore index ee9739f8..f35f94d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,23 @@ +# Global, for Macs +*~ + +# Compiled Python files +*.pyc + +# Folder view configuration files +.DS_Store +Desktop.ini + +# Thumbnail cache files +._* +Thumbs.db + +# Files that might appear on external disks +.Spotlight-V100 +.Trashes + + +# Legacy from before Feb 2021 /db/test.sqlite3-journal config/application.rb config/config.yml @@ -41,3 +61,62 @@ docker-compose.override.yml osem_development osem_test config/local_env.yml + +# From GitHub, for Ruby +# https://github.com/github/gitignore/blob/master/Ruby.gitignore +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. +.byebug_history + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# Used by RuboCop. Remote config files pulled in from inherit_from directive. +.rubocop-https?--* From 20c6320dcd599cbf65ac7baa814e371ac0f52b7f Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 15:17:54 -0800 Subject: [PATCH 04/55] Add Badges except for Bluejay --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2fe87dcf..64243d7e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Build Status](https://travis-ci.org/openSUSE/osem.svg?branch=master)](https://travis-ci.org/openSUSE/osem) -[![Code Climate](https://codeclimate.com/github/openSUSE/osem.png)](https://codeclimate.com/github/openSUSE/osem) -[![codecov](https://codecov.io/gh/opensuse/osem/branch/master/graph/badge.svg)](https://codecov.io/gh/opensuse/osem) -[![Security Status](https://hakiri.io/github/openSUSE/osem/master.svg)](https://hakiri.io/github/openSUSE/osem/master) -[![Dependencies](https://badges.depfu.com/badges/8fcd630367d20f5b48d393774c00c5fd/overview.svg)](https://depfu.com/repos/openSUSE/osem) +[![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) +[![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) +[![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) +[![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) +[![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) Deploy From 8c1a8108c20cbe9a3f0b2ca52f8c5ce07e88748c Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:17:30 -0800 Subject: [PATCH 05/55] Create info.yml --- info.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 info.yml diff --git a/info.yml b/info.yml new file mode 100644 index 00000000..1a5487d0 --- /dev/null +++ b/info.yml @@ -0,0 +1,44 @@ +project: + name: 'snapcon' + owner: 'cs169' + teamId: '5' + identities: + pivotal: + url: 'https://www.pivotaltracker.com/n/projects/2487653' + heroku: + url: 'https://http://cs169l-sp2021-snapcon.herokuapp.com' + travis: + url: 'https://travis-ci.com/github/CactusPuppy/snapcon' + codeclimate: + url: 'https://codeclimate.com/github/CactusPuppy/snapcon' + members: + member1: + name: 'Rajavi' + surname: 'Mishra' + githubUsername: 'rajavi-mishra' + pivotalUsername: 'rajavimishra' + herokuEmail: 'rajavi.mishra@berkeley.edu' + member2: + name: 'Jimmy' + surname: 'Xu' + githubUsername: 'kingdish' + pivotalUsername: 'kingdish' + herokuEmail: 'jimmyxu1997@berkeley.edu' + member3: + name: 'Coby' + surname: 'Zhong' + githubUsername: 'CactusPuppy' + pivotalUsername: 'cobyzhong' + herokuEmail: 'coby.zhong@berkeley.edu' + member4: + name: 'Esha' + surname: 'Madhekare' + githubUsername: 'madhekare' + pivotalUsername: 'eshamadhekar' + herokuEmail: 'esha@berkeley.edu' + member5: + name: 'Ziyi' + surname: 'Lu' + githubUsername: 'lzy-106' + pivotalUsername: 'lzy_1006' + herokuEmail: 'lzy-1006@berkeley.edu' From c007bcf4c6053e8c18c97e3e2f1b22d625a37012 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:21:02 -0800 Subject: [PATCH 06/55] Update info.yml --- info.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/info.yml b/info.yml index 1a5487d0..1affa50a 100644 --- a/info.yml +++ b/info.yml @@ -13,32 +13,8 @@ project: url: 'https://codeclimate.com/github/CactusPuppy/snapcon' members: member1: - name: 'Rajavi' - surname: 'Mishra' - githubUsername: 'rajavi-mishra' - pivotalUsername: 'rajavimishra' - herokuEmail: 'rajavi.mishra@berkeley.edu' - member2: - name: 'Jimmy' - surname: 'Xu' - githubUsername: 'kingdish' - pivotalUsername: 'kingdish' - herokuEmail: 'jimmyxu1997@berkeley.edu' - member3: name: 'Coby' surname: 'Zhong' githubUsername: 'CactusPuppy' pivotalUsername: 'cobyzhong' herokuEmail: 'coby.zhong@berkeley.edu' - member4: - name: 'Esha' - surname: 'Madhekare' - githubUsername: 'madhekare' - pivotalUsername: 'eshamadhekar' - herokuEmail: 'esha@berkeley.edu' - member5: - name: 'Ziyi' - surname: 'Lu' - githubUsername: 'lzy-106' - pivotalUsername: 'lzy_1006' - herokuEmail: 'lzy-1006@berkeley.edu' From 9ed6210319ced319ba2edef61383af37f0e4cfcb Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:47:35 -0800 Subject: [PATCH 07/55] Remove double HTTP from app URL --- info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.yml b/info.yml index 1affa50a..ab0afd5e 100644 --- a/info.yml +++ b/info.yml @@ -6,7 +6,7 @@ project: pivotal: url: 'https://www.pivotaltracker.com/n/projects/2487653' heroku: - url: 'https://http://cs169l-sp2021-snapcon.herokuapp.com' + url: 'https://cs169l-sp2021-snapcon.herokuapp.com' travis: url: 'https://travis-ci.com/github/CactusPuppy/snapcon' codeclimate: From f473ca838ff2dbca71c3bd480f548f5ed99672ce Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 21:48:18 -0800 Subject: [PATCH 08/55] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64243d7e..46ea6cab 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) +[![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) Deploy From 7f5d06b23c1e45ccbf51629e1eeeef83880ded06 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Feb 2021 21:03:28 -0800 Subject: [PATCH 09/55] Fix Rubocop issues --- Gemfile | 2 +- app/controllers/admin/reports_controller.rb | 2 +- app/controllers/application_controller.rb | 30 +++++++++---------- app/controllers/users_controller.rb | 4 ++- app/datatables/user_datatable.rb | 1 - app/helpers/application_helper.rb | 8 ++--- app/helpers/conference_helper.rb | 1 + app/helpers/events_helper.rb | 29 ++++++++++-------- app/helpers/format_helper.rb | 10 +++---- app/models/ability.rb | 3 ++ app/models/commercial.rb | 2 +- app/models/conference.rb | 2 ++ app/models/event.rb | 1 - app/models/event_user.rb | 2 +- app/models/payment.rb | 2 +- app/models/ticket_purchase.rb | 1 + app/models/user.rb | 7 ++--- config/application.rb | 8 +++-- config/initializers/devise.rb | 2 +- config/puma.rb | 6 ++-- config/routes.rb | 2 +- .../20180409170433_add_visible_to_tickets.rb | 2 +- lib/tasks/db.rake | 12 ++++---- lib/tasks/registrations.rake | 22 +++++++------- .../admin/tickets_controller_spec.rb | 4 +-- spec/helpers/application_helper_spec.rb | 2 +- spec/helpers/format_helper_spec.rb | 10 +++---- 27 files changed, 94 insertions(+), 83 deletions(-) diff --git a/Gemfile b/Gemfile index b25cf8ad..4bbddc27 100644 --- a/Gemfile +++ b/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' diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 5d9eabf4..a4eb9f60 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -9,7 +9,7 @@ module Admin def index @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_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id)) @events_with_requirements = @events.where.not(description: ['', nil]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b868e83..c9f93a30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,22 +10,22 @@ class ApplicationController < ActionController::Base check_authorization unless: :devise_controller? skip_authorization_check if: - def store_location - # store last url - this is needed for post-login redirect to whatever the user last visited. - return unless request.get? + def store_location + # store last url - this is needed for post-login redirect to whatever the user last visited. + return unless request.get? - if (request.path != '/accounts/sign_in' && - request.path != '/accounts/sign_up' && - request.path != '/accounts/password/new' && - request.path != '/accounts/password/edit' && - request.path != '/accounts/confirmation' && - request.path != '/accounts/sign_out' && - request.path != '/users/ichain_registration/ichain_sign_up' && - !request.path.starts_with?(Devise.ichain_base_url) && - !request.xhr?) # don't store ajax calls - session[:return_to] = request.fullpath - end - end + if (request.path != '/accounts/sign_in' && + request.path != '/accounts/sign_up' && + request.path != '/accounts/password/new' && + request.path != '/accounts/password/edit' && + request.path != '/accounts/confirmation' && + request.path != '/accounts/sign_out' && + request.path != '/users/ichain_registration/ichain_sign_up' && + !request.path.starts_with?(Devise.ichain_base_url) && + !request.xhr?) # don't store ajax calls + session[:return_to] = request.fullpath + end + end def after_sign_in_path_for(_resource) if (can? :view, Conference) && diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e69a52aa..55af84df 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,11 +27,13 @@ class UsersController < ApplicationController def user_params params.require(:user).permit(:name, :biography, :nickname, :affiliation, - :picture, :picture_cache) + :picture, :picture_cache) 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 diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index c21aa2ff..45200ebb 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true class UserDatatable < AjaxDatatablesRails::Base diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6984f304..80ea92c0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) @@ -188,7 +188,7 @@ module ApplicationHelper 'hidden' if Date.today > conference.end_date 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) path = conference&.id.present? ? conference_path(conference) : root_path link_to( @@ -201,8 +201,8 @@ module ApplicationHelper def nav_link_text(conference) conference.try(:organization).try(:name) || - ENV['OSEM_NAME'] || - 'OSEM' + ENV['OSEM_NAME'] || + 'OSEM' end # returns the url to be used for logo on basis of sponsorship level position diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 39316f9f..85ead390 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -24,6 +24,7 @@ module ConferenceHelper def short_ticket_description(ticket) return unless ticket.description + markdown(ticket.description.split("\n").first&.strip) end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 0c135c32..eebaa4fe 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -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 @@ -164,7 +166,7 @@ module EventsHelper conference_id, event.id, event.send(attribute), - url: admin_conference_program_event_path( + url: admin_conference_program_event_path( conference_id, event, event: { attribute => nil } @@ -183,7 +185,7 @@ module EventsHelper if current_user.roles.where(id: conference.roles).any? # Show Pre-Event links for any memeber of the conference team. 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) if is_now link_to('Join Live Event', event.url, target: '_blank') @@ -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') @@ -206,12 +208,12 @@ module EventsHelper start_timestamp = calendar_timestamp(event_schedule.start_time, conference.timezone) end_timestamp = calendar_timestamp(event_schedule.end_time, conference.timezone) event_details = { - action: 'TEMPLATE', - text: "#{event.title} at #{conference.title}", - details: calendar_event_text(event, event_schedule, conference), + action: 'TEMPLATE', + text: "#{event.title} at #{conference.title}", + details: calendar_event_text(event, event_schedule, conference), location: "#{event.room.name} #{event.url}", - dates: "#{start_timestamp}/#{end_timestamp}", - ctz: event_schedule.timezone + dates: "#{start_timestamp}/#{end_timestamp}", + ctz: event_schedule.timezone } "#{calendar_base}?#{event_details.to_param}" end @@ -220,13 +222,13 @@ 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} + #{conference.title} - #{event.title} + #{event_schedule.start_time.strftime('%Y %B %e - %H:%M')} #{event_schedule.timezone} - More Info: #{conference_program_proposal_url(conference, event)} - Join: #{event.url} + More Info: #{conference_program_proposal_url(conference, event)} + Join: #{event.url} - #{truncate(event.abstract, length: 200)} + #{truncate(event.abstract, length: 200)} TEXT end @@ -256,3 +258,4 @@ module EventsHelper end end end +# rubocop:enable Metrics/ModuleLength diff --git a/app/helpers/format_helper.rb b/app/helpers/format_helper.rb index 6aa198d6..418fa93a 100644 --- a/app/helpers/format_helper.rb +++ b/app/helpers/format_helper.rb @@ -184,12 +184,12 @@ module FormatHelper return '' if text.nil? options = { - autolink: true, + autolink: true, space_after_headers: true, - tables: true, - strikethrough: true, - footnotes: true, - superscript: true + tables: true, + strikethrough: true, + footnotes: true, + superscript: true } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options) markdown.render(text).html_safe diff --git a/app/models/ability.rb b/app/models/ability.rb index 9db7bacf..ec17e14c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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) diff --git a/app/models/commercial.rb b/app/models/commercial.rb index 51f8b7f5..ee514459 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index c91939ae..73e56210 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index 2007dec6..72a1917f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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 # diff --git a/app/models/event_user.rb b/app/models/event_user.rb index f8a2b66a..44f9d78b 100644 --- a/app/models/event_user.rb +++ b/app/models/event_user.rb @@ -2,7 +2,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 diff --git a/app/models/payment.rb b/app/models/payment.rb index 870e82cc..fba15138 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -23,7 +23,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 diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 1eaa9cf5..924ee2a1 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index d7f23779..2967b542 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index 874f4456..18f917aa 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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| - ENV[key.to_s] = value - end if File.exists?(env_file) + if File.exist?(env_file) + YAML.safe_load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end + end end end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 101f0c3d..d00b17f0 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -15,7 +15,7 @@ Devise.setup do |config| scope: 'email' 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'] config.omniauth :facebook, diff --git a/config/puma.rb b/config/puma.rb index 1d43c487..400b5d03 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -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"]] diff --git a/config/routes.rb b/config/routes.rb index ef984ca9..362b762c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 } diff --git a/db/migrate/20180409170433_add_visible_to_tickets.rb b/db/migrate/20180409170433_add_visible_to_tickets.rb index 199f7a48..2286a065 100644 --- a/db/migrate/20180409170433_add_visible_to_tickets.rb +++ b/db/migrate/20180409170433_add_visible_to_tickets.rb @@ -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 diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3c9cded7..bed74e53 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -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 diff --git a/lib/tasks/registrations.rake b/lib/tasks/registrations.rake index f94bb3ae..709e13e0 100644 --- a/lib/tasks/registrations.rake +++ b/lib/tasks/registrations.rake @@ -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 diff --git a/spec/controllers/admin/tickets_controller_spec.rb b/spec/controllers/admin/tickets_controller_spec.rb index 6f09070c..d2efb9ee 100644 --- a/spec/controllers/admin/tickets_controller_spec.rb +++ b/spec/controllers/admin/tickets_controller_spec.rb @@ -69,8 +69,8 @@ describe Admin::TicketsController do it 'creates new ticket' do expect do post :create, params: { - ticket: attributes_for(:ticket), - conference_id: conference + ticket: attributes_for(:ticket), + conference_id: conference } end.to change{ conference.tickets.count }.from(ticket_count).to(ticket_count + 1) end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index edadc869..3a3c53ea 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -65,7 +65,7 @@ describe ApplicationHelper, type: :helper do describe 'navigation title link' do it 'should default to OSEM' do ENV.delete('OSEM_NAME') - # TODO:Snap!Con: expect(nav_root_link_for(nil)).to match 'OSEM' + # TODO: Snap!Con: expect(nav_root_link_for(nil)).to match 'OSEM' expect(nav_root_link_for(nil)).to match image_tag('snapcon_logo.png') end diff --git a/spec/helpers/format_helper_spec.rb b/spec/helpers/format_helper_spec.rb index 9d611ccb..cd1940e0 100644 --- a/spec/helpers/format_helper_spec.rb +++ b/spec/helpers/format_helper_spec.rb @@ -13,12 +13,12 @@ describe FormatHelper, type: :helper do expect(Redcarpet::Markdown).to receive(:new) .with( Redcarpet::Render::HTML, - autolink: true, + autolink: true, space_after_headers: true, - tables: true, - strikethrough: true, - footnotes: true, - superscript: true + tables: true, + strikethrough: true, + footnotes: true, + superscript: true ) .and_call_original From 55f56495f4f1fc1975e4e0f30e1fe6cf2cb8bf0d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 19 Feb 2021 17:01:24 +0800 Subject: [PATCH 10/55] [feat] Allow embedding user-defined logo and user-defined text in email template --- app/mailers/mailbot.rb | 160 +++++++++++++++------------ app/views/mailbot/email_template.erb | 73 ++++++++++++ config/environments/development.rb | 2 +- 3 files changed, 165 insertions(+), 70 deletions(-) create mode 100644 app/views/mailbot/email_template.erb diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 15c5846f..93eb450d 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -1,17 +1,19 @@ # frozen_string_literal: true SNAPCON_BCC_ADDRESS = 'messages@snap.berkeley.edu' +EMAIL_TEMPLATE = 'email_template' YTLF_TICKET_ID = 50 class Mailbot < ActionMailer::Base def registration_mail(conference, user) - mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.registration_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.registration_body)) + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.registration_body) + @logo = conference.picture.thumb.url + + mail(to: user.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.registration_subject, + template_name: EMAIL_TEMPLATE) end def ticket_confirmation_mail(ticket_purchase) @@ -39,108 +41,128 @@ class Mailbot < ActionMailer::Base def acceptance_mail(event) conference = event.program.conference - mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.accepted_subject, - body: conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body) + + mail(to: event.submitter.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.accepted_subject, + template_name: EMAIL_TEMPLATE) end def submitted_proposal_mail(event) conference = event.program.conference - mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.submitted_proposal_subject, - body: conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body) + + mail(to: event.submitter.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.submitted_proposal_subject, + template_name: EMAIL_TEMPLATE) end def rejection_mail(event) conference = event.program.conference - mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.rejected_subject, - body: conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body) + + mail(to: event.submitter.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.rejected_subject, + template_name: EMAIL_TEMPLATE) end def confirm_reminder_mail(event) conference = event.program.conference - mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.confirmed_without_registration_subject, - body: conference.email_settings.generate_event_mail(event, - conference.email_settings.confirmed_without_registration_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.confirmed_without_registration_body) + + mail(to: event.submitter.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.confirmed_without_registration_subject, + template_name: EMAIL_TEMPLATE) end def conference_date_update_mail(conference, user) - mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.conference_dates_updated_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.conference_dates_updated_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_dates_updated_body) + + mail(to: user.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.conference_dates_updated_subject, + template_name: EMAIL_TEMPLATE) end def conference_registration_date_update_mail(conference, user) - mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.conference_registration_dates_updated_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.conference_registration_dates_updated_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_registration_dates_updated_body) + + mail(to: user.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.conference_registration_dates_updated_subject, + template_name: EMAIL_TEMPLATE) end def conference_venue_update_mail(conference, user) - mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, - from: conference.contact.email, - subject: conference.email_settings.venue_updated_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.venue_updated_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.venue_updated_body) + + mail(to: user.email, + bcc: SNAPCON_BCC_ADDRESS, + from: conference.contact.email, + subject: conference.email_settings.venue_updated_subject, + template_name: EMAIL_TEMPLATE) end def conference_schedule_update_mail(conference, user) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.program_schedule_public_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.program_schedule_public_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.program_schedule_public_body) + + mail(to: user.email, + from: conference.contact.email, + subject: conference.email_settings.program_schedule_public_subject, + template_name: EMAIL_TEMPLATE) end def conference_cfp_update_mail(conference, user) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.cfp_dates_updated_subject, - body: conference.email_settings.generate_email_on_conf_updates(conference, - user, - conference.email_settings.cfp_dates_updated_body)) + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body) + + mail(to: user.email, + from: conference.contact.email, + subject: conference.email_settings.cfp_dates_updated_subject, + template_name: EMAIL_TEMPLATE) end def conference_booths_acceptance_mail(booth) conference = booth.conference + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body) - mail(to: booth.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.booths_acceptance_subject, - body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body)) + mail(to: booth.submitter.email, + from: conference.contact.email, + subject: conference.email_settings.booths_acceptance_subject, + template_name: EMAIL_TEMPLATE) end def conference_booths_rejection_mail(booth) conference = booth.conference + @logo = conference.picture.thumb.url + @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body) - mail(to: booth.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.booths_rejection_subject, - body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body)) + mail(to: booth.submitter.email, + from: conference.contact.email, + subject: conference.email_settings.booths_rejection_subject, + template_name: EMAIL_TEMPLATE) end def event_comment_mail(comment, user) diff --git a/app/views/mailbot/email_template.erb b/app/views/mailbot/email_template.erb new file mode 100644 index 00000000..5c64cf11 --- /dev/null +++ b/app/views/mailbot/email_template.erb @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + Email + + +
+
+ +
<%= image_tag(@logo, style: "display:block") %>
+

+
+
+
+ + <%= @email_body %> + +
+
+

+
+ + diff --git a/config/environments/development.rb b/config/environments/development.rb index c3dcac54..6f2a1042 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,7 +1,7 @@ Osem::Application.configure do # Settings specified here will take precedence over those in config/application.rb - config.action_mailer.delivery_method = :letter_opener + config.action_mailer.delivery_method = :letter_opener_web # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development From ae05f5166982c3e3614e5fd34e80bcf4ba8676a3 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 10 Feb 2021 17:10:18 -0800 Subject: [PATCH 11/55] Add ability to use local environment variables via config/local_env.yml --- .gitignore | 1 + config/application.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 8331c5c8..ee9739f8 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docker-compose.override.yml .buildconfig osem_development osem_test +config/local_env.yml diff --git a/config/application.rb b/config/application.rb index e3483d4a..874f4456 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,5 +65,12 @@ module Osem config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' } config.active_job.queue_adapter = :delayed_job + + config.before_configuration do + env_file = File.join(Rails.root, 'config', 'local_env.yml') + YAML.load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end if File.exists?(env_file) + end end end From d6da9b6380d2fe8456b884837e54df56059e9d60 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Feb 2021 16:17:13 -0800 Subject: [PATCH 12/55] Add back user/password loading --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index ecf07a0f..e8a3d502 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,8 +11,8 @@ default: &default encoding: <%= encoding %> host: <%= ENV['OSEM_DB_HOST'] || 'database' %> port: <%= ENV['OSEM_DB_PORT'] || '5432' %> - # username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> - # password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> + username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> + password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> pool: 5 timeout: 50000 From d1ebc025d34d173e8d119c06bdcf02eddae773f0 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Wed, 17 Feb 2021 12:44:25 -0800 Subject: [PATCH 13/55] gitignore for Mac --- .gitignore | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/.gitignore b/.gitignore index ee9739f8..f35f94d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,23 @@ +# Global, for Macs +*~ + +# Compiled Python files +*.pyc + +# Folder view configuration files +.DS_Store +Desktop.ini + +# Thumbnail cache files +._* +Thumbs.db + +# Files that might appear on external disks +.Spotlight-V100 +.Trashes + + +# Legacy from before Feb 2021 /db/test.sqlite3-journal config/application.rb config/config.yml @@ -41,3 +61,62 @@ docker-compose.override.yml osem_development osem_test config/local_env.yml + +# From GitHub, for Ruby +# https://github.com/github/gitignore/blob/master/Ruby.gitignore +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. +.byebug_history + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# Used by RuboCop. Remote config files pulled in from inherit_from directive. +.rubocop-https?--* From 65e2509c704e20da59c4316ba0b0ffe7e597012b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:17:30 -0800 Subject: [PATCH 14/55] Create info.yml --- info.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 info.yml diff --git a/info.yml b/info.yml new file mode 100644 index 00000000..1a5487d0 --- /dev/null +++ b/info.yml @@ -0,0 +1,44 @@ +project: + name: 'snapcon' + owner: 'cs169' + teamId: '5' + identities: + pivotal: + url: 'https://www.pivotaltracker.com/n/projects/2487653' + heroku: + url: 'https://http://cs169l-sp2021-snapcon.herokuapp.com' + travis: + url: 'https://travis-ci.com/github/CactusPuppy/snapcon' + codeclimate: + url: 'https://codeclimate.com/github/CactusPuppy/snapcon' + members: + member1: + name: 'Rajavi' + surname: 'Mishra' + githubUsername: 'rajavi-mishra' + pivotalUsername: 'rajavimishra' + herokuEmail: 'rajavi.mishra@berkeley.edu' + member2: + name: 'Jimmy' + surname: 'Xu' + githubUsername: 'kingdish' + pivotalUsername: 'kingdish' + herokuEmail: 'jimmyxu1997@berkeley.edu' + member3: + name: 'Coby' + surname: 'Zhong' + githubUsername: 'CactusPuppy' + pivotalUsername: 'cobyzhong' + herokuEmail: 'coby.zhong@berkeley.edu' + member4: + name: 'Esha' + surname: 'Madhekare' + githubUsername: 'madhekare' + pivotalUsername: 'eshamadhekar' + herokuEmail: 'esha@berkeley.edu' + member5: + name: 'Ziyi' + surname: 'Lu' + githubUsername: 'lzy-106' + pivotalUsername: 'lzy_1006' + herokuEmail: 'lzy-1006@berkeley.edu' From 424b225abd73074d2492be718bbcd3c0fa3f160f Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:21:02 -0800 Subject: [PATCH 15/55] Update info.yml --- info.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/info.yml b/info.yml index 1a5487d0..1affa50a 100644 --- a/info.yml +++ b/info.yml @@ -13,32 +13,8 @@ project: url: 'https://codeclimate.com/github/CactusPuppy/snapcon' members: member1: - name: 'Rajavi' - surname: 'Mishra' - githubUsername: 'rajavi-mishra' - pivotalUsername: 'rajavimishra' - herokuEmail: 'rajavi.mishra@berkeley.edu' - member2: - name: 'Jimmy' - surname: 'Xu' - githubUsername: 'kingdish' - pivotalUsername: 'kingdish' - herokuEmail: 'jimmyxu1997@berkeley.edu' - member3: name: 'Coby' surname: 'Zhong' githubUsername: 'CactusPuppy' pivotalUsername: 'cobyzhong' herokuEmail: 'coby.zhong@berkeley.edu' - member4: - name: 'Esha' - surname: 'Madhekare' - githubUsername: 'madhekare' - pivotalUsername: 'eshamadhekar' - herokuEmail: 'esha@berkeley.edu' - member5: - name: 'Ziyi' - surname: 'Lu' - githubUsername: 'lzy-106' - pivotalUsername: 'lzy_1006' - herokuEmail: 'lzy-1006@berkeley.edu' From 3b724c28fae5f90c9b46edd167da996ef4223aac Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 17:47:35 -0800 Subject: [PATCH 16/55] Remove double HTTP from app URL --- info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.yml b/info.yml index 1affa50a..ab0afd5e 100644 --- a/info.yml +++ b/info.yml @@ -6,7 +6,7 @@ project: pivotal: url: 'https://www.pivotaltracker.com/n/projects/2487653' heroku: - url: 'https://http://cs169l-sp2021-snapcon.herokuapp.com' + url: 'https://cs169l-sp2021-snapcon.herokuapp.com' travis: url: 'https://travis-ci.com/github/CactusPuppy/snapcon' codeclimate: From c9a6f55499b3e8c93aa7c9418989c4ccec5ac881 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 15:17:54 -0800 Subject: [PATCH 17/55] Add Badges except for Bluejay --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2fe87dcf..64243d7e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Build Status](https://travis-ci.org/openSUSE/osem.svg?branch=master)](https://travis-ci.org/openSUSE/osem) -[![Code Climate](https://codeclimate.com/github/openSUSE/osem.png)](https://codeclimate.com/github/openSUSE/osem) -[![codecov](https://codecov.io/gh/opensuse/osem/branch/master/graph/badge.svg)](https://codecov.io/gh/opensuse/osem) -[![Security Status](https://hakiri.io/github/openSUSE/osem/master.svg)](https://hakiri.io/github/openSUSE/osem/master) -[![Dependencies](https://badges.depfu.com/badges/8fcd630367d20f5b48d393774c00c5fd/overview.svg)](https://depfu.com/repos/openSUSE/osem) +[![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) +[![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) +[![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) +[![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) +[![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) Deploy From eaf4cef3c286d10c483bdd4111158b4b8fef8157 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Feb 2021 21:48:18 -0800 Subject: [PATCH 18/55] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64243d7e..46ea6cab 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) +[![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) Deploy From a932c6dd036ba4843e70639d85c43a8657789f51 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Fri, 19 Feb 2021 17:50:03 -0800 Subject: [PATCH 19/55] Pivotal badge on README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 46ea6cab..bd15cffc 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,37 @@ [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) + [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) + [![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) + [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) + [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) + [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) + Deploy + + + Pivotal Tracker + + # Open Source Event Manager - [osem.io](https://osem.io) + ![OSEM Logo](doc/osem-logo.png) An event management tool tailored to Free and Open Source Software conferences. ## Installation + Please refer to our [installation guide](INSTALL.md). ## How to contribute to OSEM + Please refer to our [contributing guide](CONTRIBUTING.md). ## Contact + GitHub issues are the primary way for communicating about specific proposed changes to this project. If you have other questions feel free to subscribe to the [opensuse-web@opensuse.org](http://lists.opensuse.org/opensuse-web/) mailinglist, all OSEM contributors are on that list! Additionally you can use #osem channel on freenode IRC. From c79aa1f8bfde178f040e93354d799e375315d4d9 Mon Sep 17 00:00:00 2001 From: Ziyi Date: Fri, 19 Feb 2021 17:50:53 -0800 Subject: [PATCH 20/55] Reformat README badges --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index bd15cffc..09356477 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) - [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) - [![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) - [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) - [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) - [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From e7eca161c7434aca0377690641f543849a741ead Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 23 Feb 2021 16:02:49 -0800 Subject: [PATCH 21/55] [fix] Email will not error out when logo is nil --- app/views/mailbot/email_template.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/mailbot/email_template.erb b/app/views/mailbot/email_template.erb index 5c64cf11..429553be 100644 --- a/app/views/mailbot/email_template.erb +++ b/app/views/mailbot/email_template.erb @@ -57,7 +57,11 @@
-
<%= image_tag(@logo, style: "display:block") %>
+
+ <% if !@logo.nil? %> + <%= image_tag(@logo, style: "display:block") %> + <% end %> +

From 57f4079d03fa9df23763150c6d61d8ecb535a53e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 23 Feb 2021 16:31:07 -0800 Subject: [PATCH 22/55] [fix] Fix mailbot rspec test --- spec/mailers/mailbot_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index 1cbdd8e7..1f739997 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -23,7 +23,7 @@ describe Mailbot do end it 'assigns the email body' do - expect(mail.body).to eq 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' + expect(mail.body).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' end it 'delivers the email' do From e127007c678652b0f8803621d12ef4cb4c8b1b79 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 23 Feb 2021 23:03:33 -0800 Subject: [PATCH 23/55] [feat] Add design elements to all provided templates --- app/views/mailbot/comment_template.text.erb | 85 +++++++++++++++++-- .../ticket_confirmation_template.text.erb | 83 ++++++++++++++++-- ...kers_ticket_confirmation_template.text.erb | 85 +++++++++++++++++-- 3 files changed, 236 insertions(+), 17 deletions(-) diff --git a/app/views/mailbot/comment_template.text.erb b/app/views/mailbot/comment_template.text.erb index 0e7a8c35..d162d710 100644 --- a/app/views/mailbot/comment_template.text.erb +++ b/app/views/mailbot/comment_template.text.erb @@ -1,10 +1,83 @@ -Dear <%= @user.name %>, + + + + + + + + + + + + + + Email + + +
+
+ +
+
+

+
+
+
+ + Dear <%= @user.name %>, + + User <%= @comment.user.name %> posted a new comment for event <%= @event.title %> of <%= @conference.short_title %> . + + "<%= @comment.body %>" + + To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %> + + Best wishes, + <%= @conference.title %> Team + +
+
+

+
+ + diff --git a/app/views/mailbot/ticket_confirmation_template.text.erb b/app/views/mailbot/ticket_confirmation_template.text.erb index 08f5175a..0e4e54f8 100644 --- a/app/views/mailbot/ticket_confirmation_template.text.erb +++ b/app/views/mailbot/ticket_confirmation_template.text.erb @@ -1,8 +1,81 @@ -Dear <%= @user.name %>, + + + + + + + + + + + + + + Email + + +
+
+ +
+
+

+
+
+
+ + Dear <%= @user.name %>, + + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + Best wishes, + <%= @conference.title %> Team + +
+
+

+
+ + diff --git a/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb b/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb index e3e52c1f..6a4c7fb5 100644 --- a/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb +++ b/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb @@ -1,10 +1,83 @@ -Dear <%= @user.name %>, + + + + + + + + + + + + + + Email + + +
+
+ +
+
+

+
+
+
+ + Dear <%= @user.name %>, + + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to youngthinkers@sap.com. + + Best wishes, + <%= @conference.title %> Team + +
+
+

+
+ + From a0532b5d9ff7bb0506c5df0a9a4b0244854b7294 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 24 Feb 2021 12:17:05 -0800 Subject: [PATCH 24/55] [feat] Add a button in admin event view that links to user event view --- app/views/admin/events/_proposal.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 722387ac..1c2254d3 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -7,6 +7,8 @@ %small = @event.subtitle .btn-group.pull-right + - if @event.public + = link_to 'Preview', conference_program_proposal_path(@conference.short_title, @event.id), class: 'btn btn-mini btn-primary' = link_to 'Registrations', registrations_admin_conference_program_event_path(@conference.short_title, @event), class: 'btn btn-success' = link_to 'Edit', edit_admin_conference_program_event_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary' From ebc2bd20ef42da83ce13c852e505904e45b63505 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 10 Feb 2021 17:10:18 -0800 Subject: [PATCH 25/55] Add ability to use local environment variables via config/local_env.yml --- .gitignore | 1 + config/application.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 8331c5c8..ee9739f8 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docker-compose.override.yml .buildconfig osem_development osem_test +config/local_env.yml diff --git a/config/application.rb b/config/application.rb index e3483d4a..874f4456 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,5 +65,12 @@ module Osem config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' } config.active_job.queue_adapter = :delayed_job + + config.before_configuration do + env_file = File.join(Rails.root, 'config', 'local_env.yml') + YAML.load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end if File.exists?(env_file) + end end end From a4a63061984d2ff1e91380d8a84649738739a343 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Feb 2021 16:17:13 -0800 Subject: [PATCH 26/55] Add back user/password loading --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index ecf07a0f..e8a3d502 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,8 +11,8 @@ default: &default encoding: <%= encoding %> host: <%= ENV['OSEM_DB_HOST'] || 'database' %> port: <%= ENV['OSEM_DB_PORT'] || '5432' %> - # username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> - # password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> + username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> + password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> pool: 5 timeout: 50000 From d63a22c54e160a3846b8a81e860eb700ac44b564 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Feb 2021 21:03:28 -0800 Subject: [PATCH 27/55] Fix Rubocop issues --- app/controllers/admin/reports_controller.rb | 2 +- app/controllers/application_controller.rb | 30 +++---- .../conference_registrations_controller.rb | 2 +- app/controllers/users_controller.rb | 4 +- app/datatables/user_datatable.rb | 1 - app/helpers/application_helper.rb | 8 +- app/helpers/conference_helper.rb | 1 + app/helpers/events_helper.rb | 29 +++--- app/helpers/format_helper.rb | 10 +-- app/models/ability.rb | 3 + app/models/commercial.rb | 2 +- app/models/conference.rb | 4 +- app/models/event.rb | 1 - app/models/event_user.rb | 2 +- app/models/payment.rb | 2 +- app/models/registration.rb | 2 +- app/models/ticket_purchase.rb | 1 + app/models/user.rb | 7 +- config/application.rb | 8 +- config/initializers/devise.rb | 2 +- config/puma.rb | 6 +- config/routes.rb | 2 +- .../20180409170433_add_visible_to_tickets.rb | 2 +- lib/tasks/auto_annotate_models.rake | 90 +++++++++---------- lib/tasks/db.rake | 12 +-- lib/tasks/registrations.rake | 22 ++--- .../admin/tickets_controller_spec.rb | 4 +- spec/features/commercials_spec.rb | 2 +- .../organization_admin_ability_spec.rb | 2 +- spec/features/organizer_ability_spec.rb | 2 +- spec/helpers/format_helper_spec.rb | 10 +-- spec/models/conference_spec.rb | 2 +- spec/support/external_request.rb | 4 +- spec/support/omniauth_macros.rb | 7 +- 34 files changed, 151 insertions(+), 137 deletions(-) diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 5d9eabf4..a4eb9f60 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -9,7 +9,7 @@ module Admin def index @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_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id)) @events_with_requirements = @events.where.not(description: ['', nil]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b868e83..c9f93a30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,22 +10,22 @@ class ApplicationController < ActionController::Base check_authorization unless: :devise_controller? skip_authorization_check if: - def store_location - # store last url - this is needed for post-login redirect to whatever the user last visited. - return unless request.get? + def store_location + # store last url - this is needed for post-login redirect to whatever the user last visited. + return unless request.get? - if (request.path != '/accounts/sign_in' && - request.path != '/accounts/sign_up' && - request.path != '/accounts/password/new' && - request.path != '/accounts/password/edit' && - request.path != '/accounts/confirmation' && - request.path != '/accounts/sign_out' && - request.path != '/users/ichain_registration/ichain_sign_up' && - !request.path.starts_with?(Devise.ichain_base_url) && - !request.xhr?) # don't store ajax calls - session[:return_to] = request.fullpath - end - end + if (request.path != '/accounts/sign_in' && + request.path != '/accounts/sign_up' && + request.path != '/accounts/password/new' && + request.path != '/accounts/password/edit' && + request.path != '/accounts/confirmation' && + request.path != '/accounts/sign_out' && + request.path != '/users/ichain_registration/ichain_sign_up' && + !request.path.starts_with?(Devise.ichain_base_url) && + !request.xhr?) # don't store ajax calls + session[:return_to] = request.fullpath + end + end def after_sign_in_path_for(_resource) if (can? :view, Conference) && diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index fd6dd14c..8d4ae8a1 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -66,7 +66,7 @@ class ConferenceRegistrationsController < ApplicationController end elsif @conference.registration_ticket_required? && !current_user.supports?(@conference) 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 flash.now[:error] = "Could not create your registration for #{@conference.title}: "\ "#{@registration.errors.full_messages.join('. ')}." diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e69a52aa..55af84df 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,11 +27,13 @@ class UsersController < ApplicationController def user_params params.require(:user).permit(:name, :biography, :nickname, :affiliation, - :picture, :picture_cache) + :picture, :picture_cache) 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 diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index c21aa2ff..45200ebb 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true class UserDatatable < AjaxDatatablesRails::Base diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 300b91c9..b3179681 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) @@ -188,7 +188,7 @@ module ApplicationHelper 'hidden' if Date.today > conference.end_date 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) path = conference&.id.present? ? conference_path(conference) : root_path link_to( @@ -201,8 +201,8 @@ module ApplicationHelper def nav_link_text(conference) conference.try(:organization).try(:name) || - ENV['OSEM_NAME'] || - 'OSEM' + ENV['OSEM_NAME'] || + 'OSEM' end # returns the url to be used for logo on basis of sponsorship level position diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 39316f9f..85ead390 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -24,6 +24,7 @@ module ConferenceHelper def short_ticket_description(ticket) return unless ticket.description + markdown(ticket.description.split("\n").first&.strip) end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 0c135c32..eebaa4fe 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -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 @@ -164,7 +166,7 @@ module EventsHelper conference_id, event.id, event.send(attribute), - url: admin_conference_program_event_path( + url: admin_conference_program_event_path( conference_id, event, event: { attribute => nil } @@ -183,7 +185,7 @@ module EventsHelper if current_user.roles.where(id: conference.roles).any? # Show Pre-Event links for any memeber of the conference team. 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) if is_now link_to('Join Live Event', event.url, target: '_blank') @@ -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') @@ -206,12 +208,12 @@ module EventsHelper start_timestamp = calendar_timestamp(event_schedule.start_time, conference.timezone) end_timestamp = calendar_timestamp(event_schedule.end_time, conference.timezone) event_details = { - action: 'TEMPLATE', - text: "#{event.title} at #{conference.title}", - details: calendar_event_text(event, event_schedule, conference), + action: 'TEMPLATE', + text: "#{event.title} at #{conference.title}", + details: calendar_event_text(event, event_schedule, conference), location: "#{event.room.name} #{event.url}", - dates: "#{start_timestamp}/#{end_timestamp}", - ctz: event_schedule.timezone + dates: "#{start_timestamp}/#{end_timestamp}", + ctz: event_schedule.timezone } "#{calendar_base}?#{event_details.to_param}" end @@ -220,13 +222,13 @@ 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} + #{conference.title} - #{event.title} + #{event_schedule.start_time.strftime('%Y %B %e - %H:%M')} #{event_schedule.timezone} - More Info: #{conference_program_proposal_url(conference, event)} - Join: #{event.url} + More Info: #{conference_program_proposal_url(conference, event)} + Join: #{event.url} - #{truncate(event.abstract, length: 200)} + #{truncate(event.abstract, length: 200)} TEXT end @@ -256,3 +258,4 @@ module EventsHelper end end end +# rubocop:enable Metrics/ModuleLength diff --git a/app/helpers/format_helper.rb b/app/helpers/format_helper.rb index 6aa198d6..418fa93a 100644 --- a/app/helpers/format_helper.rb +++ b/app/helpers/format_helper.rb @@ -184,12 +184,12 @@ module FormatHelper return '' if text.nil? options = { - autolink: true, + autolink: true, space_after_headers: true, - tables: true, - strikethrough: true, - footnotes: true, - superscript: true + tables: true, + strikethrough: true, + footnotes: true, + superscript: true } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options) markdown.render(text).html_safe diff --git a/app/models/ability.rb b/app/models/ability.rb index 9db7bacf..ec17e14c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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) diff --git a/app/models/commercial.rb b/app/models/commercial.rb index 1d39f9c5..64631052 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index 3bf67dd2..44224ab7 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index 4978fbf9..0370926b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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 # diff --git a/app/models/event_user.rb b/app/models/event_user.rb index 3bf3cb2b..e468f793 100644 --- a/app/models/event_user.rb +++ b/app/models/event_user.rb @@ -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 diff --git a/app/models/payment.rb b/app/models/payment.rb index 559faf54..480e84b2 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -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 diff --git a/app/models/registration.rb b/app/models/registration.rb index 944d0e65..3906f558 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -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? diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 6f598c8e..46a5befe 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index a63ebe18..9bd1bf80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index 874f4456..18f917aa 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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| - ENV[key.to_s] = value - end if File.exists?(env_file) + if File.exist?(env_file) + YAML.safe_load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end + end end end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 0ddb8415..26fca25b 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -16,7 +16,7 @@ Devise.setup do |config| # TODO-SNAPCON: This ought to be configurable. Use OSEM_DISCOURSE_KEY? 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'] config.omniauth :facebook, diff --git a/config/puma.rb b/config/puma.rb index ed6fe45b..c6f137da 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -46,9 +46,9 @@ end lowlevel_error_handler do |ex, env| Sentry.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"]] diff --git a/config/routes.rb b/config/routes.rb index ef984ca9..362b762c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 } diff --git a/db/migrate/20180409170433_add_visible_to_tickets.rb b/db/migrate/20180409170433_add_visible_to_tickets.rb index 199f7a48..2286a065 100644 --- a/db/migrate/20180409170433_add_visible_to_tickets.rb +++ b/db/migrate/20180409170433_add_visible_to_tickets.rb @@ -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 diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index e96283ea..3f1cf4e1 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -7,51 +7,51 @@ if Rails.env.development? # You can override any of these by setting an environment variable of the # same name. Annotate.set_defaults( - 'active_admin' => 'false', - 'additional_file_patterns' => [], - 'routes' => 'false', - 'models' => 'true', - 'position_in_routes' => 'before', - 'position_in_class' => 'before', - 'position_in_test' => 'before', - 'position_in_fixture' => 'before', - 'position_in_factory' => 'before', - 'position_in_serializer' => 'before', - 'show_foreign_keys' => 'true', - 'show_complete_foreign_keys' => 'false', - 'show_indexes' => 'true', - 'simple_indexes' => 'false', - 'model_dir' => 'app/models', - 'root_dir' => '', - 'include_version' => 'false', - 'require' => '', - 'exclude_tests' => 'false', - 'exclude_fixtures' => 'false', - 'exclude_factories' => 'false', - 'exclude_serializers' => 'false', - 'exclude_scaffolds' => 'true', - 'exclude_controllers' => 'true', - 'exclude_helpers' => 'true', - 'exclude_sti_subclasses' => 'false', - 'ignore_model_sub_dir' => 'false', - 'ignore_columns' => nil, - 'ignore_routes' => nil, - 'ignore_unknown_models' => 'false', - 'hide_limit_column_types' => 'integer,bigint,boolean', - 'hide_default_column_types' => 'json,jsonb,hstore', - 'skip_on_db_migrate' => 'false', - 'format_bare' => 'true', - 'format_rdoc' => 'false', - 'format_yard' => 'false', - 'format_markdown' => 'false', - 'sort' => 'false', - 'force' => 'false', - 'frozen' => 'false', - 'classified_sort' => 'true', - 'trace' => 'false', - 'wrapper_open' => nil, - 'wrapper_close' => nil, - 'with_comment' => 'true' + 'active_admin' => 'false', + 'additional_file_patterns' => [], + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'true', + 'show_complete_foreign_keys' => 'false', + 'show_indexes' => 'true', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'false', + 'exclude_fixtures' => 'false', + 'exclude_factories' => 'false', + 'exclude_serializers' => 'false', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'exclude_sti_subclasses' => 'false', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', + 'hide_limit_column_types' => 'integer,bigint,boolean', + 'hide_default_column_types' => 'json,jsonb,hstore', + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_yard' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'frozen' => 'false', + 'classified_sort' => 'true', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil, + 'with_comment' => 'true' ) end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3c9cded7..bed74e53 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -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 diff --git a/lib/tasks/registrations.rake b/lib/tasks/registrations.rake index f94bb3ae..709e13e0 100644 --- a/lib/tasks/registrations.rake +++ b/lib/tasks/registrations.rake @@ -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 diff --git a/spec/controllers/admin/tickets_controller_spec.rb b/spec/controllers/admin/tickets_controller_spec.rb index 6f09070c..d2efb9ee 100644 --- a/spec/controllers/admin/tickets_controller_spec.rb +++ b/spec/controllers/admin/tickets_controller_spec.rb @@ -69,8 +69,8 @@ describe Admin::TicketsController do it 'creates new ticket' do expect do post :create, params: { - ticket: attributes_for(:ticket), - conference_id: conference + ticket: attributes_for(:ticket), + conference_id: conference } end.to change{ conference.tickets.count }.from(ticket_count).to(ticket_count + 1) end diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 13c46f3b..d6fc7f38 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -69,7 +69,7 @@ feature Commercial do scenario 'does not add an invalid commercial of an event', feature: true, js: true do # 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) click_link 'Materials' fill_in 'commercial_url', with: 'invalid_commercial_url' diff --git a/spec/features/organization_admin_ability_spec.rb b/spec/features/organization_admin_ability_spec.rb index 3e36db94..c122f789 100644 --- a/spec/features/organization_admin_ability_spec.rb +++ b/spec/features/organization_admin_ability_spec.rb @@ -193,7 +193,7 @@ feature 'Has correct abilities' do other_user = create(:user) ticket = conference.registration_tickets.first 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) 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)) diff --git a/spec/features/organizer_ability_spec.rb b/spec/features/organizer_ability_spec.rb index 3ddc4203..3683a7aa 100644 --- a/spec/features/organizer_ability_spec.rb +++ b/spec/features/organizer_ability_spec.rb @@ -200,7 +200,7 @@ feature 'Has correct abilities' do other_user = create(:user) ticket = conference.registration_tickets.first 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) 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)) diff --git a/spec/helpers/format_helper_spec.rb b/spec/helpers/format_helper_spec.rb index 9d611ccb..cd1940e0 100644 --- a/spec/helpers/format_helper_spec.rb +++ b/spec/helpers/format_helper_spec.rb @@ -13,12 +13,12 @@ describe FormatHelper, type: :helper do expect(Redcarpet::Markdown).to receive(:new) .with( Redcarpet::Render::HTML, - autolink: true, + autolink: true, space_after_headers: true, - tables: true, - strikethrough: true, - footnotes: true, - superscript: true + tables: true, + strikethrough: true, + footnotes: true, + superscript: true ) .and_call_original diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 14b396e1..f73bd879 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -36,7 +36,7 @@ # # index_conferences_on_organization_id (organization_id) # -#!/bin/env ruby +# !/bin/env ruby require 'spec_helper' describe Conference do diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index 8109a624..83eb47db 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -35,6 +35,6 @@ def mock_commercial_request end def mock_image_request - WebMock.stub_request(:post, "https://api.cloudinary.com/v1_1/snapcon/image/destroy"). - to_return(status: 200, body: {}.to_json, headers: {}) + WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy') + .to_return(status: 200, body: {}.to_json, headers: {}) end diff --git a/spec/support/omniauth_macros.rb b/spec/support/omniauth_macros.rb index 11077f34..2696f005 100644 --- a/spec/support/omniauth_macros.rb +++ b/spec/support/omniauth_macros.rb @@ -15,8 +15,6 @@ module OmniauthMacros ENV['OSEM_DISCOURSE_KEY'] = 'test key discourse' ENV['OSEM_DISCOURSE_SECRET'] = 'test secret discourse' - - def mock_auth_new_user OmniAuth.config.mock_auth[:google] = OmniAuth::AuthHash.new( @@ -90,6 +88,10 @@ module OmniauthMacros # account is available for every supported omniauth provider. # These must be identical to the ones in /config/environments/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 OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new( @@ -166,4 +168,5 @@ module OmniauthMacros } ) end + # rubocop:enable Metrics/MethodLength end From a5e1cf17c539b751417c605c985d0f5871a734ad Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 10 Feb 2021 17:10:18 -0800 Subject: [PATCH 28/55] Add ability to use local environment variables via config/local_env.yml --- .gitignore | 1 + config/application.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 8331c5c8..ee9739f8 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docker-compose.override.yml .buildconfig osem_development osem_test +config/local_env.yml diff --git a/config/application.rb b/config/application.rb index e3483d4a..874f4456 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,5 +65,12 @@ module Osem config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' } config.active_job.queue_adapter = :delayed_job + + config.before_configuration do + env_file = File.join(Rails.root, 'config', 'local_env.yml') + YAML.load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end if File.exists?(env_file) + end end end From f67c4aafe0c7d956bf27b6e8710bc81d985359db Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Feb 2021 16:17:13 -0800 Subject: [PATCH 29/55] Add back user/password loading --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index ecf07a0f..e8a3d502 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,8 +11,8 @@ default: &default encoding: <%= encoding %> host: <%= ENV['OSEM_DB_HOST'] || 'database' %> port: <%= ENV['OSEM_DB_PORT'] || '5432' %> - # username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> - # password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> + username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> + password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> pool: 5 timeout: 50000 From 21e282679fa53c5868bcb45966c6aa20d7a5bc53 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Feb 2021 21:03:28 -0800 Subject: [PATCH 30/55] Fix Rubocop issues --- app/controllers/application_controller.rb | 2 +- app/controllers/users_controller.rb | 2 ++ app/helpers/application_helper.rb | 2 +- app/helpers/events_helper.rb | 7 ++++-- app/models/ability.rb | 3 +++ app/models/commercial.rb | 2 +- app/models/conference.rb | 2 ++ app/models/user.rb | 2 +- config/application.rb | 8 ++++--- config/puma.rb | 6 ++--- config/routes.rb | 2 +- .../20180409170433_add_visible_to_tickets.rb | 2 +- lib/tasks/db.rake | 12 +++++----- lib/tasks/registrations.rake | 22 +++++++++---------- spec/features/commercials_spec.rb | 2 +- spec/support/external_request.rb | 2 +- spec/support/omniauth_macros.rb | 5 +++++ 17 files changed, 50 insertions(+), 33 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0a4eca46..c9f93a30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base !request.xhr?) # don't store ajax calls session[:return_to] = request.fullpath end - end + end def after_sign_in_path_for(_resource) if (can? :view, Conference) && diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0bf44f49..55af84df 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 90b3fa2b..1c7f5da6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index c920c16f..eebaa4fe 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -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 diff --git a/app/models/ability.rb b/app/models/ability.rb index 9db7bacf..ec17e14c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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) diff --git a/app/models/commercial.rb b/app/models/commercial.rb index 1d39f9c5..64631052 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index 3e197280..44224ab7 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -35,6 +35,7 @@ # # index_conferences_on_organization_id (organization_id) # +# rubocop:disable Metrics/ClassLength class Conference < ApplicationRecord include RevisionCount require 'uri' @@ -1234,3 +1235,4 @@ class Conference < ApplicationRecord ] end end +# rubocop:enable Metrics/ClassLength diff --git a/app/models/user.rb b/app/models/user.rb index 147c2fe6..9bd1bf80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index 874f4456..18f917aa 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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| - ENV[key.to_s] = value - end if File.exists?(env_file) + if File.exist?(env_file) + YAML.safe_load(File.open(env_file)).each do |key, value| + ENV[key.to_s] = value + end + end end end end diff --git a/config/puma.rb b/config/puma.rb index 0d3b583f..c6f137da 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -46,9 +46,9 @@ end lowlevel_error_handler do |ex, env| Sentry.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"]] diff --git a/config/routes.rb b/config/routes.rb index ef984ca9..362b762c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 } diff --git a/db/migrate/20180409170433_add_visible_to_tickets.rb b/db/migrate/20180409170433_add_visible_to_tickets.rb index 199f7a48..2286a065 100644 --- a/db/migrate/20180409170433_add_visible_to_tickets.rb +++ b/db/migrate/20180409170433_add_visible_to_tickets.rb @@ -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 diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3c9cded7..bed74e53 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -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 diff --git a/lib/tasks/registrations.rake b/lib/tasks/registrations.rake index f94bb3ae..709e13e0 100644 --- a/lib/tasks/registrations.rake +++ b/lib/tasks/registrations.rake @@ -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 diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 13c46f3b..d6fc7f38 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -69,7 +69,7 @@ feature Commercial do scenario 'does not add an invalid commercial of an event', feature: true, js: true do # 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) click_link 'Materials' fill_in 'commercial_url', with: 'invalid_commercial_url' diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index b9a61e85..83eb47db 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -35,6 +35,6 @@ def mock_commercial_request end 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: {}) end diff --git a/spec/support/omniauth_macros.rb b/spec/support/omniauth_macros.rb index 25c6f039..2696f005 100644 --- a/spec/support/omniauth_macros.rb +++ b/spec/support/omniauth_macros.rb @@ -88,6 +88,10 @@ module OmniauthMacros # account is available for every supported omniauth provider. # These must be identical to the ones in /config/environments/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 OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new( @@ -164,4 +168,5 @@ module OmniauthMacros } ) end + # rubocop:enable Metrics/MethodLength end From 82a08ffa742b2469205428acd725908c35d96885 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 24 Feb 2021 20:28:13 -0800 Subject: [PATCH 31/55] Fix typo --- spec/helpers/application_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 7e209774..10aced29 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -91,7 +91,7 @@ describe ApplicationHelper, type: :helper do end it 'should use the conference organization name' do - expect(nav_link_text(nil)).to match conference.organization.name) + expect(nav_link_text(nil)).to match conference.organization.name end end end From 0d4823db38c763bb908dd33d13b421b605499b5f Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 24 Feb 2021 20:36:49 -0800 Subject: [PATCH 32/55] Prevent contributors from accidentally committing their local_env.yml files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ee9739f8..b9c48111 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /db/test.sqlite3-journal config/application.rb config/config.yml +config/local_env.yml config/secrets.yml /vendor/cache /vendor/cache-old From 38c10d326dcce4f8ea6e50aa859a0ac1d3f68ab3 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 24 Feb 2021 20:55:30 -0800 Subject: [PATCH 33/55] Fix spec incorrectly testing for conference org names --- spec/helpers/application_helper_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 10aced29..b54a0bd2 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -75,7 +75,7 @@ describe ApplicationHelper, type: :helper do # TODO-SNAPCON: This is an indicator in a conference it should be the conference name. it 'should use the conference organization name' do - expect(nav_root_link_for(nil)).to include image_tag('snapcon_logo.png', alt: conference.organization.name) + expect(nav_root_link_for(conference)).to include image_tag('snapcon_logo.png', alt: conference.organization.name) end end @@ -91,7 +91,7 @@ describe ApplicationHelper, type: :helper do end it 'should use the conference organization name' do - expect(nav_link_text(nil)).to match conference.organization.name + expect(nav_link_text(conference)).to match conference.organization.name end end end From 50675c8dbef16246eaaeaeb29ca4faf10ffa3727 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 24 Feb 2021 20:55:59 -0800 Subject: [PATCH 34/55] Fix a minor typo with spec description --- spec/helpers/application_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index b54a0bd2..4864a21b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -79,7 +79,7 @@ describe ApplicationHelper, type: :helper do end end - describe 'navigation link titke text' do + describe 'navigation link title text' do it 'should default to OSEM' do ENV.delete('OSEM_NAME') expect(nav_link_text(nil)).to match 'OSEM' From 9abaf38e5a3c47551a1718645e8ec0d7f2008da3 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 24 Feb 2021 20:53:28 -0800 Subject: [PATCH 35/55] Delint from a local pronto run --- spec/support/external_request.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index 83eb47db..c968acd3 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -35,6 +35,7 @@ def mock_commercial_request end def mock_image_request + # TODO-SNAPCON: This needs to be configurable somehow. WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy') .to_return(status: 200, body: {}.to_json, headers: {}) end From ad514b8908b719aecc4a32089219287a11d1ae0c Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 24 Feb 2021 20:55:59 -0800 Subject: [PATCH 36/55] Add a flay ignore file --- .flayignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .flayignore diff --git a/.flayignore b/.flayignore new file mode 100644 index 00000000..cbee825d --- /dev/null +++ b/.flayignore @@ -0,0 +1 @@ +spec/**/*.rb From 4ee70899f5783f61714779f41aae88287955efb3 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 24 Feb 2021 22:17:47 -0800 Subject: [PATCH 37/55] [fix] Fix style --- app/mailers/mailbot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 93eb450d..c055ec84 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -136,7 +136,7 @@ class Mailbot < ActionMailer::Base def conference_cfp_update_mail(conference, user) @logo = conference.picture.thumb.url @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body) - + mail(to: user.email, from: conference.contact.email, subject: conference.email_settings.cfp_dates_updated_subject, From 46fa17b55c6c755fcb21b0fb3f38e5b3550cc745 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:44:15 -0800 Subject: [PATCH 38/55] submission_text field migration --- db/migrate/20210215213515_add_submission_text_to_events.rb | 5 +++++ db/schema.rb | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20210215213515_add_submission_text_to_events.rb diff --git a/db/migrate/20210215213515_add_submission_text_to_events.rb b/db/migrate/20210215213515_add_submission_text_to_events.rb new file mode 100644 index 00000000..90270eb3 --- /dev/null +++ b/db/migrate/20210215213515_add_submission_text_to_events.rb @@ -0,0 +1,5 @@ +class AddSubmissionTextToEvents < ActiveRecord::Migration[5.2] + def change + add_column :events, :submission_text, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index e8ac08e8..dee892f6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_07_16_181602) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" +ActiveRecord::Schema.define(version: 2021_02_15_213515) do create_table "answers", force: :cascade do |t| t.string "title" @@ -257,6 +254,7 @@ ActiveRecord::Schema.define(version: 2020_07_16_181602) do t.integer "program_id" t.integer "max_attendees" t.integer "comments_count", default: 0, null: false + t.text "submission_text" end create_table "events_registrations", force: :cascade do |t| From baf488ad8adcd50199d3ab329fa120fe6b0082f4 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:45:38 -0800 Subject: [PATCH 39/55] sumbission text views --- app/views/admin/events/_proposal.html.haml | 4 ++++ app/views/proposals/_proposal_form.html.haml | 14 ++++++++++++++ app/views/proposals/new.html.haml | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 722387ac..3442bc80 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -111,6 +111,10 @@ %td %b Abstract %td= markdown(@event.abstract) + %tr + %td + %b Submission Description + %td= markdown(@event.submission_text) %tr %td %b Requirements diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index f385bdeb..e175df54 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -46,6 +46,20 @@ 250 words. + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, + hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') + + %p + You have used + %span#abstract-count #{@event.submission_word_count} + words. Submission descriptions must be between + %span#abstract-minimum-word-count + 0 + and + %span#abstract-maximum-word-count + 250 + words. + - if current_user.is_admin? or @program.cfp.enable_registrations? = f.inputs 'Enable pre-registration' do = f.input :require_registration, label: 'Require participants to register to your event' diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index b7fc22f5..eed58560 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -61,6 +61,22 @@ 250 words. + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, + hint: markdown_hint + + %p + You have used + %span#abstract-count #{@event.submission_word_count} + words. Submission descriptions must be between + %span#abstract-minimum-word-count + 0 + and + %span#abstract-maximum-word-count + 250 + words. + + + - if @program.cfp.enable_registrations? = f.input :require_registration, label: 'Require participants to register to your event' From b8f531783b2907073861e6b69b388c9ae8ae3f57 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:46:54 -0800 Subject: [PATCH 40/55] submission text control/model modifications --- app/controllers/admin/events_controller.rb | 2 +- app/controllers/proposals_controller.rb | 2 +- app/models/event.rb | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index b24882f3..f5e68165 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -175,7 +175,7 @@ module Admin def event_params params.require(:event).permit( # Set also in proposals controller - :title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id, + :title, :subtitle, :event_type_id, :abstract, :submission_text, :description, :require_registration, :difficulty_level_id, # Set only in admin/events controller :track_id, :state, :language, :is_highlight, :max_attendees, # Not used anymore? diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index adfdbea0..bf1b3adc 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -170,7 +170,7 @@ class ProposalsController < ApplicationController def event_params params.require(:event).permit(:event_type_id, :track_id, :difficulty_level_id, - :title, :subtitle, :abstract, :description, + :title, :subtitle, :abstract, :submission_text, :description, :require_registration, :max_attendees, :language, speaker_ids: [], volunteer_ids: [] ) diff --git a/app/models/event.rb b/app/models/event.rb index 0370926b..dd86efec 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -73,6 +73,7 @@ class Event < ApplicationRecord before_create :generate_guid validate :abstract_limit + validate :submission_limit validate :before_end_of_conference, on: :create validates :title, presence: true validates :abstract, presence: true @@ -217,6 +218,10 @@ class Event < ApplicationRecord abstract.to_s.split.size end + def submission_word_count + submission_text.to_s.split.size + end + def self.get_state_color(state) COLORS[state.to_sym] || '#00FFFF' # azure end @@ -353,6 +358,18 @@ class Event < ApplicationRecord errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words end + def submission_limit + # If we don't have an event type, there is no need to count anything + return unless event_type && submission_text + + len = submission_text.split.size + max_words = event_type.maximum_abstract_length + min_words = event_type.minimum_abstract_length + + errors.add(:submission_text, "cannot have less than #{min_words} words") if len < min_words + errors.add(:submission_text, "cannot have more than #{max_words} words") if len > max_words + end + # TODO: create a module to be mixed into model to perform same operation # venue.rb has same functionality which can be shared # TODO: rename guid to UUID as guid is specifically Microsoft term From 16d9dfef4c61599c35df713c6dfa749ed58659fd Mon Sep 17 00:00:00 2001 From: madhekare Date: Wed, 17 Feb 2021 17:27:41 -0800 Subject: [PATCH 41/55] submission_text rspec --- spec/features/proposals_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 4d25e9ce..7df6b7d7 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -82,6 +82,7 @@ feature Event do fill_in 'event_title', with: 'Example Proposal' select('Example Event Type', from: 'event[event_type_id]') fill_in 'event_abstract', with: 'Lorem ipsum abstract' + fill_in 'event_submission_text', with: 'Lorem ipsum submission' click_button 'Submit Proposal' page.find('#flash') @@ -123,6 +124,9 @@ feature Event do fill_in 'event_abstract', with: 'Lorem ipsum abstract' expect(page).to have_text('You have used 3 words') + fill_in 'event_submission_text', with: 'Lorem ipsum submission_text' + expect(page).to have_text('Submission description') + click_link 'Do you require something special?' fill_in 'event_description', with: 'Lorem ipsum description' From d46e1e73978458f8ec9ae94e0412c7c58a5e7480 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Feb 2021 23:27:20 -0800 Subject: [PATCH 42/55] Add JavaScript to make placeholder text update along with word count --- app/assets/javascripts/osem.js | 15 ++++++++++++++- app/views/proposals/_proposal_form.html.haml | 14 ++++++++------ app/views/proposals/new.html.haml | 6 +++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index dcab692c..0839f13b 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -149,15 +149,21 @@ function word_count(text, divId, maxcount) { /* Wait for the DOM to be ready before attaching events to the elements */ $( document ).ready(function() { - /* Set the minimum and maximum proposal abstract word length */ + /* Set the minimum and maximum proposal abstract and submission text word length */ $("#event_event_type_id").change(function () { var $selected = $("#event_event_type_id option:selected") var max = $selected.data("max-words"); var min = $selected.data("min-words"); $("#abstract-maximum-word-count").text(max); + $("#submission-maximum-word-count").text(max); $("#abstract-minimum-word-count").text(min); + $("#submission-minimum-word-count").text(min); word_count($('#event_abstract').get(0), 'abstract-count', max); + word_count($('#event_submission_text').get(0), 'submission-count', max); + + // Set the placeholder text for the abstract + $('#event_submission_text').attr("placeholder", $selected.data("help")); }) .trigger('change'); @@ -167,6 +173,13 @@ $( document ).ready(function() { var max = $selected.data("max-words"); word_count(this, 'abstract-count', max); } ); + + /* Count the submission text length */ + $("#event_submission_text").bind('change keyup paste input', function() { + var $selected = $("event_event_type_id option:selected") + var max = $selected.data("max-words"); + word_count(this, 'submission-count', max); + }); }); /* Commodity function for modal windows */ diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index e175df54..5b4e7079 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -13,7 +13,7 @@ = f.input :event_type_id, as: :select, collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, - data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, + data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - if @program.languages.present? @@ -46,17 +46,19 @@ 250 words. - = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, - hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') + %br + + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' }, + hint: markdown_hint('Only conference organizers will read this.') %p You have used - %span#abstract-count #{@event.submission_word_count} + %span#submission-count #{@event.submission_word_count} words. Submission descriptions must be between - %span#abstract-minimum-word-count + %span#submission-minimum-word-count 0 and - %span#abstract-maximum-word-count + %span#submission-maximum-word-count 250 words. diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index eed58560..bdd16e11 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -66,12 +66,12 @@ %p You have used - %span#abstract-count #{@event.submission_word_count} + %span#submission-count #{@event.submission_word_count} words. Submission descriptions must be between - %span#abstract-minimum-word-count + %span#submission-minimum-word-count 0 and - %span#abstract-maximum-word-count + %span#submission-maximum-word-count 250 words. From 1a03b3e8cc0f4da446c60d723793359d4bb24667 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Thu, 25 Feb 2021 08:13:40 +0000 Subject: [PATCH 43/55] Update carrierwave to version 2.2.0 --- Gemfile.lock | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 241cbb00..ba1be7eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,10 +104,13 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) - carrierwave (1.3.2) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) + carrierwave (2.2.0) + activemodel (>= 5.0.0) + activesupport (>= 5.0.0) + addressable (~> 2.6) + image_processing (~> 1.1) + mimemagic (>= 0.3.0) + mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) carrierwave-bombshelter (0.2.2) activesupport (>= 3.2.0) @@ -252,6 +255,9 @@ GEM i18n (1.8.9) concurrent-ruby (~> 1.0) i18n_data (0.8.0) + image_processing (1.12.1) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) inversion (1.1.1) loggability (~> 0.12) io-like (0.3.0) @@ -295,7 +301,7 @@ GEM method_source (0.8.2) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.1104) + mime-types-data (3.2021.0212) mimemagic (0.3.5) mina (1.2.3) open4 (~> 1.3.4) @@ -303,7 +309,7 @@ GEM mini_magick (4.9.5) mini_mime (1.0.2) mini_portile2 (2.5.0) - minitest (5.14.3) + minitest (5.14.4) momentjs-rails (2.20.1) railties (>= 3.1) monetize (1.9.2) @@ -540,6 +546,8 @@ GEM ruby-openid (2.9.2) ruby-progressbar (1.10.1) ruby-rc4 (0.1.5) + ruby-vips (2.0.17) + ffi (~> 1.9) ruby2_keywords (0.0.4) ruby_dep (1.5.0) ruby_parser (3.11.0) From 05f877cfe5564f421686b69653eb2a73ba43e3c1 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 25 Feb 2021 11:15:23 -0800 Subject: [PATCH 44/55] [test] Add tests for previewing proposal in admin page --- spec/features/proposals_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 4d25e9ce..6839f8dd 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -27,6 +27,21 @@ feature Event do sign_in organizer end + scenario 'can preview a proposal if it is public', feature: true, js: true do + visit admin_conference_program_event_path(conference.short_title, @event) + expect(page).to have_selector(:link_or_button, 'Preview') + click_link 'Preview' + expect(current_path).to eq(conference_program_proposal_path(conference.short_title, @event.id)) + end + + scenario 'cannot preview a proposal if it is not public', feature: true, js: true do + event = create(:event, program: conference.program, title: 'Example Proposal') + event.public = false + event.save! + visit admin_conference_program_event_path(conference.short_title, event) + expect(page).to_not have_selector(:link_or_button, 'Preview') + end + scenario 'rejects a proposal', feature: true, js: true do visit admin_conference_program_events_path(conference.short_title) expect(page).to have_content 'Example Proposal' From 42d43319c56225971e7d4daba3155f8a2c45062e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 25 Feb 2021 20:12:20 -0800 Subject: [PATCH 45/55] fix indentation error --- app/models/event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/event.rb b/app/models/event.rb index dd86efec..4fd3cbcf 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -358,7 +358,7 @@ class Event < ApplicationRecord errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words end - def submission_limit + def submission_limit # If we don't have an event type, there is no need to count anything return unless event_type && submission_text From 974d12db30d70159d44aec7462f6575f04cde976 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 25 Feb 2021 20:30:27 -0800 Subject: [PATCH 46/55] Fix some rubocop complaints --- db/migrate/20210215213515_add_submission_text_to_events.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20210215213515_add_submission_text_to_events.rb b/db/migrate/20210215213515_add_submission_text_to_events.rb index 90270eb3..cf935e18 100644 --- a/db/migrate/20210215213515_add_submission_text_to_events.rb +++ b/db/migrate/20210215213515_add_submission_text_to_events.rb @@ -1,5 +1,5 @@ class AddSubmissionTextToEvents < ActiveRecord::Migration[5.2] def change - add_column :events, :submission_text, :text + add_column :events, :submission_text, :text end end From b94894fe87ad3f02aa42cbfffea752140de61612 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 26 Feb 2021 11:04:20 -0800 Subject: [PATCH 47/55] Update annotate_models --- app/models/event.rb | 1 + app/serializers/event_serializer.rb | 1 + spec/factories/events.rb | 1 + spec/models/event_spec.rb | 1 + spec/serializers/event_serializer_spec.rb | 1 + 5 files changed, 5 insertions(+) diff --git a/app/models/event.rb b/app/models/event.rb index 4fd3cbcf..6e5cda1b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -18,6 +18,7 @@ # require_registration :boolean # start_time :datetime # state :string default("new"), not null +# submission_text :text # subtitle :string # title :string not null # week :integer diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb index 4e81ef3b..8c30b1a1 100644 --- a/app/serializers/event_serializer.rb +++ b/app/serializers/event_serializer.rb @@ -18,6 +18,7 @@ # require_registration :boolean # start_time :datetime # state :string default("new"), not null +# submission_text :text # subtitle :string # title :string not null # week :integer diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 18d40a3b..c8360449 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -18,6 +18,7 @@ # require_registration :boolean # start_time :datetime # state :string default("new"), not null +# submission_text :text # subtitle :string # title :string not null # week :integer diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index c2dca815..305275d6 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -18,6 +18,7 @@ # require_registration :boolean # start_time :datetime # state :string default("new"), not null +# submission_text :text # subtitle :string # title :string not null # week :integer diff --git a/spec/serializers/event_serializer_spec.rb b/spec/serializers/event_serializer_spec.rb index b365a310..506134cf 100644 --- a/spec/serializers/event_serializer_spec.rb +++ b/spec/serializers/event_serializer_spec.rb @@ -18,6 +18,7 @@ # require_registration :boolean # start_time :datetime # state :string default("new"), not null +# submission_text :text # subtitle :string # title :string not null # week :integer From 0aa33c497c25a099cb6c84ce6a42e15dd69d4434 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 11:25:37 -0800 Subject: [PATCH 48/55] Ensure that user is actually guest when testing --- spec/features/base_controller_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/base_controller_spec.rb b/spec/features/base_controller_spec.rb index 57d5be94..6bfd0622 100644 --- a/spec/features/base_controller_spec.rb +++ b/spec/features/base_controller_spec.rb @@ -13,6 +13,10 @@ feature 'BaseController' do describe 'GET #verify_user_admin' do context 'when user is a guest' do + before(:each) do + sign_out + end + it 'redirects to sign in page' do visit admin_conferences_path expect(current_path).to eq new_user_session_path From f207d070ac669bbb1ab62700bb96ce4b280875f8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 11:29:27 -0800 Subject: [PATCH 49/55] Add spec for submission limits --- spec/models/event_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 305275d6..14e0b044 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -110,6 +110,35 @@ describe Event do end end + describe '#submission_limit' do + before :each do + event.event_type.maximum_abstract_length = 3 + event.event_type.minimum_abstract_length = 2 + end + + context 'is invalid' do + it 'when submission text is too long' do + event.submission_text = 'four too many words' + expect(event.valid?).to eq false + expect(event.errors[:submission_text]).to eq ['cannot have more than 3 words'] + end + + it 'when submission text is too short' do + event.submission_text = 'word' + expect(event.valid?).to eq false + expect(event.errors[:submission_text]).to eq ['cannot have less than 2 words'] + end + end + + context 'is valid' do + it 'when submission text is within limts' do + event.abstract = 'the magic three' + expect(event.valid?).to eq true + expect(event.errors.size).to eq 0 + end + end + end + describe '#before_end_of_conference' do context 'is invalid' do it 'when event is created after the conference end_date, and returns an error message' do From 16f5ed6138175177aa6bb6d642802dba4a2e6bc6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 22:54:35 -0800 Subject: [PATCH 50/55] Refactor calculation of submission limit and abstract limit into helper function --- app/models/event.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 6e5cda1b..7c00b4d3 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -347,28 +347,28 @@ class Event < ApplicationRecord errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size) end - def abstract_limit - # If we don't have an event type, there is no need to count anything - return unless event_type && abstract + def word_limit(field) + # If we don't have an event type or the requested field, don't count + return unless event_type && self.respond_to?(field) && self[field] - len = abstract.split.size + len = self[field].split.size + # TODO: Use different limits for different text fields + # Uncomment the two lines below this when the separate word limits are implemented. + # max_words = event_type["maximum_#{field}_length"] + # min_words = event_type["minimum_#{field}_length"] max_words = event_type.maximum_abstract_length min_words = event_type.minimum_abstract_length - errors.add(:abstract, "cannot have less than #{min_words} words") if len < min_words - errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words + errors.add(field.to_sym, "cannot have less than #{min_words} words") if len < min_words + errors.add(field.to_sym, "cannot have more than #{max_words} words") if len > max_words + end + + def abstract_limit + word_limit(:abstract) end def submission_limit - # If we don't have an event type, there is no need to count anything - return unless event_type && submission_text - - len = submission_text.split.size - max_words = event_type.maximum_abstract_length - min_words = event_type.minimum_abstract_length - - errors.add(:submission_text, "cannot have less than #{min_words} words") if len < min_words - errors.add(:submission_text, "cannot have more than #{max_words} words") if len > max_words + word_limit(:submission_text) end # TODO: create a module to be mixed into model to perform same operation From 626eaee761b361046b40c987f45cdc9e04bee960 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 23:03:29 -0800 Subject: [PATCH 51/55] Remove unnecessary self --- app/models/event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/event.rb b/app/models/event.rb index 7c00b4d3..ba04ba20 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -349,7 +349,7 @@ class Event < ApplicationRecord def word_limit(field) # If we don't have an event type or the requested field, don't count - return unless event_type && self.respond_to?(field) && self[field] + return unless event_type && respond_to?(field) && self[field] len = self[field].split.size # TODO: Use different limits for different text fields From c8e6dc86d768f6df7b6a67635bde6cb8bdb309a2 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 22:56:45 -0800 Subject: [PATCH 52/55] Increase test coverage to stop codecov from complaining --- spec/helpers/events_helper_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index c1cf5344..077d599e 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe EventsHelper, type: :helper do let(:conference) { create(:conference) } let(:event) { create(:event_full, program: conference.program) } + let(:event_schedule) { create(:event_schedule) } let(:my_vote) { 3 } let(:max_rating) { 5 } let(:fraction) { my_vote.to_s + '/' + max_rating.to_s } @@ -28,6 +29,27 @@ describe EventsHelper, type: :helper do end end + describe '#canceled_replacement_event_label' do + describe 'returns nothing' do + it "when the event isn't cancelled and is not a replacement" do + event.state == 'confirmed' + expect(canceled_replacement_event_label(event, nil, 'text-class')).to eq nil + end + + it 'when the event is canceled' do + event.state = 'canceled' + expect(canceled_replacement_event_label(event, nil, 'test-class')).to eq 'CANCELED' + end + + it "when the event is a replacement but is not canceled" do + event.state == 'confirmed' + allow(event_schedule).to receive(:replacement?) { true } + expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq 'REPLACEMENT' + end + + end + end + describe '#rating_tooltip' do let(:vote_count) { pluralize(event.voters.length, 'vote') } From 30ec69282d6c9a0d51de0fd269c3e6667074d1f6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 23:00:04 -0800 Subject: [PATCH 53/55] Fix '==' instead of assignment operator --- spec/helpers/events_helper_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 077d599e..71ed8b16 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -32,7 +32,7 @@ describe EventsHelper, type: :helper do describe '#canceled_replacement_event_label' do describe 'returns nothing' do it "when the event isn't cancelled and is not a replacement" do - event.state == 'confirmed' + event.state = 'confirmed' expect(canceled_replacement_event_label(event, nil, 'text-class')).to eq nil end @@ -42,7 +42,7 @@ describe EventsHelper, type: :helper do end it "when the event is a replacement but is not canceled" do - event.state == 'confirmed' + event.state = 'confirmed' allow(event_schedule).to receive(:replacement?) { true } expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq 'REPLACEMENT' end From 54a5f84d8bd85064a39c259638088498e5c4ec60 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 23:01:28 -0800 Subject: [PATCH 54/55] Prefer single-quoted strings --- spec/helpers/events_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 71ed8b16..35866d6b 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -41,7 +41,7 @@ describe EventsHelper, type: :helper do expect(canceled_replacement_event_label(event, nil, 'test-class')).to eq 'CANCELED' end - it "when the event is a replacement but is not canceled" do + it 'when the event is a replacement but is not canceled' do event.state = 'confirmed' allow(event_schedule).to receive(:replacement?) { true } expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq 'REPLACEMENT' From f913d69ca947987f7885a9ddc65a7aca3d0f9c63 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 17:47:36 +0000 Subject: [PATCH 55/55] Update chartkick to version 3.4.2 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ba1be7eb..296eb96c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,7 +118,7 @@ GEM fastimage case_transform (0.2) activesupport - chartkick (3.4.0) + chartkick (3.4.2) childprocess (3.0.0) chronic (0.10.2) chunky_png (1.3.11)