mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Save and restore statuses when setting and unsetting force delete #2845
This commit is contained in:
parent
2c0de95363
commit
9157f861d8
4 changed files with 32 additions and 13 deletions
|
@ -538,12 +538,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def set_force_delete
|
||||
statuses << DomainStatus::FORCE_DELETE
|
||||
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||
statuses << DomainStatus::PENDING_DELETE
|
||||
self.statuses_backup = statuses
|
||||
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
|
@ -551,11 +546,6 @@ class Domain < ActiveRecord::Base
|
|||
statuses.delete(DomainStatus::PENDING_RENEW)
|
||||
statuses.delete(DomainStatus::PENDING_CREATE)
|
||||
|
||||
self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
def unset_force_delete
|
||||
statuses.delete(DomainStatus::FORCE_DELETE)
|
||||
statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||
|
@ -563,7 +553,27 @@ class Domain < ActiveRecord::Base
|
|||
statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
|
||||
statuses << DomainStatus::FORCE_DELETE
|
||||
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||
statuses << DomainStatus::PENDING_DELETE
|
||||
|
||||
self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
def unset_force_delete
|
||||
s = []
|
||||
s << DomainStatus::EXPIRED if statuses.include?(DomainStatus::EXPIRED)
|
||||
s << DomainStatus::SERVER_HOLD if statuses.include?(DomainStatus::SERVER_HOLD)
|
||||
s << DomainStatus::DELETE_CANDIDATE if statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
|
||||
self.statuses = (statuses_backup + s).uniq
|
||||
|
||||
self.force_delete_at = nil
|
||||
self.statuses_backup = []
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddStatusesBackupForDomains < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :domains, :statuses_backup, :string, array: true, default: []
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150803080914) do
|
||||
ActiveRecord::Schema.define(version: 20150810114746) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -329,6 +329,7 @@ ActiveRecord::Schema.define(version: 20150803080914) do
|
|||
t.string "statuses", array: true
|
||||
t.boolean "reserved", default: false
|
||||
t.hstore "status_notes"
|
||||
t.string "statuses_backup", default: [], array: true
|
||||
end
|
||||
|
||||
add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree
|
||||
|
|
|
@ -910,7 +910,8 @@ CREATE TABLE domains (
|
|||
force_delete_at timestamp without time zone,
|
||||
statuses character varying[],
|
||||
reserved boolean DEFAULT false,
|
||||
status_notes hstore
|
||||
status_notes hstore,
|
||||
statuses_backup character varying[] DEFAULT '{}'::character varying[]
|
||||
);
|
||||
|
||||
|
||||
|
@ -4871,3 +4872,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150722071128');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150803080914');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150810114746');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue