diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb index 932c507..6580b1c 100644 --- a/app/controllers/registrant/domains_controller.rb +++ b/app/controllers/registrant/domains_controller.rb @@ -95,12 +95,12 @@ def domain_params tech_domain_contacts_attributes: [ :id, :_destroy, - contact: [:role, :name, :email, :ident, :_destroy] + contact: [:role, :name, :email, :ident, :country_code, :_destroy, :phone, :phone_code, :state, :street, :city, :zip, :address_country_code] ], admin_domain_contacts_attributes: [ :id, :_destroy, - contact: [:role, :name, :email, :ident, :_destroy] + contact: [:role, :name, :email, :ident, :_destroy, :country_code, :phone, :phone_code, :state, :street, :city, :zip, :address_country_code] ], nameservers_attributes: [ :id, diff --git a/app/jobs/estonian_tld/create_contact_job.rb b/app/jobs/estonian_tld/create_contact_job.rb index d64e606..e3dd2d5 100644 --- a/app/jobs/estonian_tld/create_contact_job.rb +++ b/app/jobs/estonian_tld/create_contact_job.rb @@ -50,7 +50,6 @@ def create_contact(registrant_user) end def contact_payload(user) - { id: nil, name: user.name, @@ -87,5 +86,4 @@ def transform_file_params(params) { body: Base64.encode64(params.read), type: params.original_filename.split('.').last.downcase } end - -end \ No newline at end of file +end diff --git a/app/jobs/estonian_tld/domain_creation_process/create_contacts_job.rb b/app/jobs/estonian_tld/domain_creation_process/create_contacts_job.rb new file mode 100644 index 0000000..3440dc8 --- /dev/null +++ b/app/jobs/estonian_tld/domain_creation_process/create_contacts_job.rb @@ -0,0 +1,88 @@ +module EstonianTld + module DomainCreationProcess + class CreateContactsJob < ApplicationJob + queue_as :critical + + def perform(pending_action) + return if pending_action.completed? + + @pending_action = pending_action + + contacts_what_not_exists = [] + contacts_without_code = [] + + pending_action.info['admin_domain_contacts_attributes'].each do |_k, v| + next if v['contact']['_destroy'] == 'true' + + contact = Contact.find_by(ident: v['contact']['ident']) + if contact.nil? + contacts_what_not_exists << v + elsif contact.code.blank? + contacts_without_code << v + end + end + + pending_action.info['tech_domain_contacts_attributes'].each do |_k, v| + next if v['contact']['_destroy'] == 'true' + + contact = Contact.find_by(ident: v['contact']['ident']) + if contact.nil? + contacts_what_not_exists << v + elsif contact.code.blank? + contacts_without_code << v + end + end + + contacts_what_not_exists.each do |contact| + create_contact(contact) + end + + puts '---' + puts contacts_what_not_exists + puts contacts_without_code + puts '---' + + (contacts_what_not_exists + contacts_without_code).each do |contact| + # EstonianTld::CreateContactJob.perform_later(contact) + user = Contact.find_by(ident: contact['contact']['ident']) + + puts '---- DO USER EXISTS ???' + puts contact['contact']['ident'] + puts user.inspect + puts '---- DO USER EXISTS ???' + + EstonianTld::CreateContactJob.perform_now(user) + end + end + + def create_contact(contact) + # {"contact"=>{"name"=>"sanjoik", "role"=>"priv", "email"=>"sanjok@gmail.com", "ident"=>"51501017732", "phone"=>"5433432", "_destroy"=>"false", "phone_code"=>"372", "country_code"=>"EE"}} + c = Contact.new( + ident: contact['contact']['ident'], + name: contact['contact']['name'], + email: contact['contact']['email'], + phone: contact['contact']['phone'], + phone_code: contact['contact']['phone_code'], + role: contact['contact']['role'], + country_code: contact['contact']['country_code'], + state: 'draft', + street: 'street', + city: 'city', + zip: 'zip' + ) + + puts '--- DO CONTACT VALID ?' + puts c.valid? + puts c.errors.full_messages + puts c.inspect + puts '--- DO CONTACT VALID ?' + + c.save! + end + + after_perform do |job| + EstonianTld::DomainCreationProcess::CreateDomainJob.perform_later(@pending_action) + end + end + end +end \ No newline at end of file diff --git a/app/jobs/estonian_tld/domain_creation_process/create_domain_job.rb b/app/jobs/estonian_tld/domain_creation_process/create_domain_job.rb index 2f07be1..9bb72c9 100644 --- a/app/jobs/estonian_tld/domain_creation_process/create_domain_job.rb +++ b/app/jobs/estonian_tld/domain_creation_process/create_domain_job.rb @@ -14,11 +14,6 @@ def perform(pending_action) registrant_contact = Contact.find_by(code: pending_action.user.code) domain = Domain.find_by(name: pending_action.info['name']) - - - p '------- Setting[dnssec_enabled] -----' - p Setting.dnssec_enabled - p '------- Setting[dnssec_enabled] -----' if domain.nil? domain = Domain.new( diff --git a/app/models/contact.rb b/app/models/contact.rb index b4d2ef1..3ec1b8e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -7,6 +7,7 @@ class Contact < ApplicationRecord include Phone attr_accessor :phone_code + attr_accessor :registrar_format_phone has_many :domain_contacts has_many :domains, through: :domain_contacts diff --git a/app/services/domain_services/create_domain_service.rb b/app/services/domain_services/create_domain_service.rb index 405fbc1..6c9fa7a 100644 --- a/app/services/domain_services/create_domain_service.rb +++ b/app/services/domain_services/create_domain_service.rb @@ -7,12 +7,8 @@ def initialize(pending_action) end def call - # todo: check, do contacts exist in registry? - # crete contacts if not - # and after that run job - - - EstonianTld::DomainCreationProcess::CreateDomainJob.perform_later(pending_action) + EstonianTld::DomainCreationProcess::CreateContactsJob.perform_later(pending_action) + # EstonianTld::DomainCreationProcess::CreateDomainJob.perform_later(pending_action) end end end diff --git a/app/views/registrant/domains/_contact_fields.html.erb b/app/views/registrant/domains/_contact_fields.html.erb index ecfb387..cf753b8 100644 --- a/app/views/registrant/domains/_contact_fields.html.erb +++ b/app/views/registrant/domains/_contact_fields.html.erb @@ -1,7 +1,7 @@
- <%= form.radio_button :role, "priv", checked: form.object.new_record? ? true : form&.object&.role == 'priv', class: "h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-500" %> + <%= form.radio_button :role, "priv", checked: form&.object&.new_record? ? true : form&.object&.role == 'priv', class: "h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-500" %> <%= form.label :role, t('.priv'), class: 'ml-3 block text-sm font-medium text-gray-700' %>
@@ -14,9 +14,72 @@
Private contact field - <%= form.text_field :name, placeholder: 'New Contact Name' %> - <%= form.text_field :email, placeholder: 'New Contact Email' %> - <%= form.text_field :ident, placeholder: 'New Contact Ident' %> + <%#= form.text_field :name, placeholder: 'New Contact Name' %> + <%#= form.text_field :email, placeholder: 'New Contact Email' %> + <%#= form.text_field :ident, placeholder: 'New Contact Ident' %> + +
+
+
+ <%= component 'form/country_select_input', form: form, attribute: :country_code, heroicon_name: 'globe-americas' %> +
+ +
+ <%= component 'form/text_input', form: form, attribute: :ident, heroicon_name: 'identification', placeholder: '2323232323' %> +
+
+ +
+
+ <%= component 'form/text_input', form: form, attribute: :name, heroicon_name: 'user', placeholder: 'John Doe' %> +
+ +
+ <%#= component 'form/text_input', form: form, attribute: :phone_code, heroicon_name: 'phone', placeholder: '+372' %> + <%#= component 'form/text_input', form: form, attribute: :phone, heroicon_name: 'phone', placeholder: '56722123' %> + + <%= component 'form/phone_input', form: form, phone_attribute: :phone, code_attribute: :phone_code, + code_placeholder: '372', phone_placeholder: '56722123' %> +
+ +
+ <%= component 'form/email_input', form: form, attribute: :email, heroicon_name: 'envelope', placeholder: 'johndoe@example.com' %> +
+
+
+ + <% if show_address? %> +
+ + <%= component 'divider', label: t('.address') %> + +
+
+
+ <%= component 'form/country_select_input', form: form, attribute: :address_country_code, heroicon_name: 'globe-americas' %> +
+ +
+ <%= component 'form/text_input', form: form, attribute: :state, heroicon_name: 'home-modern', placeholder: 'NY' %> +
+ +
+ <%= component 'form/text_input', form: form, attribute: :city, heroicon_name: 'home-modern', placeholder: 'New York' %> +
+
+ +
+
+ <%= component 'form/text_input', form: form, attribute: :zip, heroicon_name: 'home-modern', placeholder: '12345' %> +
+ +
+ <%= component 'form/text_input', form: form, attribute: :street, heroicon_name: 'home-modern', placeholder: 'Somewhere' %> +
+
+ +
+ <% end %> <%= form.hidden_field :_destroy %> diff --git a/app/views/registrar/invoices/_form.html.erb b/app/views/registrar/invoices/_form.html.erb index ece2b27..c3e45bd 100644 --- a/app/views/registrar/invoices/_form.html.erb +++ b/app/views/registrar/invoices/_form.html.erb @@ -14,41 +14,41 @@
- <%= component 'form/text_input', form: form, attribute: :name, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "nameInput" } %> + <%= component 'form/text_input', form: form, attribute: :name, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "nameInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :country_code, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "countryCodeInput" } %> + <%= component 'form/text_input', form: form, attribute: :country_code, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "countryCodeInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :state, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "stateInput" } %> + <%= component 'form/text_input', form: form, attribute: :state, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "stateInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :street, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "streetInput" } %> + <%= component 'form/text_input', form: form, attribute: :street, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "streetInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :city, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "cityInput" } %> + <%= component 'form/text_input', form: form, attribute: :city, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "cityInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :zip, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "zipInput" } %> + <%= component 'form/text_input', form: form, attribute: :zip, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "zipInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :phone, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "phoneInput" } %> + <%= component 'form/text_input', form: form, attribute: :phone, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "phoneInput" } } %>
- <%= component 'form/text_input', form: form, attribute: :url, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "urlInput" } %> + <%= component 'form/text_input', form: form, attribute: :url, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "urlInput" } } %>
- <%= component 'form/email_input', form: form, attribute: :email, heroicon_name: 'user', placeholder: 'John Dee', data_attributes: { form__invoice_autocomplete_target: "emailInput" } %> + <%= component 'form/email_input', form: form, attribute: :email, heroicon_name: 'user', placeholder: 'John Dee', options: { data_attributes: { form__invoice_autocomplete_target: "emailInput" } } %>