From 12c28466e1c16af408c334d486594a2d19c408df Mon Sep 17 00:00:00 2001 From: Weston Triemstra Date: Mon, 6 Apr 2020 19:58:13 -0700 Subject: [PATCH 01/70] App loads with ruby 2.4.10 and rails 4.2.11.1 --- .ruby-version | 2 +- Gemfile | 6 +- Gemfile.lock | 269 +++++++++++++------- app/controllers/application_controller.rb | 4 +- app/views/admin/market_stripe/show.html.erb | 2 +- spec/support/devise.rb | 2 +- 6 files changed, 182 insertions(+), 103 deletions(-) diff --git a/.ruby-version b/.ruby-version index bc4abe86de..b0f6bf0cd2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.8 +2.4.10 diff --git a/Gemfile b/Gemfile index 253101fe3c..652d1bd76c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,9 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end -ruby '2.3.8' +ruby '2.4.10' -gem 'rails', '~> 4.1.11' +gem 'rails', '~> 4.2.11.1' gem 'pg', '~> 0.21.0' @@ -36,7 +36,7 @@ gem 'color' gem 'countries' gem 'csv_builder' gem 'delayed_job_active_record' -gem 'devise', '~> 3.5.10' +gem 'devise' gem 'devise_invitable' gem 'devise_masquerade' gem 'dragonfly-s3_data_store' diff --git a/Gemfile.lock b/Gemfile.lock index cef9cc2c07..a658a51e03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,47 +50,54 @@ GIT GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.1) + CFPropertyList (2.3.6) accountingjs-rails (0.0.4) - actionmailer (4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) + actionmailer (4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.16) - actionview (= 4.1.16) - activesupport (= 4.1.16) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.11.1) + actionview (= 4.2.11.1) + activesupport (= 4.2.11.1) + rack (~> 1.6) rack-test (~> 0.6.2) - actionview (4.1.16) - activesupport (= 4.1.16) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.11.1) + activesupport (= 4.2.11.1) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.9.0) activemodel (>= 3.2) active_record_query_trace (1.5.4) active_record_union (1.0.1) activerecord (>= 4.0) - activemodel (4.1.16) - activesupport (= 4.1.16) + activejob (4.2.11.1) + activesupport (= 4.2.11.1) + globalid (>= 0.3.0) + activemodel (4.2.11.1) + activesupport (= 4.2.11.1) builder (~> 3.1) - activerecord (4.1.16) - activemodel (= 4.1.16) - activesupport (= 4.1.16) - arel (~> 5.0.0) + activerecord (4.2.11.1) + activemodel (= 4.2.11.1) + activesupport (= 4.2.11.1) + arel (~> 6.0) activerecord-import (0.10.0) activerecord (>= 3.0) - activesupport (4.1.16) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (4.2.11.1) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts_as_geocodable (2.1.0) - graticule (~> 2.0) - rails (>= 3, < 4.2) + acts_as_geocodable (2.0.3) + graticule (>= 2.0.0) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (5.0.1.20140414130214) + arel (6.0.4) ast (2.4.0) attr_encrypted (3.0.3) encryptor (~> 3.0.0) @@ -115,8 +122,8 @@ GEM babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - bcrypt (3.1.11) - bootsnap (1.4.5) + bcrypt (3.1.13) + bootsnap (1.4.6) msgpack (~> 1.0) browserify-rails (0.9.3) sprockets (~> 2.2) @@ -169,6 +176,7 @@ GEM currencies (~> 0.4.2) crack (0.4.3) safe_yaml (~> 1.0.0) + crass (1.0.6) csv_builder (2.1.1) actionpack (>= 3.0.0) currencies (0.4.2) @@ -183,17 +191,16 @@ GEM delayed_job (>= 3.0, < 5) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.10) + devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - devise_invitable (1.6.1) - actionmailer (>= 3.2.6) - devise (>= 3.2.0) - devise_masquerade (0.1.5) + devise_invitable (1.7.5) + actionmailer (>= 4.1.0) + devise (>= 4.0.0) + devise_masquerade (0.6.5) devise (>= 2.1.0) railties (>= 3.0) diff-lcs (1.3) @@ -212,6 +219,7 @@ GEM activemodel (>= 3.0) activesupport (>= 3.0) request_store (~> 1.0.3) + dry-inflector (0.2.0) email_spec (1.6.0) launchy (~> 2.1) mail (~> 2.2) @@ -219,7 +227,7 @@ GEM equalizer (0.0.11) erubis (2.7.0) eventmachine (1.0.5) - excon (0.72.0) + excon (0.73.0) execjs (2.7.0) factory_bot (4.8.2) activesupport (>= 3.0.0) @@ -244,17 +252,26 @@ GEM path_expander (~> 1.0) ruby_parser (~> 3.1, > 3.1.0) sexp_processor (~> 4.8) - fog (1.30.0) + fog (1.41.0) + fog-aliyun (>= 0.1.0) fog-atmos - fog-aws (~> 0.0) + fog-aws (>= 0.6.0) fog-brightbox (~> 0.4) - fog-core (~> 1.27, >= 1.27.4) - fog-ecloud - fog-google (>= 0.0.2) + fog-cloudatcost (~> 0.1.0) + fog-core (~> 1.45) + fog-digitalocean (>= 0.3.0) + fog-dnsimple (~> 1.0) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (<= 0.1.0) + fog-internet-archive + fog-joyent fog-json fog-local + fog-openstack fog-powerdns (>= 0.1.1) fog-profitbricks + fog-rackspace fog-radosgw (>= 0.0.2) fog-riakcs fog-sakuracloud (>= 0.0.4) @@ -264,49 +281,86 @@ GEM fog-terremark fog-vmfusion fog-voxel + fog-vsphere (>= 0.4.0) + fog-xenserver fog-xml (~> 0.1.1) ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) + json (>= 1.8, < 2.0) + fog-aliyun (0.3.8) + fog-core + fog-json + ipaddress (~> 0.8) + xml-simple (~> 1.1) fog-atmos (0.1.0) fog-core fog-xml - fog-aws (0.7.4) - fog-core (~> 1.27) + fog-aws (2.0.1) + fog-core (~> 1.38) fog-json (~> 1.0) fog-xml (~> 0.1) ipaddress (~> 0.8) - fog-brightbox (0.7.1) - fog-core (~> 1.22) + fog-brightbox (0.16.1) + dry-inflector + fog-core fog-json - inflecto (~> 0.0.2) - fog-core (1.32.0) + mime-types + fog-cloudatcost (0.1.2) + fog-core (~> 1.36) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.45.0) builder - excon (~> 0.45) + excon (~> 0.58) formatador (~> 0.2) - mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - fog-ecloud (0.1.1) + fog-digitalocean (0.4.0) fog-core + fog-json fog-xml - fog-google (0.0.5) + ipaddress (>= 0.5) + fog-dnsimple (1.0.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-dynect (0.0.3) fog-core fog-json fog-xml - fog-json (1.0.2) - fog-core (~> 1.0) + fog-ecloud (0.3.0) + fog-core + fog-xml + fog-google (0.1.0) + fog-core + fog-json + fog-xml + fog-internet-archive (0.0.1) + fog-core + fog-json + fog-xml + fog-joyent (0.0.1) + fog-core (~> 1.42) + fog-json (>= 1.0) + fog-json (1.2.0) + fog-core multi_json (~> 1.10) - fog-local (0.2.1) - fog-core (~> 1.27) - fog-powerdns (0.1.1) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - fog-profitbricks (0.0.2) + fog-local (0.6.0) + fog-core (>= 1.27, < 3.0) + fog-openstack (0.3.10) + fog-core (>= 1.45, <= 2.1.0) + fog-json (>= 1.0) + ipaddress (>= 0.8) + fog-powerdns (0.2.0) fog-core + fog-json fog-xml - nokogiri - fog-radosgw (0.0.4) + fog-profitbricks (4.1.1) + fog-core (~> 1.42) + fog-json (~> 1.0) + fog-rackspace (0.1.6) + fog-core (>= 1.35) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.8) + fog-radosgw (0.0.5) fog-core (>= 1.21.0) fog-json fog-xml (>= 0.0.1) @@ -314,13 +368,13 @@ GEM fog-core fog-json fog-xml - fog-sakuracloud (1.0.1) + fog-sakuracloud (1.7.5) fog-core fog-json fog-serverlove (0.1.2) fog-core fog-json - fog-softlayer (0.4.6) + fog-softlayer (1.1.4) fog-core fog-json fog-storm_on_demand (0.1.1) @@ -335,15 +389,24 @@ GEM fog-voxel (0.1.0) fog-core fog-xml - fog-xml (0.1.2) + fog-vsphere (3.2.5) + fog-core + rbvmomi (>= 1.9, < 3) + fog-xenserver (1.0.0) + fog-core + fog-xml + xmlrpc + fog-xml (0.1.3) fog-core - nokogiri (~> 1.5, >= 1.5.11) + nokogiri (>= 1.5.11, < 2.0.0) font-awesome-rails (4.4.0.0) railties (>= 3.2, < 5.0) font_assets (0.1.11) rack formatador (0.2.5) fssm (0.2.10) + globalid (0.4.2) + activesupport (>= 4.2.0) grape (1.1.0) activesupport builder @@ -360,10 +423,9 @@ GEM grape-swagger (0.10.4) grape (>= 0.8.0) grape-entity (< 0.5.0) - graticule (2.5.0) + graticule (2.7.2) activesupport i18n - json nokogiri-happymapper (>= 0.5.9) guard (2.14.1) formatador (>= 0.2.4) @@ -397,12 +459,11 @@ GEM i18n (0.9.5) concurrent-ruby (~> 1.0) ice_nine (0.11.2) - inflecto (0.0.2) interactor (2.1.1) interactor-rails (1.0.1) interactor (< 3) rails (>= 3, < 5) - ipaddress (0.8.0) + ipaddress (0.8.3) jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) @@ -436,8 +497,11 @@ GEM listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) lumberjack (1.0.12) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mailcatcher (0.6.1) activesupport (>= 4.0.0, < 5) @@ -466,16 +530,13 @@ GEM mustermann-grape (1.0.1) mustermann (>= 1.0.0) nenv (0.3.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.2) newrelic-dragonfly (0.0.4) dragonfly newrelic_rpm newrelic_rpm (5.2.0.345) nokogiri (1.10.9) mini_portile2 (~> 2.4.0) - nokogiri-happymapper (0.5.9) + nokogiri-happymapper (0.8.1) nokogiri (~> 1.5) notiffany (0.1.1) nenv (~> 0.1) @@ -496,6 +557,7 @@ GEM omniauth-stripe-connect (2.10.1) omniauth (~> 1.3) omniauth-oauth2 (~> 1.4) + optimist (3.0.0) orm_adapter (0.5.0) parallel (1.19.1) parser (2.4.0.2) @@ -539,7 +601,7 @@ GEM activesupport (>= 3.0.0) quiet_assets (1.0.3) railties (>= 3.1, < 5.0) - rack (1.5.5) + rack (1.6.13) rack-accept (0.4.5) rack (>= 0.4) rack-cache (1.2) @@ -555,16 +617,25 @@ GEM rack-test (0.6.3) rack (>= 1.0) railroady (1.5.3) - rails (4.1.16) - actionmailer (= 4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) - activemodel (= 4.1.16) - activerecord (= 4.1.16) - activesupport (= 4.1.16) + rails (4.2.11.1) + actionmailer (= 4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) + activemodel (= 4.2.11.1) + activerecord (= 4.2.11.1) + activesupport (= 4.2.11.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.16) - sprockets-rails (~> 2.0) + railties (= 4.2.11.1) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails-observers (0.1.2) activemodel (~> 4.0) rails_12factor (0.0.2) @@ -573,9 +644,9 @@ GEM rails_serve_static_assets (0.0.2) rails_stdout_logging (0.0.3) rails_view_annotator (0.0.10) - railties (4.1.16) - actionpack (= 4.1.16) - activesupport (= 4.1.16) + railties (4.2.11.1) + actionpack (= 4.2.11.1) + activesupport (= 4.2.11.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) @@ -591,6 +662,11 @@ GEM rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) + rbvmomi (2.3.1) + builder (~> 3.0) + json (>= 1.8) + nokogiri (~> 1.5) + optimist (~> 3.0) rdoc (4.1.1) json (~> 1.4) react-rails (1.4.2) @@ -607,8 +683,9 @@ GEM parser (>= 2.4.0.0, < 2.5) rainbow (~> 2.0) request_store (1.0.8) - responders (1.1.2) - railties (>= 3.2, < 4.2) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) rollbar (2.23.2) roxml (3.3.1) activesupport (>= 2.3.0) @@ -728,7 +805,7 @@ GEM tty-which (0.3.0) turbolinks (2.5.3) coffee-rails - tzinfo (1.2.6) + tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (2.7.2) execjs (>= 0.3.0) @@ -765,6 +842,8 @@ GEM wysiwyg-rails (1.2.8) font-awesome-rails (>= 4.3.0.0) railties (>= 3.2, < 5.0) + xml-simple (1.1.5) + xmlrpc (0.3.0) xpath (3.2.0) nokogiri (~> 1.8) @@ -799,7 +878,7 @@ DEPENDENCIES database_cleaner dedent delayed_job_active_record - devise (~> 3.5.10) + devise devise_invitable devise_masquerade domino (< 0.8.0) @@ -855,7 +934,7 @@ DEPENDENCIES rack-cors rack-mini-profiler railroady - rails (~> 4.1.11) + rails (~> 4.2.11.1) rails_12factor rails_view_annotator ransack @@ -900,7 +979,7 @@ DEPENDENCIES wysiwyg-rails RUBY VERSION - ruby 2.3.8p459 + ruby 2.4.10p364 BUNDLED WITH 1.17.3 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 177205f59b..d6ca5818ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -348,8 +348,8 @@ def reset_session_ids end def configure_permitted_parameters - devise_parameter_sanitizer.for(:accept_invitation).concat [:name, :email] - devise_parameter_sanitizer.for(:account_update).concat [:name] + devise_parameter_sanitizer.permit(:accept_invitation).concat [:name, :email] + devise_parameter_sanitizer.permit(:account_update).concat [:name] end def redirect_to_url diff --git a/app/views/admin/market_stripe/show.html.erb b/app/views/admin/market_stripe/show.html.erb index 2f2df6a265..6a863de00c 100644 --- a/app/views/admin/market_stripe/show.html.erb +++ b/app/views/admin/market_stripe/show.html.erb @@ -9,7 +9,7 @@
Stripe is the credit card processing technology that is integrated into the Local Orbit platform and lets you accept credit card payments.

