whois update in auction list

This commit is contained in:
olegphenomenon 2023-05-18 10:09:25 +03:00
parent 316f00cadc
commit 06254fb994
3 changed files with 19 additions and 5 deletions

2
.gitignore vendored
View file

@ -15,3 +15,5 @@
/config/master.key
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
.rubocop.yml
/lib/tasks/mock.rake

View file

@ -64,13 +64,11 @@ module Admin
response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port'])
if response.code == "200"
return record_result_for_each_api_user(response: response)
if response.code == '200'
record_result_for_each_api_user(response: response)
else
return redirect_to request.referer, notice: 'Registrar no found'
redirect_to request.referer, notice: 'Registrar no found'
end
redirect_to request.referer, notice: 'Something goes wrong'
end
def remove_test_date

View file

@ -1,4 +1,7 @@
class Auction < ApplicationRecord
after_create :whois_create
after_destroy :whois_destroy
enum status: {
started: 'started',
awaiting_payment: 'awaiting_payment',
@ -116,6 +119,17 @@ class Auction < ApplicationRecord
new_auction.start
end
def whois_create
Whois::Record.transaction do
whois_record = Whois::Record.find_or_create_by!(name: domain)
whois_record.update_from_auction(self)
end
end
def whois_destroy
Whois::Record.find_by(name: domain)&.destroy!
end
private
def generate_registration_code