diff --git a/app/controllers/admin/zonefile_settings_controller.rb b/app/controllers/admin/zonefile_settings_controller.rb index 45f31bb55..d671acba5 100644 --- a/app/controllers/admin/zonefile_settings_controller.rb +++ b/app/controllers/admin/zonefile_settings_controller.rb @@ -5,6 +5,22 @@ class Admin::ZonefileSettingsController < AdminController @zonefile_settings = ZonefileSetting.all 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 @zonefile_setting = ZonefileSetting.find(params[:id]) end @@ -26,6 +42,8 @@ class Admin::ZonefileSettingsController < AdminController end 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 diff --git a/app/models/zonefile_setting.rb b/app/models/zonefile_setting.rb index 8747a11ca..60b9994c1 100644 --- a/app/models/zonefile_setting.rb +++ b/app/models/zonefile_setting.rb @@ -2,6 +2,7 @@ class ZonefileSetting < ActiveRecord::Base include Versions # version/zonefile_setting_version.rb validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true } + validates :origin, uniqueness: true def self.generate_zonefiles pluck(:origin).each do |origin| diff --git a/app/views/admin/zonefile_settings/_form.haml b/app/views/admin/zonefile_settings/_form.haml new file mode 100644 index 000000000..f83107508 --- /dev/null +++ b/app/views/admin/zonefile_settings/_form.haml @@ -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) diff --git a/app/views/admin/zonefile_settings/edit.haml b/app/views/admin/zonefile_settings/edit.haml index 5f58cb040..f8f9a83c4 100644 --- a/app/views/admin/zonefile_settings/edit.haml +++ b/app/views/admin/zonefile_settings/edit.haml @@ -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| - .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) += render 'form' diff --git a/app/views/admin/zonefile_settings/index.haml b/app/views/admin/zonefile_settings/index.haml index 8ef09d498..a062c0793 100644 --- a/app/views/admin/zonefile_settings/index.haml +++ b/app/views/admin/zonefile_settings/index.haml @@ -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) .row @@ -15,6 +17,6 @@ %tr %td= link_to(x, edit_admin_zonefile_setting_path(x)) %td - = link_to(t(:generate_zonefile), - admin_zonefiles_path(origin: x.origin), + = link_to(t(:generate_zonefile), + admin_zonefiles_path(origin: x.origin), method: 'post', class: 'btn btn-xs btn-primary') diff --git a/app/views/admin/zonefile_settings/new.haml b/app/views/admin/zonefile_settings/new.haml new file mode 100644 index 000000000..211054e03 --- /dev/null +++ b/app/views/admin/zonefile_settings/new.haml @@ -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' diff --git a/config/locales/en.yml b/config/locales/en.yml index 5dce96914..bf44f2407 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -895,3 +895,6 @@ en: result_count: '%{count} results' 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}' + a4_records: 'AAAA records' + new_zone: 'New zone' + edit_zone: 'Edit zone' diff --git a/db/migrate/20150803080914_add_ns_data_to_zones.rb b/db/migrate/20150803080914_add_ns_data_to_zones.rb new file mode 100644 index 000000000..2d438128c --- /dev/null +++ b/db/migrate/20150803080914_add_ns_data_to_zones.rb @@ -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 diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index f7f535ed6..46df6aac0 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # 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 enable_extension "plpgsql" @@ -216,6 +216,12 @@ ActiveRecord::Schema.define(version: 20150722071128) do t.string "updator_str" 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| t.integer "domain_id" t.string "key_tag" @@ -1026,7 +1032,7 @@ ActiveRecord::Schema.define(version: 20150722071128) do t.text "crt" t.string "type" t.string "registrant_ident" - t.string "encrypted_password", default: "" + t.string "encrypted_password", default: "", null: false t.datetime "remember_created_at" t.integer "failed_attempts", default: 0, null: false t.datetime "locked_at" @@ -1076,6 +1082,9 @@ ActiveRecord::Schema.define(version: 20150722071128) do t.datetime "updated_at" t.string "creator_str" t.string "updator_str" + t.text "ns_records" + t.text "a_records" + t.text "a4_records" end end diff --git a/db/structure.sql b/db/structure.sql index 46aaf34c1..567ad5ac4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -690,6 +690,15 @@ CREATE SEQUENCE countries_id_seq 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: -- @@ -2377,7 +2386,7 @@ CREATE TABLE pricelists ( id integer NOT NULL, "desc" 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, valid_from timestamp without time zone, valid_to timestamp without time zone, @@ -2641,7 +2650,7 @@ CREATE TABLE users ( crt text, type 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, failed_attempts integer DEFAULT 0 NOT NULL, locked_at timestamp without time zone @@ -2784,7 +2793,10 @@ CREATE TABLE zonefile_settings ( created_at timestamp without time zone, updated_at timestamp without time zone, 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); +-- +-- 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: -- @@ -4727,8 +4746,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508'); 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 ('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 ('20150422090645'); - INSERT INTO schema_migrations (version) VALUES ('20150422092514'); 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 ('20150519142542'); - INSERT INTO schema_migrations (version) VALUES ('20150519144118'); 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 ('20150603141054'); +INSERT INTO schema_migrations (version) VALUES ('20150601083516'); + +INSERT INTO schema_migrations (version) VALUES ('20150601083800'); 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 ('20150609093515'); + 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 ('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 ('20150612125720'); + 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 ('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 ('20150803080914'); +