To set up your Stripe account, click the button below and follow the instructions.

- <%= link_to image_tag('light-on-light.png'), user_omniauth_authorize_path(:stripe_connect, scope: 'read_write', state: current_market.subdomain) %> + <%= link_to image_tag('light-on-light.png'), user_stripe_connect_omniauth_authorize_path(scope: 'read_write', state: current_market.subdomain) %> <% else %>
diff --git a/spec/support/devise.rb b/spec/support/devise.rb index 7999895586..3225fc7d94 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -1,3 +1,3 @@ RSpec.configure do |config| - config.include Devise::TestHelpers, type: :controller + config.include Devise::Test::ControllerHelpers, type: :controller end From 865cba26acfacf4a38788b23a237c9752126d325 Mon Sep 17 00:00:00 2001 From: Rob Barreca Date: Mon, 6 Apr 2020 19:26:04 -1000 Subject: [PATCH 02/70] Remove geocode --- Gemfile | 4 +- Gemfile.lock | 10 ---- app/controllers/admin/metrics_controller.rb | 14 ++--- app/decorators/market_decorator.rb | 13 +++-- app/decorators/order_decorator.rb | 13 +++-- app/decorators/organization_decorator.rb | 22 +++---- app/decorators/organization_item_decorator.rb | 11 ++-- app/helpers/map_helper.rb | 28 ++++----- .../generate_table_tents_or_posters.rb | 23 ++++---- app/models/location.rb | 2 - app/models/market_address.rb | 6 +- app/serializers/market_map_serializer.rb | 4 +- app/views/admin/pack_lists/show.html.erb | 10 ++-- .../_poster_page.html.erb | 4 -- .../_table_tent_page.html.erb | 4 -- config/initializers/geo.rb | 6 +- ...416161702_add_geocodes_to_existing_data.rb | 46 +++++++-------- spec/models/location_spec.rb | 53 ----------------- spec/support/geocoder.rb | 58 +++++++++---------- 19 files changed, 132 insertions(+), 199 deletions(-) diff --git a/Gemfile b/Gemfile index 652d1bd76c..3e7553521d 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,6 @@ gem 'wysihtml5-rails' gem 'active_model_serializers' gem 'active_record_query_trace' gem 'active_record_union' -gem 'acts_as_geocodable' gem 'audited-activerecord' gem 'awesome_nested_set' gem 'bootsnap', require: false # TODO: Remove this when we upgrade to rails 5.2 @@ -43,7 +42,6 @@ gem 'dragonfly-s3_data_store' gem 'draper' gem 'figaro' gem 'font_assets' -gem 'graticule' gem 'groupdate', :git => 'https://github.com/trestrantham/groupdate.git', :branch => 'custom-calculations' # Waiting on https://github.com/ankane/groupdate/pull/53 gem 'interactor-rails', '< 3.0' gem 'interactor', '< 3.0' # We are not ready for 3 yet @@ -57,6 +55,7 @@ gem 'postgres_ext' gem 'rack-canonical-host' gem 'ransack' gem 'recaptcha' +# RAILS42 TODO: gem 'responders', '~> 2.0' gem 'simpleidn' gem 'stripe', '5.14.0' gem 'stripe_event', '2.3.0' @@ -83,6 +82,7 @@ gem 'rschema', :git => 'https://github.com/tomdalling/rschema.git' gem 'turbolinks' install_if -> { RUBY_PLATFORM =~ /darwin/ } do + # Maybe try 0.12.5.4 if run into issues gem 'wkhtmltopdf-binary', '0.12.5.1' end install_if -> { ENV['ON_HEROKU'] == 'true' } do diff --git a/Gemfile.lock b/Gemfile.lock index a658a51e03..69318d315a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,8 +93,6 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts_as_geocodable (2.0.3) - graticule (>= 2.0.0) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) arel (6.0.4) @@ -423,10 +421,6 @@ GEM grape-swagger (0.10.4) grape (>= 0.8.0) grape-entity (< 0.5.0) - graticule (2.7.2) - activesupport - i18n - nokogiri-happymapper (>= 0.5.9) guard (2.14.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -536,8 +530,6 @@ GEM newrelic_rpm (5.2.0.345) nokogiri (1.10.9) mini_portile2 (~> 2.4.0) - nokogiri-happymapper (0.8.1) - nokogiri (~> 1.5) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) @@ -856,7 +848,6 @@ DEPENDENCIES active_record_query_trace active_record_union activerecord-import - acts_as_geocodable attr_encrypted (~> 3.0.0) audited-activerecord awesome_nested_set @@ -894,7 +885,6 @@ DEPENDENCIES grape grape-active_model_serializers grape-swagger - graticule groupdate! guard-konacha-rails guard-rspec diff --git a/app/controllers/admin/metrics_controller.rb b/app/controllers/admin/metrics_controller.rb index 1793057f18..cb4975f745 100644 --- a/app/controllers/admin/metrics_controller.rb +++ b/app/controllers/admin/metrics_controller.rb @@ -16,13 +16,13 @@ def show end def map - @mapbox_map_id = Figaro.env.mapbox_api_key - markets = Market.where.not(id: Metrics::Base::TEST_MARKET_IDS).all. - joins("LEFT JOIN market_addresses ON (market_addresses.market_id = markets.id) AND (market_addresses.id = (SELECT market_addresses.id FROM market_addresses WHERE market_addresses.market_id = markets.id AND market_addresses.deleted_at IS NULL ORDER BY created_at ASC LIMIT 1))"). - joins("INNER JOIN geocodings ON geocodings.geocodable_type = 'MarketAddress' AND geocodings.geocodable_id = market_addresses.id"). - includes({organization: :plan}, addresses: [:geocoding]) - @map_data = ActiveModel::ArraySerializer.new(markets, each_serializer: MarketMapSerializer).to_json - @plans = plans_with_slugs + # @mapbox_map_id = Figaro.env.mapbox_api_key + # markets = Market.where.not(id: Metrics::Base::TEST_MARKET_IDS).all. + # joins("LEFT JOIN market_addresses ON (market_addresses.market_id = markets.id) AND (market_addresses.id = (SELECT market_addresses.id FROM market_addresses WHERE market_addresses.market_id = markets.id AND market_addresses.deleted_at IS NULL ORDER BY created_at ASC LIMIT 1))"). + # joins("INNER JOIN geocodings ON geocodings.geocodable_type = 'MarketAddress' AND geocodings.geocodable_id = market_addresses.id"). + # includes({organization: :plan}, addresses: [:geocoding]) + # @map_data = ActiveModel::ArraySerializer.new(markets, each_serializer: MarketMapSerializer).to_json + # @plans = plans_with_slugs end private diff --git a/app/decorators/market_decorator.rb b/app/decorators/market_decorator.rb index 4adbd65d6a..a62ff6bf01 100644 --- a/app/decorators/market_decorator.rb +++ b/app/decorators/market_decorator.rb @@ -15,7 +15,7 @@ def first_address def default_address default_addrs = addresses.visible.select{|addr| addr if addr.default? } # this should have only one in the array if any - unless default_addrs.empty? + unless default_addrs.empty? default_addrs.first else addresses.visible.first # if an address can be properly default or billing via those attrs, it must also be visible (not soft-deleted) @@ -25,7 +25,7 @@ def default_address def billing_address billing_addrs = addresses.visible.select{|addr| addr if addr.billing? } # should be just one again unless billing_addrs.empty? - billing_addrs.first + billing_addrs.first else addresses.visible.first end @@ -39,11 +39,12 @@ def remit_to_address end def seller_locations_map(w=400, h=300) - addresses = organizations.selling.map do |seller| - seller.shipping_location.geocode if seller.shipping_location - end.compact + # addresses = organizations.selling.map do |seller| + # seller.shipping_location.geocode if seller.shipping_location + # end.compact - google_static_map(addresses, default_address.try(:geocode), w, h) + # google_static_map(addresses, default_address.try(:geocode), w, h) + "" end def has_address? diff --git a/app/decorators/order_decorator.rb b/app/decorators/order_decorator.rb index 37fbe14de7..8a6a9dca0d 100644 --- a/app/decorators/order_decorator.rb +++ b/app/decorators/order_decorator.rb @@ -30,12 +30,13 @@ def display_delivery_phone end def delivery_lat_long - address = organization.locations.default_shipping - if !address.nil? && !address.geocode.nil? - raw "#{address.geocode.latitude},#{address.geocode.longitude}" - else - "" - end + # address = organization.locations.default_shipping + # if !address.nil? && !address.geocode.nil? + # raw "#{address.geocode.latitude},#{address.geocode.longitude}" + # else + # "" + # end + "" end def display_market_street diff --git a/app/decorators/organization_decorator.rb b/app/decorators/organization_decorator.rb index 1f0a4f3128..2bff2fcfa5 100644 --- a/app/decorators/organization_decorator.rb +++ b/app/decorators/organization_decorator.rb @@ -9,11 +9,12 @@ def human_org_type end def locations_map(w=340, h=300) - addresses = locations.visible.map do |location| - location.geocode if location - end.compact + # addresses = locations.visible.map do |location| + # location.geocode if location + # end.compact - google_static_map(addresses, addresses.first, w, h, 11) + # google_static_map(addresses, addresses.first, w, h, 11) + "" end def ship_from_address @@ -25,12 +26,13 @@ def ship_from_address end def ship_from_lat_long - address = shipping_location - if !address.nil? && !address.geocode.nil? - raw "#{address.geocode.latitude},#{address.geocode.longitude}" - else - "" - end + # address = shipping_location + # if !address.nil? && !address.geocode.nil? + # raw "#{address.geocode.latitude},#{address.geocode.longitude}" + # else + # "" + # end + "" end def delivery_schedules diff --git a/app/decorators/organization_item_decorator.rb b/app/decorators/organization_item_decorator.rb index b396336f64..6afb77d0ea 100644 --- a/app/decorators/organization_item_decorator.rb +++ b/app/decorators/organization_item_decorator.rb @@ -28,11 +28,12 @@ def location end def location_map(w=300, h=200) - if location && location.geocode - google_static_map([location.geocode], location.geocode, w, h, 11) - else - "" - end + # if location && location.geocode + # google_static_map([location.geocode], location.geocode, w, h, 11) + # else + # "" + # end + "" end def location_label diff --git a/app/helpers/map_helper.rb b/app/helpers/map_helper.rb index b106b33e02..d20e4cdedf 100644 --- a/app/helpers/map_helper.rb +++ b/app/helpers/map_helper.rb @@ -12,20 +12,22 @@ def static_map(geocodes, center, width, height, zoom=9) end def google_static_map(geocodes, center, width, height, zoom=nil) - return "" unless center - markers = "?markers=" - unless geocodes.empty? - markers += geocodes.map {|g| "#{g.latitude},#{g.longitude}" }.join("|") - end - width = width > 640 ? 640 : width - height = height > 640 ? 640 : height + return "" - if zoom - zoom_str = "&zoom=#{zoom}" - else - zoom_str = "" - end + # return "" unless center + # markers = "?markers=" + # unless geocodes.empty? + # markers += geocodes.map {|g| "#{g.latitude},#{g.longitude}" }.join("|") + # end + # width = width > 640 ? 640 : width + # height = height > 640 ? 640 : height + + # if zoom + # zoom_str = "&zoom=#{zoom}" + # else + # zoom_str = "" + # end - "//maps.googleapis.com/maps/api/staticmap#{markers}&format=png&style=feature:road.highway|saturation:-100¢er=#{center.latitude},#{center.longitude}&size=#{width}x#{height}#{zoom_str}&key=#{Figaro.env.google_maps_key}" + # "//maps.googleapis.com/maps/api/staticmap#{markers}&format=png&style=feature:road.highway|saturation:-100¢er=#{center.latitude},#{center.longitude}&size=#{width}x#{height}#{zoom_str}&key=#{Figaro.env.google_maps_key}" end end diff --git a/app/interactors/generate_table_tents_or_posters.rb b/app/interactors/generate_table_tents_or_posters.rb index 6a86770376..657b845d3a 100644 --- a/app/interactors/generate_table_tents_or_posters.rb +++ b/app/interactors/generate_table_tents_or_posters.rb @@ -10,12 +10,12 @@ def perform GenerateTableTentsOrPosters.get_pdf_size(type: type) ) context[:pdf_result] = TemplatedPdfGenerator.generate_pdf( - request: request, - template: template, - locals: { + request: request, + template: template, + locals: { params: { # For some reason we packed all our data into a single local called 'params' - page_list: page_list, - include_product_names: include_product_names, + page_list: page_list, + include_product_names: include_product_names, market: order.market } }, @@ -38,12 +38,13 @@ def self.get_page_list(order:,include_product_names:) end def self.build_seller_map(seller) - seller_location = seller.shipping_location.geocode if seller.shipping_location - if seller_location - "http:" + google_static_map([seller_location], seller_location, 320, 200) - else - "" - end + # seller_location = seller.shipping_location.geocode if seller.shipping_location + # if seller_location + # "http:" + google_static_map([seller_location], seller_location, 320, 200) + # else + # "" + # end + "" end def self.get_template_from_type(type:) diff --git a/app/models/location.rb b/app/models/location.rb index 340fdcf375..fec34bce66 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -11,8 +11,6 @@ class Location < ActiveRecord::Base before_save :ensure_default_address_label after_update :set_new_defaults - acts_as_geocodable address: {street: :address, locality: :city, region: :state, postal_code: :zip, country: :country} - def self.alphabetical_by_name order(name: :asc) end diff --git a/app/models/market_address.rb b/app/models/market_address.rb index 885b2a3206..7d7c33083c 100644 --- a/app/models/market_address.rb +++ b/app/models/market_address.rb @@ -6,8 +6,6 @@ class MarketAddress < ActiveRecord::Base validates :address, :city, :state, :zip, :market, :country, presence: true - acts_as_geocodable address: {street: :address, locality: :city, region: :state, postal_code: :zip, country: :country} - before_save :ensure_single_default before_save :ensure_single_billing before_save :ensure_single_remit_to @@ -34,7 +32,7 @@ def falsify_all_others_default(mkt_addr_id) end def falsify_all_others_billing(mkt_addr_id) - MarketAddress.where( billing:true ).where(market_id:"#{mkt_addr_id}".to_i).each do |ma| + MarketAddress.where( billing:true ).where(market_id:"#{mkt_addr_id}".to_i).each do |ma| if ma.id != self.id ma.billing = false ma.save! @@ -58,7 +56,7 @@ def ensure_single_default end def ensure_single_billing - if self.billing + if self.billing falsify_all_others_billing(self.market_id) end end diff --git a/app/serializers/market_map_serializer.rb b/app/serializers/market_map_serializer.rb index 06dd301211..89054e4f1f 100644 --- a/app/serializers/market_map_serializer.rb +++ b/app/serializers/market_map_serializer.rb @@ -4,11 +4,11 @@ class MarketMapSerializer < ActiveModel::Serializer attributes :id, :name, :latitude, :longitude, :plan_name, :market_path def latitude - object.addresses.visible.first.geocode.latitude + # object.addresses.visible.first.geocode.latitude end def longitude - object.addresses.visible.first.geocode.longitude + # object.addresses.visible.first.geocode.longitude end def plan_name diff --git a/app/views/admin/pack_lists/show.html.erb b/app/views/admin/pack_lists/show.html.erb index 63980b542a..9c0243717c 100644 --- a/app/views/admin/pack_lists/show.html.erb +++ b/app/views/admin/pack_lists/show.html.erb @@ -3,11 +3,11 @@