diff --git a/app/controllers/admin/admin_users_controller.rb b/app/controllers/admin/admin_users_controller.rb
index 8e72fd274..3d0c4280b 100644
--- a/app/controllers/admin/admin_users_controller.rb
+++ b/app/controllers/admin/admin_users_controller.rb
@@ -34,7 +34,7 @@ module Admin
params[:admin_user].delete(:password) if params[:admin_user][:password].blank?
params[:admin_user].delete(:password_confirmation) if params[:admin_user][:password_confirmation].blank?
- if @admin_user.update_attributes(admin_user_params)
+ if @admin_user.update(admin_user_params)
flash[:notice] = I18n.t('record_updated')
redirect_to [:admin, @admin_user]
else
diff --git a/app/helpers/sorted_country_helper.rb b/app/helpers/sorted_country_helper.rb
new file mode 100644
index 000000000..af08210be
--- /dev/null
+++ b/app/helpers/sorted_country_helper.rb
@@ -0,0 +1,32 @@
+module SortedCountryHelper
+ def all_country_options(selected = nil)
+ quick_options = options_for_select(quick_list, selected: selected)
+
+ # no double select
+ selected = quick_list.map(&:second).include?(selected) ? '' : selected
+
+ all_options = options_for_select([['---', '---']] + all_sorted_truncated,
+ selected: selected, disabled: ['---'])
+ quick_options + all_options
+ end
+
+ def quick_list
+ [
+ %w[Estonia EE],
+ %w[Finland FI],
+ %w[Latvia LV],
+ %w[Lithuania LT],
+ ['Russian Federation', 'RU'],
+ %w[Sweden SE],
+ ['United States', 'US'],
+ ]
+ end
+
+ def all_sorted
+ Country.all.sort_by(&:name)
+ end
+
+ def all_sorted_truncated
+ all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
+ end
+end
diff --git a/app/models/sorted_country.rb b/app/models/sorted_country.rb
deleted file mode 100644
index 7b27adacb..000000000
--- a/app/models/sorted_country.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-class SortedCountry
- class << self
- include ActionView::Helpers
-
- def all_options(selected = nil)
- quick_options = options_for_select(quick_list, selected: selected)
-
- # no double select
- selected = quick_list.map(&:second).include?(selected) ? '' : selected
-
- all_options = options_for_select([['---', '---']] + all_sorted_truncated,
- selected: selected, disabled: ['---'])
- quick_options + all_options
- end
-
- private
-
- def quick_list
- @quick_list ||=
- [
- %w[Estonia EE],
- %w[Finland FI],
- %w[Latvia LV],
- %w[Lithuania LT],
- ['Russian Federation', 'RU'],
- %w[Sweden SE],
- ['United States', 'US']
- ]
- end
-
- def all_sorted
- @all_sorted ||= Country.all.sort_by(&:name)
- end
-
- def all_sorted_truncated
- @all_sorted_truncated ||=
- all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
- end
- end
-end
diff --git a/app/views/admin/admin_users/_form.haml b/app/views/admin/admin_users/_form.haml
index ddee458ba..d23ff40cb 100644
--- a/app/views/admin/admin_users/_form.haml
+++ b/app/views/admin/admin_users/_form.haml
@@ -35,14 +35,14 @@
.col-md-4.control-label
= f.label :country_code, t(:country), class: 'required'
.col-md-8
- = f.select :country_code, SortedCountry.all_options(f.object.country_code), {}, required: true, class: 'form-control'
+ = f.select :country_code, ApplicationController.helpers.all_country_options(f.object.country_code), {}, required: true, class: 'form-control'
%hr
.form-group
.col-md-4.control-label
= f.label :role, nil, class: 'required'
.col-md-8
- = select_tag 'admin_user[roles][]',
- options_for_select(AdminUser::ROLES.map {|x| [t(x), x] },
+ = select_tag 'admin_user[roles][]',
+ options_for_select(AdminUser::ROLES.map {|x| [t(x), x] },
@admin_user.roles.try(:first)), class: 'form-control selectize'
%hr
diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml
index cbd11d3fc..7da4f4ab7 100644
--- a/app/views/admin/contacts/index.haml
+++ b/app/views/admin/contacts/index.haml
@@ -28,7 +28,7 @@
.col-md-3
.form-group
= label_tag t(:country)
- = select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
+ = select_tag '[q][country_code_eq]', ApplicationController.helpers.all_country_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
.col-md-6
.form-group
= label_tag t(:contact_type)
diff --git a/app/views/admin/registrars/form/_address.html.erb b/app/views/admin/registrars/form/_address.html.erb
index ccac2b03e..4d52aa591 100644
--- a/app/views/admin/registrars/form/_address.html.erb
+++ b/app/views/admin/registrars/form/_address.html.erb
@@ -49,7 +49,7 @@
<%= f.select :address_country_code,
- SortedCountry.all_options(f.object.address_country_code), {},
+ ApplicationController.helpers.all_country_options(f.object.address_country_code), {},
required: true, class: 'form-control' %>
<%= t '.country_hint' %>
@@ -59,4 +59,4 @@
-
\ No newline at end of file
+
diff --git a/app/views/registrar/contacts/_search_form.html.erb b/app/views/registrar/contacts/_search_form.html.erb
index e15ff1880..73c1281e0 100644
--- a/app/views/registrar/contacts/_search_form.html.erb
+++ b/app/views/registrar/contacts/_search_form.html.erb
@@ -40,7 +40,7 @@
<%= label_tag t(:country) %>
- <%= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
+ <%= select_tag '[q][country_code_eq]', ApplicationController.helpers.all_country_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
diff --git a/app/views/registrar/contacts/form/_address.haml b/app/views/registrar/contacts/form/_address.haml
index 1d9ae5869..7789c2891 100644
--- a/app/views/registrar/contacts/form/_address.haml
+++ b/app/views/registrar/contacts/form/_address.haml
@@ -31,6 +31,6 @@
= f.label :country_code, t(:country) + '*'
.col-md-7
- country_selected = f.object.persisted? ? f.object.country_code : 'EE'
- = f.select(:country_code, SortedCountry.all_options(country_selected),
+ = f.select(:country_code, SApplicationController.helpers.all_country_options(country_selected),
{ include_blank: true }, required: true)
diff --git a/app/views/registrar/contacts/form/_general.haml b/app/views/registrar/contacts/form/_general.haml
index b8ff90965..d7fcea38a 100644
--- a/app/views/registrar/contacts/form/_general.haml
+++ b/app/views/registrar/contacts/form/_general.haml
@@ -19,7 +19,7 @@
= Country.new(f.object.ident_country_code).try(:to_s)
= " [#{f.object.ident_country_code}]"
- else
- = f.select(:ident_country_code, SortedCountry.all_options(country_selected), {},
+ = f.select(:ident_country_code, ApplicationController.helpers.all_country_options(country_selected), {},
class: 'js-ident-country-code', required: true)
.form-group
diff --git a/db/structure.sql b/db/structure.sql
index 01565d2f9..c30e507e4 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -536,6 +536,43 @@ CREATE SEQUENCE public.certificates_id_seq
ALTER SEQUENCE public.certificates_id_seq OWNED BY public.certificates.id;
+--
+-- Name: contact_requests; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.contact_requests (
+ id integer NOT NULL,
+ whois_record_id integer NOT NULL,
+ secret character varying NOT NULL,
+ email character varying NOT NULL,
+ name character varying NOT NULL,
+ valid_to timestamp without time zone NOT NULL,
+ status character varying DEFAULT 'new'::character varying NOT NULL,
+ ip_address inet,
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL,
+ message_id character varying
+);
+
+
+--
+-- Name: contact_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE public.contact_requests_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contact_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE public.contact_requests_id_seq OWNED BY public.contact_requests.id;
+
--
-- Name: contacts; Type: TABLE; Schema: public; Owner: -
--
@@ -2735,6 +2772,13 @@ ALTER TABLE ONLY public.bounced_mail_addresses ALTER COLUMN id SET DEFAULT nextv
ALTER TABLE ONLY public.certificates ALTER COLUMN id SET DEFAULT nextval('public.certificates_id_seq'::regclass);
+--
+-- Name: contact_requests id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.contact_requests ALTER COLUMN id SET DEFAULT nextval('public.contact_requests_id_seq'::regclass);
+
+
--
-- Name: contacts id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -3193,6 +3237,14 @@ ALTER TABLE ONLY public.certificates
ADD CONSTRAINT certificates_pkey PRIMARY KEY (id);
+--
+-- Name: contact_requests contact_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.contact_requests
+ ADD CONSTRAINT contact_requests_pkey PRIMARY KEY (id);
+
+
--
-- Name: contacts contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -3780,6 +3832,34 @@ CREATE INDEX index_accounts_on_registrar_id ON public.accounts USING btree (regi
CREATE INDEX index_certificates_on_api_user_id ON public.certificates USING btree (api_user_id);
+--
+-- Name: index_contact_requests_on_email; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_contact_requests_on_email ON public.contact_requests USING btree (email);
+
+
+--
+-- Name: index_contact_requests_on_ip_address; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_contact_requests_on_ip_address ON public.contact_requests USING btree (ip_address);
+
+
+--
+-- Name: index_contact_requests_on_secret; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE UNIQUE INDEX index_contact_requests_on_secret ON public.contact_requests USING btree (secret);
+
+
+--
+-- Name: index_contact_requests_on_whois_record_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_contact_requests_on_whois_record_id ON public.contact_requests USING btree (whois_record_id);
+
+
--
-- Name: index_contacts_on_code; Type: INDEX; Schema: public; Owner: -
--