mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Add form for adding zone #2806
This commit is contained in:
parent
1fe8bd3f46
commit
44b2d383b1
10 changed files with 163 additions and 67 deletions
|
@ -5,6 +5,22 @@ class Admin::ZonefileSettingsController < AdminController
|
||||||
@zonefile_settings = ZonefileSetting.all
|
@zonefile_settings = ZonefileSetting.all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@zonefile_setting = ZonefileSetting.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@zonefile_setting = ZonefileSetting.new(zonefile_setting_params)
|
||||||
|
|
||||||
|
if @zonefile_setting.save
|
||||||
|
flash[:notice] = I18n.t('record_created')
|
||||||
|
redirect_to admin_zonefile_settings_path
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||||
|
render 'new'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@zonefile_setting = ZonefileSetting.find(params[:id])
|
@zonefile_setting = ZonefileSetting.find(params[:id])
|
||||||
end
|
end
|
||||||
|
@ -26,6 +42,8 @@ class Admin::ZonefileSettingsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def zonefile_setting_params
|
def zonefile_setting_params
|
||||||
params.require(:zonefile_setting).permit(:ttl, :refresh, :retry, :expire, :minimum_ttl, :email)
|
params.require(:zonefile_setting).permit(
|
||||||
|
:origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :ns_records, :a_records, :a4_records
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ class ZonefileSetting < ActiveRecord::Base
|
||||||
include Versions # version/zonefile_setting_version.rb
|
include Versions # version/zonefile_setting_version.rb
|
||||||
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
|
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
|
||||||
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
||||||
|
validates :origin, uniqueness: true
|
||||||
|
|
||||||
def self.generate_zonefiles
|
def self.generate_zonefiles
|
||||||
pluck(:origin).each do |origin|
|
pluck(:origin).each do |origin|
|
||||||
|
|
74
app/views/admin/zonefile_settings/_form.haml
Normal file
74
app/views/admin/zonefile_settings/_form.haml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
|
||||||
|
= form_for [:admin, @zonefile_setting], html: { class: 'form-horizontal' } do |f|
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
#domain-statuses
|
||||||
|
= render 'shared/full_errors', object: f.object
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :origin
|
||||||
|
.col-md-8
|
||||||
|
- if @zonefile_setting.persisted?
|
||||||
|
= f.text_field :origin, class: 'form-control', disabled: true
|
||||||
|
- else
|
||||||
|
= f.text_field :origin, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :ttl
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :ttl, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :refresh
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :refresh, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :retry
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :retry, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :expire
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :expire, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :minimum_ttl
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :minimum_ttl, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :email
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field :email, class: 'form-control'
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :ns_records
|
||||||
|
.col-md-8
|
||||||
|
= f.text_area :ns_records, class: 'form-control', rows: 8
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :a_records
|
||||||
|
.col-md-8
|
||||||
|
= f.text_area :a_records, class: 'form-control', rows: 8
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :a4_records, t(:a4_records)
|
||||||
|
.col-md-8
|
||||||
|
= f.text_area :a4_records, class: 'form-control', rows: 8
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-8.text-right
|
||||||
|
%button.btn.btn-primary= t(:save)
|
|
@ -1,53 +1,5 @@
|
||||||
= render 'shared/title', name: t(:zonefile_settings)
|
- content_for :actions do
|
||||||
|
= link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
|
||||||
|
= render 'shared/title', name: t(:edit_zone)
|
||||||
|
|
||||||
= form_for [:admin, @zonefile_setting], html: { class: 'form-horizontal' } do |f|
|
= render 'form'
|
||||||
.row
|
|
||||||
.col-md-8
|
|
||||||
#domain-statuses
|
|
||||||
= render 'shared/full_errors', object: f.object
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :origin
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :origin, class: 'form-control', disabled: true
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :ttl
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :ttl, class: 'form-control'
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :refresh
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :refresh, class: 'form-control'
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :retry
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :retry, class: 'form-control'
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :expire
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :expire, class: 'form-control'
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :minimum_ttl
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :minimum_ttl, class: 'form-control'
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :email
|
|
||||||
.col-md-8
|
|
||||||
= f.text_field :email, class: 'form-control', email: true
|
|
||||||
|
|
||||||
%hr
|
|
||||||
.row
|
|
||||||
.col-md-8.text-right
|
|
||||||
%button.btn.btn-primary= t(:save)
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
- content_for :actions do
|
||||||
|
= link_to(t(:new), new_admin_zonefile_setting_path, class: 'btn btn-primary')
|
||||||
= render 'shared/title', name: t(:zonefile_settings)
|
= render 'shared/title', name: t(:zonefile_settings)
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
@ -15,6 +17,6 @@
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x, edit_admin_zonefile_setting_path(x))
|
%td= link_to(x, edit_admin_zonefile_setting_path(x))
|
||||||
%td
|
%td
|
||||||
= link_to(t(:generate_zonefile),
|
= link_to(t(:generate_zonefile),
|
||||||
admin_zonefiles_path(origin: x.origin),
|
admin_zonefiles_path(origin: x.origin),
|
||||||
method: 'post', class: 'btn btn-xs btn-primary')
|
method: 'post', class: 'btn btn-xs btn-primary')
|
||||||
|
|
5
app/views/admin/zonefile_settings/new.haml
Normal file
5
app/views/admin/zonefile_settings/new.haml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- content_for :actions do
|
||||||
|
= link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
|
||||||
|
= render 'shared/title', name: t(:new_zone)
|
||||||
|
|
||||||
|
= render 'form'
|
|
@ -895,3 +895,6 @@ en:
|
||||||
result_count: '%{count} results'
|
result_count: '%{count} results'
|
||||||
failed_to_generate_invoice_invoice_number_limit_reached: 'Failed to generate invoice - invoice number limit reached'
|
failed_to_generate_invoice_invoice_number_limit_reached: 'Failed to generate invoice - invoice number limit reached'
|
||||||
is_too_small_minimum_deposit_is: 'is too small. Minimum deposit is %{amount} %{currency}'
|
is_too_small_minimum_deposit_is: 'is too small. Minimum deposit is %{amount} %{currency}'
|
||||||
|
a4_records: 'AAAA records'
|
||||||
|
new_zone: 'New zone'
|
||||||
|
edit_zone: 'Edit zone'
|
||||||
|
|
7
db/migrate/20150803080914_add_ns_data_to_zones.rb
Normal file
7
db/migrate/20150803080914_add_ns_data_to_zones.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AddNsDataToZones < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :zonefile_settings, :ns_records, :text
|
||||||
|
add_column :zonefile_settings, :a_records, :text
|
||||||
|
add_column :zonefile_settings, :a4_records, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150722071128) do
|
ActiveRecord::Schema.define(version: 20150803080914) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -216,6 +216,12 @@ ActiveRecord::Schema.define(version: 20150722071128) do
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "data_migrations", id: false, force: :cascade do |t|
|
||||||
|
t.string "version", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "data_migrations", ["version"], name: "unique_data_migrations", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "delegation_signers", force: :cascade do |t|
|
create_table "delegation_signers", force: :cascade do |t|
|
||||||
t.integer "domain_id"
|
t.integer "domain_id"
|
||||||
t.string "key_tag"
|
t.string "key_tag"
|
||||||
|
@ -1026,7 +1032,7 @@ ActiveRecord::Schema.define(version: 20150722071128) do
|
||||||
t.text "crt"
|
t.text "crt"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.string "registrant_ident"
|
t.string "registrant_ident"
|
||||||
t.string "encrypted_password", default: ""
|
t.string "encrypted_password", default: "", null: false
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.integer "failed_attempts", default: 0, null: false
|
t.integer "failed_attempts", default: 0, null: false
|
||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
|
@ -1076,6 +1082,9 @@ ActiveRecord::Schema.define(version: 20150722071128) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
|
t.text "ns_records"
|
||||||
|
t.text "a_records"
|
||||||
|
t.text "a4_records"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -690,6 +690,15 @@ CREATE SEQUENCE countries_id_seq
|
||||||
ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
|
ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE data_migrations (
|
||||||
|
version character varying NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
-- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
|
@ -2377,7 +2386,7 @@ CREATE TABLE pricelists (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
"desc" character varying,
|
"desc" character varying,
|
||||||
category character varying,
|
category character varying,
|
||||||
price_cents numeric(10,2) DEFAULT 0 NOT NULL,
|
price_cents numeric(10,2) DEFAULT 0.0 NOT NULL,
|
||||||
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
|
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
|
||||||
valid_from timestamp without time zone,
|
valid_from timestamp without time zone,
|
||||||
valid_to timestamp without time zone,
|
valid_to timestamp without time zone,
|
||||||
|
@ -2641,7 +2650,7 @@ CREATE TABLE users (
|
||||||
crt text,
|
crt text,
|
||||||
type character varying,
|
type character varying,
|
||||||
registrant_ident character varying,
|
registrant_ident character varying,
|
||||||
encrypted_password character varying DEFAULT ''::character varying,
|
encrypted_password character varying DEFAULT ''::character varying NOT NULL,
|
||||||
remember_created_at timestamp without time zone,
|
remember_created_at timestamp without time zone,
|
||||||
failed_attempts integer DEFAULT 0 NOT NULL,
|
failed_attempts integer DEFAULT 0 NOT NULL,
|
||||||
locked_at timestamp without time zone
|
locked_at timestamp without time zone
|
||||||
|
@ -2784,7 +2793,10 @@ CREATE TABLE zonefile_settings (
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
updator_str character varying
|
updator_str character varying,
|
||||||
|
ns_records text,
|
||||||
|
a_records text,
|
||||||
|
a4_records text
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -4512,6 +4524,13 @@ CREATE INDEX index_whois_records_on_domain_id ON whois_records USING btree (doma
|
||||||
CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id);
|
CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (version);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
|
@ -4727,8 +4746,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150227113121');
|
INSERT INTO schema_migrations (version) VALUES ('20150227113121');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150302130224');
|
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150302161712');
|
INSERT INTO schema_migrations (version) VALUES ('20150302161712');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150303130729');
|
INSERT INTO schema_migrations (version) VALUES ('20150303130729');
|
||||||
|
@ -4787,8 +4804,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150417082723');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150421134820');
|
INSERT INTO schema_migrations (version) VALUES ('20150421134820');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150422090645');
|
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150422092514');
|
INSERT INTO schema_migrations (version) VALUES ('20150422092514');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150422132631');
|
INSERT INTO schema_migrations (version) VALUES ('20150422132631');
|
||||||
|
@ -4833,8 +4848,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150519115050');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150519140853');
|
INSERT INTO schema_migrations (version) VALUES ('20150519140853');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150519142542');
|
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150519144118');
|
INSERT INTO schema_migrations (version) VALUES ('20150519144118');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150520163237');
|
INSERT INTO schema_migrations (version) VALUES ('20150520163237');
|
||||||
|
@ -4847,7 +4860,9 @@ INSERT INTO schema_migrations (version) VALUES ('20150522164020');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150525075550');
|
INSERT INTO schema_migrations (version) VALUES ('20150525075550');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150603141054');
|
INSERT INTO schema_migrations (version) VALUES ('20150601083516');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150601083800');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150603141549');
|
INSERT INTO schema_migrations (version) VALUES ('20150603141549');
|
||||||
|
|
||||||
|
@ -4855,8 +4870,12 @@ INSERT INTO schema_migrations (version) VALUES ('20150603211318');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150603212659');
|
INSERT INTO schema_migrations (version) VALUES ('20150603212659');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150609093515');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150609103333');
|
INSERT INTO schema_migrations (version) VALUES ('20150609103333');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150610111019');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150610112238');
|
INSERT INTO schema_migrations (version) VALUES ('20150610112238');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150610144547');
|
INSERT INTO schema_migrations (version) VALUES ('20150610144547');
|
||||||
|
@ -4865,8 +4884,12 @@ INSERT INTO schema_migrations (version) VALUES ('20150611124920');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150612123111');
|
INSERT INTO schema_migrations (version) VALUES ('20150612123111');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150612125720');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150701074344');
|
INSERT INTO schema_migrations (version) VALUES ('20150701074344');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150703084206');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150703084632');
|
INSERT INTO schema_migrations (version) VALUES ('20150703084632');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150706091724');
|
INSERT INTO schema_migrations (version) VALUES ('20150706091724');
|
||||||
|
@ -4883,3 +4906,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150713113436');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150722071128');
|
INSERT INTO schema_migrations (version) VALUES ('20150722071128');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150803080914');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue