mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
switch to manual is_delete checking to prevent derpie errors from sites deleting
This commit is contained in:
parent
0552b4e9b7
commit
af2b7a3f86
5 changed files with 8 additions and 16 deletions
|
@ -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?
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue