switch to manual is_delete checking to prevent derpie errors from sites deleting

This commit is contained in:
Kyle Drake 2015-02-12 15:55:38 -08:00
parent 0552b4e9b7
commit af2b7a3f86
5 changed files with 8 additions and 16 deletions

View file

@ -12,7 +12,7 @@ def browse_sites_dataset
@current_page = @current_page.to_i @current_page = @current_page.to_i
@current_page = 1 if @current_page == 0 @current_page = 1 if @current_page == 0
site_dataset = Site.filter(is_banned: false, is_crashing: false).filter(site_changed: true) site_dataset = Site.filter(is_deleted: false, is_banned: false, is_crashing: false).filter(site_changed: true)
if current_site if current_site
if !current_site.blocking_site_ids.empty? if !current_site.blocking_site_ids.empty?

View file

@ -6,7 +6,8 @@ end
get '/site/:username/?' do |username| get '/site/:username/?' do |username|
site = Site[username: username] site = Site[username: username]
not_found if site.nil? || site.is_banned # TODO: There should probably be a "this site was deleted" page.
not_found if site.nil? || site.is_banned || site.is_deleted
@title = site.title @title = site.title

View file

@ -19,7 +19,8 @@ module Sequel
# so this adds the filter for the first time the class' dataset is accessed for the new model. # so this adds the filter for the first time the class' dataset is accessed for the new model.
def dataset def dataset
if @_is_deleted_filter_set.nil? if @_is_deleted_filter_set.nil?
@dataset.filter! is_deleted: false #KD: I turned this off because I think it's easier to do this manually.
#@dataset.filter! is_deleted: false
@_is_deleted_filter_set = true @_is_deleted_filter_set = true
end end
super super

View file

@ -220,6 +220,7 @@ class Site < Sequel::Model
site = get_with_identifier username_or_email site = get_with_identifier username_or_email
return false if site.nil? return false if site.nil?
return false if site.is_deleted
site.valid_password? plaintext site.valid_password? plaintext
end end
@ -385,8 +386,8 @@ class Site < Sequel::Model
FileUtils.mv files_path, File.join(DELETED_SITES_ROOT, username) FileUtils.mv files_path, File.join(DELETED_SITES_ROOT, username)
remove_all_tags remove_all_tags
remove_all_events #remove_all_events
Event.where(actioning_site_id: id).destroy #Event.where(actioning_site_id: id).destroy
} }
end end

View file

@ -5,17 +5,6 @@ def app
end end
describe Site do describe Site do
describe 'destroy' do
it 'should delete events properly' do
site_commented_on = Fabricate :site
site_commenting = Fabricate :site
site_commented_on.add_profile_comment actioning_site_id: site_commenting.id, message: 'hi'
site_commented_on.events_dataset.count.must_equal 1
site_commenting.destroy
site_commented_on.events_dataset.count.must_equal 0
end
end
describe 'can_email' do describe 'can_email' do
it 'should fail if send_emails is false' do it 'should fail if send_emails is false' do
site = Fabricate :site site = Fabricate :site