Add statuses to domain

This commit is contained in:
Martin Lensment 2014-08-19 13:43:01 +03:00
parent b0e9828a01
commit 32fc26b5a4
7 changed files with 60 additions and 10 deletions

View file

@ -25,6 +25,12 @@ class Domain < ActiveRecord::Base
has_and_belongs_to_many :nameservers
has_many :domain_statuses
has_many :statuses, -> {
where(setting_group: SettingGroup.domain_statuses)
}, through: :domain_statuses, source: :setting
delegate :code, to: :owner_contact, prefix: true
delegate :name, to: :registrar, prefix: true

View file

@ -0,0 +1,4 @@
class DomainStatus < ActiveRecord::Base
belongs_to :domain
belongs_to :setting
end

View file

@ -11,5 +11,9 @@ class SettingGroup < ActiveRecord::Base
def domain_validation
find_by(code: 'domain_validation')
end
def domain_statuses
find_by(code: 'domain_statuses')
end
end
end

View file

@ -1,14 +1,14 @@
%h2= t('shared.setting_groups')
%hr
- @setting_groups.each do |x|
.row
.col-md-12
%table.table.table-striped.table-bordered
%tr
%th{class: 'col-xs-9'}
= t('.setting_group')
%th{class: 'col-xs-2'}
= t('shared.action')
.row
.col-md-12
%table.table.table-striped.table-bordered
%tr
%th{class: 'col-xs-9'}
= t('.setting_group')
%th{class: 'col-xs-2'}
= t('shared.action')
- @setting_groups.each do |x|
%tr
%td= t("setting_groups.codes.#{x.code}")
%td= link_to(t('.edit_settings'), setting_group_path(x), class: 'btn btn-primary btn-xs')

View file

@ -0,0 +1,8 @@
class CreateDomainsStatuses < ActiveRecord::Migration
def change
create_table :domain_statuses do |t|
t.integer :domain_id
t.integer :setting_id
end
end
end

View file

@ -0,0 +1,23 @@
class PopulateDomainStatuses < ActiveRecord::Migration
def change
SettingGroup.create(code: 'domain_statuses', settings: [
Setting.create(code: 'clientDeleteProhibited'.underscore, value: 'clientDeleteProhibited'),
Setting.create(code: 'serverDeleteProhibited'.underscore, value: 'serverDeleteProhibited'),
Setting.create(code: 'clientHold'.underscore, value: 'clientHold'),
Setting.create(code: 'serverHold'.underscore, value: 'serverHold'),
Setting.create(code: 'clientRenewProhibited'.underscore, value: 'clientRenewProhibited'),
Setting.create(code: 'serverRenewProhibited'.underscore, value: 'serverRenewProhibited'),
Setting.create(code: 'clientTransferProhibited'.underscore, value: 'clientTransferProhibited'),
Setting.create(code: 'serverTransferProhibited'.underscore, value: 'serverTransferProhibited'),
Setting.create(code: 'clientUpdateProhibited'.underscore, value: 'clientUpdateProhibited'),
Setting.create(code: 'serverUpdateProhibited'.underscore, value: 'serverUpdateProhibited'),
Setting.create(code: 'inactive', value: 'inactive'),
Setting.create(code: 'ok', value: 'ok'),
Setting.create(code: 'pendingCreate'.underscore, value: 'pendingCreate'),
Setting.create(code: 'pendingDelete'.underscore, value: 'pendingDelete'),
Setting.create(code: 'pendingRenew'.underscore, value: 'pendingRenew'),
Setting.create(code: 'pendingTransfer'.underscore, value: 'pendingTransfer'),
Setting.create(code: 'pendingUpdate'.underscore, value: 'pendingUpdate')
])
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140815114000) do
ActiveRecord::Schema.define(version: 20140819103517) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -61,6 +61,11 @@ ActiveRecord::Schema.define(version: 20140815114000) do
t.datetime "updated_at"
end
create_table "domain_statuses", force: true do |t|
t.integer "domain_id"
t.integer "setting_id"
end
create_table "domains", force: true do |t|
t.string "name"
t.integer "registrar_id"