-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff8318a
commit 9288e38
Showing
8 changed files
with
170 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/jobs/estonian_tld/domain_creation_process/create_contacts_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"=>"[email protected]", "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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<div class='contact-item'> | ||
<div class="space-y-4 flex items-baseline space-x-4"> | ||
<div class="flex items-center"> | ||
<%= 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' %> | ||
</div> | ||
|
||
|
@@ -14,9 +14,72 @@ | |
<div id='private_form'> | ||
<b>Private contact field</b> | ||
|
||
<%= 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' %> | ||
|
||
<div class='flex flex-row justify-evenly items-center'> | ||
<div class='flex flex-col space-y-4'> | ||
<div class='w-96'> | ||
<%= component 'form/country_select_input', form: form, attribute: :country_code, heroicon_name: 'globe-americas' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :ident, heroicon_name: 'identification', placeholder: '2323232323' %> | ||
</div> | ||
</div> | ||
|
||
<div class='flex flex-col space-y-4'> | ||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :name, heroicon_name: 'user', placeholder: 'John Doe' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%#= 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' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%= component 'form/email_input', form: form, attribute: :email, heroicon_name: 'envelope', placeholder: '[email protected]' %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% if show_address? %> | ||
<div class='h-8'></div> | ||
|
||
<%= component 'divider', label: t('.address') %> | ||
|
||
<div class='flex flex-row justify-evenly items-center'> | ||
<div class='flex flex-col space-y-4'> | ||
<div class='w-96'> | ||
<%= component 'form/country_select_input', form: form, attribute: :address_country_code, heroicon_name: 'globe-americas' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :state, heroicon_name: 'home-modern', placeholder: 'NY' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :city, heroicon_name: 'home-modern', placeholder: 'New York' %> | ||
</div> | ||
</div> | ||
|
||
<div class='flex flex-col space-y-4'> | ||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :zip, heroicon_name: 'home-modern', placeholder: '12345' %> | ||
</div> | ||
|
||
<div class='w-96'> | ||
<%= component 'form/text_input', form: form, attribute: :street, heroicon_name: 'home-modern', placeholder: 'Somewhere' %> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<% end %> | ||
|
||
<%= form.hidden_field :_destroy %> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters