mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Add reserved domains management #2565
This commit is contained in:
parent
b9c8aefd19
commit
8ef8147b06
11 changed files with 132 additions and 20 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
07.07.2015
|
||||||
|
* Before applyling 20150707104937_refactor_reserved_domains.rb migration, enable hstore extension in db
|
||||||
|
|
||||||
01.07.2015
|
01.07.2015
|
||||||
|
|
||||||
* Added que init script example at doc/que directory, please setup que accornding to doc/que/README.md
|
* Added que init script example at doc/que directory, please setup que accornding to doc/que/README.md
|
||||||
|
|
|
@ -13,10 +13,12 @@ class Admin::BlockedDomainsController < AdminController
|
||||||
|
|
||||||
if bd.update(names: names)
|
if bd.update(names: names)
|
||||||
flash[:notice] = I18n.t('record_updated')
|
flash[:notice] = I18n.t('record_updated')
|
||||||
|
redirect_to :back
|
||||||
else
|
else
|
||||||
|
@blocked_domains = params[:blocked_domains]
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||||
|
render :index
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to :back
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
30
app/controllers/admin/reserved_domains_controller.rb
Normal file
30
app/controllers/admin/reserved_domains_controller.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
class Admin::ReservedDomainsController < AdminController
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def index
|
||||||
|
rd = ReservedDomain.first_or_initialize
|
||||||
|
@reserved_domains = rd.names.to_yaml
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@reserved_domains = params[:reserved_domains]
|
||||||
|
|
||||||
|
begin
|
||||||
|
names = YAML.load(params[:reserved_domains])
|
||||||
|
rescue
|
||||||
|
flash.now[:alert] = I18n.t('invalid_yaml')
|
||||||
|
logger.warn 'Invalid YAML'
|
||||||
|
render :index and return
|
||||||
|
end
|
||||||
|
|
||||||
|
rd = ReservedDomain.first_or_create
|
||||||
|
|
||||||
|
if rd.update(names: names)
|
||||||
|
flash[:notice] = I18n.t('record_updated')
|
||||||
|
redirect_to :back
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||||
|
render :index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -107,6 +107,7 @@ class Ability
|
||||||
customer_service
|
customer_service
|
||||||
can :manage, Setting
|
can :manage, Setting
|
||||||
can :manage, BlockedDomain
|
can :manage, BlockedDomain
|
||||||
|
can :manage, ReservedDomain
|
||||||
can :manage, ZonefileSetting
|
can :manage, ZonefileSetting
|
||||||
can :manage, DomainVersion
|
can :manage, DomainVersion
|
||||||
can :manage, Pricelist
|
can :manage, Pricelist
|
||||||
|
|
10
app/views/admin/reserved_domains/index.haml
Normal file
10
app/views/admin/reserved_domains/index.haml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
= render 'shared/title', name: t(:reserved_domains)
|
||||||
|
|
||||||
|
= form_tag([:admin, :reserved_domains]) do |f|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
%button.btn.btn-warning=t(:save)
|
|
@ -861,3 +861,5 @@ en:
|
||||||
receipt_date_until: 'Receipt date until'
|
receipt_date_until: 'Receipt date until'
|
||||||
add_credit: 'Add credit'
|
add_credit: 'Add credit'
|
||||||
export_csv: 'Export CSV'
|
export_csv: 'Export CSV'
|
||||||
|
reserved_domains: 'Reserved domains'
|
||||||
|
invalid_yaml: 'Invalid YAML'
|
||||||
|
|
|
@ -190,6 +190,7 @@ Rails.application.routes.draw do
|
||||||
resources :settings
|
resources :settings
|
||||||
|
|
||||||
resources :blocked_domains
|
resources :blocked_domains
|
||||||
|
resources :reserved_domains
|
||||||
|
|
||||||
resources :registrars do
|
resources :registrars do
|
||||||
resources :api_users
|
resources :api_users
|
||||||
|
|
6
db/migrate/20150707104937_refactor_reserved_domains.rb
Normal file
6
db/migrate/20150707104937_refactor_reserved_domains.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class RefactorReservedDomains < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :reserved_domains, :name
|
||||||
|
add_column :reserved_domains, :names, :hstore
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/20150707154543_increase_decimal_precision.rb
Normal file
11
db/migrate/20150707154543_increase_decimal_precision.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class IncreaseDecimalPrecision < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :account_activities, :sum, :decimal, precision: 10, scale: 2
|
||||||
|
change_column :accounts, :balance, :decimal, precision: 10, scale: 2, default: 0.0, null: false
|
||||||
|
change_column :bank_transactions, :sum, :decimal, precision: 10, scale: 2
|
||||||
|
change_column :banklink_transactions, :vk_amount, :decimal, precision: 10, scale: 2
|
||||||
|
change_column :invoice_items, :price, :decimal, precision: 10, scale: 2
|
||||||
|
change_column :invoices, :vat_prc, :decimal, precision: 10, scale: 2
|
||||||
|
change_column :invoices, :sum_cache, :decimal, precision: 10, scale: 2
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,10 +11,11 @@
|
||||||
#
|
#
|
||||||
# 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: 20150706091724) do
|
ActiveRecord::Schema.define(version: 20150707154543) 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"
|
||||||
|
enable_extension "hstore"
|
||||||
|
|
||||||
create_table "account_activities", force: :cascade do |t|
|
create_table "account_activities", force: :cascade do |t|
|
||||||
t.integer "account_id"
|
t.integer "account_id"
|
||||||
|
@ -212,6 +213,12 @@ ActiveRecord::Schema.define(version: 20150706091724) 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"
|
||||||
|
@ -928,7 +935,7 @@ ActiveRecord::Schema.define(version: 20150706091724) do
|
||||||
|
|
||||||
create_table "que_jobs", id: false, force: :cascade do |t|
|
create_table "que_jobs", id: false, force: :cascade do |t|
|
||||||
t.integer "priority", limit: 2, default: 100, null: false
|
t.integer "priority", limit: 2, default: 100, null: false
|
||||||
t.datetime "run_at", default: '2015-06-30 14:16:50', null: false
|
t.datetime "run_at", default: '2015-06-30 14:16:49', null: false
|
||||||
t.integer "job_id", limit: 8, default: 0, null: false
|
t.integer "job_id", limit: 8, default: 0, null: false
|
||||||
t.text "job_class", null: false
|
t.text "job_class", null: false
|
||||||
t.json "args", default: [], null: false
|
t.json "args", default: [], null: false
|
||||||
|
@ -978,11 +985,11 @@ ActiveRecord::Schema.define(version: 20150706091724) do
|
||||||
add_index "registrars", ["code"], name: "index_registrars_on_code", using: :btree
|
add_index "registrars", ["code"], name: "index_registrars_on_code", using: :btree
|
||||||
|
|
||||||
create_table "reserved_domains", force: :cascade do |t|
|
create_table "reserved_domains", force: :cascade do |t|
|
||||||
t.string "name"
|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
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.hstore "names"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "settings", force: :cascade do |t|
|
create_table "settings", force: :cascade do |t|
|
||||||
|
@ -1020,7 +1027,7 @@ ActiveRecord::Schema.define(version: 20150706091724) 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"
|
||||||
|
|
|
@ -23,6 +23,20 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: hstore; Type: EXTENSION; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
|
||||||
|
|
||||||
|
|
||||||
SET search_path = public, pg_catalog;
|
SET search_path = public, pg_catalog;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -41,7 +55,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
|
||||||
ret text;
|
ret text;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- define filters
|
-- define filters
|
||||||
include_filter = '%' || i_origin;
|
include_filter = '%.' || i_origin;
|
||||||
|
|
||||||
-- for %.%.%
|
-- for %.%.%
|
||||||
IF i_origin ~ '\.' THEN
|
IF i_origin ~ '\.' THEN
|
||||||
|
@ -74,7 +88,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
|
||||||
SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.')
|
SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.')
|
||||||
FROM domains d
|
FROM domains d
|
||||||
JOIN nameservers ns ON ns.domain_id = d.id
|
JOIN nameservers ns ON ns.domain_id = d.id
|
||||||
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
|
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter OR d.name = i_origin
|
||||||
ORDER BY d.name
|
ORDER BY d.name
|
||||||
),
|
),
|
||||||
chr(10)
|
chr(10)
|
||||||
|
@ -237,7 +251,7 @@ CREATE TABLE accounts (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
registrar_id integer,
|
registrar_id integer,
|
||||||
account_type character varying,
|
account_type character varying,
|
||||||
balance numeric(10,2) DEFAULT 0 NOT NULL,
|
balance numeric(10,2) DEFAULT 0.0 NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
currency character varying,
|
currency character varying,
|
||||||
|
@ -673,6 +687,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:
|
||||||
--
|
--
|
||||||
|
@ -2358,7 +2381,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,
|
||||||
|
@ -2396,7 +2419,7 @@ ALTER SEQUENCE pricelists_id_seq OWNED BY pricelists.id;
|
||||||
|
|
||||||
CREATE TABLE que_jobs (
|
CREATE TABLE que_jobs (
|
||||||
priority smallint DEFAULT 100 NOT NULL,
|
priority smallint DEFAULT 100 NOT NULL,
|
||||||
run_at timestamp without time zone DEFAULT '2015-06-30 14:16:50.905537'::timestamp without time zone NOT NULL,
|
run_at timestamp without time zone DEFAULT '2015-06-30 14:16:49.190473'::timestamp without time zone NOT NULL,
|
||||||
job_id bigint DEFAULT 0 NOT NULL,
|
job_id bigint DEFAULT 0 NOT NULL,
|
||||||
job_class text NOT NULL,
|
job_class text NOT NULL,
|
||||||
args json DEFAULT '[]'::json NOT NULL,
|
args json DEFAULT '[]'::json NOT NULL,
|
||||||
|
@ -2497,11 +2520,11 @@ ALTER SEQUENCE registrars_id_seq OWNED BY registrars.id;
|
||||||
|
|
||||||
CREATE TABLE reserved_domains (
|
CREATE TABLE reserved_domains (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
name character varying,
|
|
||||||
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,
|
||||||
|
names hstore
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2596,7 +2619,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
|
||||||
|
@ -4452,6 +4475,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:
|
||||||
--
|
--
|
||||||
|
@ -4667,8 +4697,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');
|
||||||
|
@ -4727,8 +4755,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');
|
||||||
|
@ -4773,8 +4799,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');
|
||||||
|
@ -4787,7 +4811,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');
|
||||||
|
|
||||||
|
@ -4795,8 +4821,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');
|
||||||
|
@ -4805,8 +4835,17 @@ 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');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150707104937');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150707154543');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue