From 3dc38bfc5a6bb59dbfd934b4bcbddd4c61f96afc Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 25 Feb 2017 10:19:14 -0800 Subject: [PATCH] tipping: only show tipping sites with paypal/btc input --- app/browse.rb | 1 + models/site.rb | 4 ++++ views/site.erb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/browse.rb b/app/browse.rb index f9440b87..f0212bab 100644 --- a/app/browse.rb +++ b/app/browse.rb @@ -85,6 +85,7 @@ def browse_sites_dataset site_dataset.order!(:site_updated_at.desc, :views.desc) when 'tipping_enabled' site_dataset.where! tipping_enabled: true + site_dataset.where!("(tipping_paypal is not null and tipping_paypal != '') or (tipping_bitcoin is not null and tipping_bitcoin != '')") site_dataset = site_dataset.association_left_join :follows site_dataset.select_all! :sites site_dataset.select_append! Sequel.lit("count(follows.site_id) AS follow_count") diff --git a/models/site.rb b/models/site.rb index 5ff4cf3b..6974d6db 100644 --- a/models/site.rb +++ b/models/site.rb @@ -1356,6 +1356,10 @@ class Site < Sequel::Model !site_files_dataset.where(path: /^\/?index.html$/).where(sha1_hash: EMPTY_FILE_HASH).first.nil? end + def tipping_enabled? + tipping_enabled && (!tipping_paypal.blank? || !tipping_bitcoin.blank?) + end + def classify(path) return nil unless classification_allowed? path #$classifier.classify process_for_classification(path) diff --git a/views/site.erb b/views/site.erb index 769774d4..4e518933 100644 --- a/views/site.erb +++ b/views/site.erb @@ -56,7 +56,7 @@ '> Share - <% if site.tipping_enabled && (!site.tipping_paypal.blank? || !site.tipping_bitcoin.blank?) %> + <% if site.tipping_enabled? %> '> Send a Tip <% end %>