diff --git a/Gemfile b/Gemfile
index 8961de1f1..fda2808be 100644
--- a/Gemfile
+++ b/Gemfile
@@ -40,6 +40,8 @@ gem 'simpleidn', '~> 0.0.5'
#for EE-id validation
gem 'isikukood'
+gem 'bootstrap-sass', '~> 3.2.0.1'
+
group :assets do
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
diff --git a/Gemfile.lock b/Gemfile.lock
index a428b85db..f60a53d70 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -28,6 +28,8 @@ GEM
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
+ bootstrap-sass (3.2.0.1)
+ sass (~> 3.2)
builder (3.2.2)
byebug (2.7.0)
columnize (~> 0.3)
@@ -180,6 +182,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ bootstrap-sass (~> 3.2.0.1)
coffee-rails (~> 4.0.0)
database_cleaner (~> 1.3.0)
epp (~> 1.4.0)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index d6925fa43..6ef234e04 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,4 +13,5 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
+//= require bootstrap-sprockets
//= require_tree .
diff --git a/app/assets/stylesheets/app.css.scss b/app/assets/stylesheets/app.css.scss
new file mode 100644
index 000000000..9190fee26
--- /dev/null
+++ b/app/assets/stylesheets/app.css.scss
@@ -0,0 +1,3 @@
+.navbar-static-top {
+ margin-bottom: 19px;
+}
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
deleted file mode 100644
index a443db340..000000000
--- a/app/assets/stylesheets/application.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * This is a manifest file that'll be compiled into application.css, which will include all the files
- * listed below.
- *
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
- *
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
- * compiled file so the styles you add here take precedence over styles defined in any styles
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
- * file per style scope.
- *
- *= require_tree .
- *= require_self
- */
diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss
new file mode 100644
index 000000000..baccee21b
--- /dev/null
+++ b/app/assets/stylesheets/application.css.scss
@@ -0,0 +1,2 @@
+@import "bootstrap-sprockets";
+@import "bootstrap";
diff --git a/app/controllers/setting_groups_controller.rb b/app/controllers/setting_groups_controller.rb
new file mode 100644
index 000000000..30694280d
--- /dev/null
+++ b/app/controllers/setting_groups_controller.rb
@@ -0,0 +1,26 @@
+class SettingGroupsController < ApplicationController
+ before_action :set_setting_group, only: [:show, :update]
+
+ def index
+ @setting_groups = SettingGroup.all
+ end
+
+ def show; end
+
+ def update
+ if @setting_group.update(setting_group_params)
+ redirect_to @setting_group
+ else
+ render 'show'
+ end
+ end
+
+ private
+ def set_setting_group
+ @setting_group = SettingGroup.find(params[:id])
+ end
+
+ def setting_group_params
+ params.require(:setting_group).permit(settings_attributes: [ :value, :id ])
+ end
+end
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
new file mode 100644
index 000000000..0958fdf04
--- /dev/null
+++ b/app/controllers/settings_controller.rb
@@ -0,0 +1,3 @@
+class SettingsController < ApplicationController
+
+end
diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb
index 21b77322b..2abf3aa27 100644
--- a/app/helpers/epp/domains_helper.rb
+++ b/app/helpers/epp/domains_helper.rb
@@ -6,7 +6,7 @@ module Epp::DomainsHelper
handle_errors(@domain) and return unless @domain.attach_objects(@ph, parsed_frame)
handle_errors(@domain) and return unless @domain.save
- render '/epp/domains/create'
+ render '/epp/domains/success'
end
end
@@ -34,6 +34,14 @@ module Epp::DomainsHelper
render '/epp/domains/info'
end
+ def update_domain
+ @domain = find_domain
+
+ handle_errors(@domain) and return unless @domain
+
+ render '/epp/domains/success'
+ end
+
### HELPER METHODS ###
private
@@ -72,6 +80,11 @@ module Epp::DomainsHelper
xml_attrs_present?(@ph, [['name']])
end
+ ## UPDATE
+ def validate_domain_update_request
+ @ph = params_hash['epp']['command']['update']['update']
+ xml_attrs_present?(@ph, [['name']])
+ end
## SHARED
def find_domain
diff --git a/app/models/setting.rb b/app/models/setting.rb
new file mode 100644
index 000000000..7c457d7b3
--- /dev/null
+++ b/app/models/setting.rb
@@ -0,0 +1,3 @@
+class Setting < ActiveRecord::Base
+ belongs_to :setting_group
+end
diff --git a/app/models/setting_group.rb b/app/models/setting_group.rb
new file mode 100644
index 000000000..914cd5b32
--- /dev/null
+++ b/app/models/setting_group.rb
@@ -0,0 +1,5 @@
+class SettingGroup < ActiveRecord::Base
+ has_many :settings
+
+ accepts_nested_attributes_for :settings
+end
diff --git a/app/views/epp/domains/create.xml.builder b/app/views/epp/domains/success.xml.builder
similarity index 100%
rename from app/views/epp/domains/create.xml.builder
rename to app/views/epp/domains/success.xml.builder
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
deleted file mode 100644
index 15fcc6082..000000000
--- a/app/views/layouts/application.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- Internetee
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
- <%= csrf_meta_tags %>
-
-
-
-<%= yield %>
-
-
-
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
new file mode 100644
index 000000000..11915fc62
--- /dev/null
+++ b/app/views/layouts/application.html.haml
@@ -0,0 +1,54 @@
+%html{lang: "en"}
+ %head
+ %meta{charset: "utf-8"}/
+ %meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
+ %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
+ %meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/
+ %meta{content: "Gitlab LTD", name: "author"}/
+ = csrf_meta_tags
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
+ %link{href: "../../favicon.ico", rel: "icon"}/
+ %title Eesti Interneti SA
+ %body
+ / Static navbar
+ .navbar.navbar-default.navbar-static-top{role: "navigation"}
+ .container
+ .navbar-header
+ %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"}
+ %span.sr-only Toggle navigation
+ %span.icon-bar
+ %span.icon-bar
+ %span.icon-bar
+ = link_to APP_CONFIG['app_name'], root_path, class: 'navbar-brand'
+ .navbar-collapse.collapse
+ %ul.nav.navbar-nav
+ %li
+ = link_to t('shared.dashboard'), root_path
+ %li
+ = link_to t('shared.registrars'), root_path
+ %li
+ = link_to t('shared.domains'), root_path
+ %li.dropdown
+ %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
+ = t('shared.settings')
+ %span.caret
+ %ul.dropdown-menu{role: "menu"}
+ %li.dropdown-header= t('shared.system')
+ %li
+ = link_to t('shared.setting_groups'), setting_groups_path
+ %li
+ = link_to t('shared.users'), '#'
+ %li
+ = link_to t('shared.epp_users'), '#'
+ %li.divider
+ %li.dropdown-header= 'Something else'
+ %li
+ %a{href: "#"} Link
+ %ul.nav.navbar-nav.navbar-right
+ %li= link_to t('shared.log_out'), '/logout'
+ / /.nav-collapse
+ .container
+ = yield
+
+
diff --git a/app/views/setting_groups/index.haml b/app/views/setting_groups/index.haml
new file mode 100644
index 000000000..492d76d54
--- /dev/null
+++ b/app/views/setting_groups/index.haml
@@ -0,0 +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')
+ %tr
+ %td= t("setting_groups.codes.#{x.code}")
+ %td= link_to(t('.edit_settings'), setting_group_path(x), class: 'btn btn-primary btn-xs')
diff --git a/app/views/setting_groups/show.haml b/app/views/setting_groups/show.haml
new file mode 100644
index 000000000..f9baf4ac3
--- /dev/null
+++ b/app/views/setting_groups/show.haml
@@ -0,0 +1,19 @@
+%h2= t("setting_groups.codes.#{@setting_group.code}")
+%hr
+= form_for(@setting_group) do |f|
+ .row
+ .col-md-12
+ %table.table.table-striped.table-bordered
+ %tr
+ %th{class: 'col-xs-9'}
+ = t('.setting')
+ %th{class: 'col-xs-2'}
+ = t('shared.value')
+ - @setting_group.settings.each do |setting|
+ = f.fields_for :settings, setting do |sf|
+ %tr
+ %td= t("settings.codes.#{sf.object.code}")
+ %td= sf.text_field(:value, autocomplete: 'off')
+ .row
+ .col-md-12.text-right
+ %button.btn.btn-primary=t('shared.save')
diff --git a/config/application.yml b/config/application.yml
new file mode 100644
index 000000000..e961a0d29
--- /dev/null
+++ b/config/application.yml
@@ -0,0 +1,14 @@
+defaults: &defaults
+ app_name: .EE Registry
+
+development:
+ <<: *defaults
+
+test:
+ <<: *defaults
+
+staging:
+ <<: *defaults
+
+production:
+ <<: *defaults
diff --git a/config/initializers/app_config.rb b/config/initializers/app_config.rb
new file mode 100644
index 000000000..0527ac9b6
--- /dev/null
+++ b/config/initializers/app_config.rb
@@ -0,0 +1 @@
+APP_CONFIG = YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env]
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 62537f891..152605419 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -83,3 +83,33 @@ en:
epp_exp_dates_do_not_match: 'Given and current expire dates do not match'
epp_registrant_not_found: 'Registrant not found'
required_parameter_missing: 'Required parameter missing: %{key}'
+
+ setting_groups:
+ codes:
+ domain_statuses: 'Domain statuses'
+
+ index:
+ setting_group: 'Setting group'
+ edit_settings: 'Edit settings'
+ show:
+ setting: 'Setting'
+
+ settings:
+ codes:
+ ns_min_count: 'Nameserver minimum count'
+ ns_max_count: 'Nameserver maximum count'
+
+ shared:
+ code: 'Code'
+ value: 'Value'
+ setting_groups: 'Setting groups'
+ action: 'Action'
+ edit: 'Edit'
+ save: 'Save'
+ dashboard: 'Dashboard'
+ log_out: 'Log out'
+ system: 'System'
+ settings: 'Settings'
+ domains: 'Domains'
+ epp_users: 'EPP Users'
+ registrars: 'Registrars'
diff --git a/config/routes.rb b/config/routes.rb
index 41e3f3d9c..09a32a0dc 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -5,11 +5,14 @@ Rails.application.routes.draw do
get 'error/:command', to: 'errors#error', defaults: { format: :xml }
end
+ resources :setting_groups
+ resources :settings
+
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
- # root 'welcome#index'
+ root 'setting_groups#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
diff --git a/db/migrate/20140815082619_create_setting_groups.rb b/db/migrate/20140815082619_create_setting_groups.rb
new file mode 100644
index 000000000..f5bd32262
--- /dev/null
+++ b/db/migrate/20140815082619_create_setting_groups.rb
@@ -0,0 +1,7 @@
+class CreateSettingGroups < ActiveRecord::Migration
+ def change
+ create_table :setting_groups do |t|
+ t.string :code
+ end
+ end
+end
diff --git a/db/migrate/20140815082916_create_settings.rb b/db/migrate/20140815082916_create_settings.rb
new file mode 100644
index 000000000..c8dff86c2
--- /dev/null
+++ b/db/migrate/20140815082916_create_settings.rb
@@ -0,0 +1,9 @@
+class CreateSettings < ActiveRecord::Migration
+ def change
+ create_table :settings do |t|
+ t.integer :setting_group_id
+ t.string :code
+ t.string :value
+ end
+ end
+end
diff --git a/db/migrate/20140815110028_populate_settings.rb b/db/migrate/20140815110028_populate_settings.rb
new file mode 100644
index 000000000..f221fc21a
--- /dev/null
+++ b/db/migrate/20140815110028_populate_settings.rb
@@ -0,0 +1,11 @@
+class PopulateSettings < ActiveRecord::Migration
+ def change
+ SettingGroup.create(
+ code: 'domain_validation',
+ settings: [
+ Setting.create(code: 'ns_min_count', value: 1),
+ Setting.create(code: 'ns_max_count', value: 13),
+ ]
+ )
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1f10eb9b4..ee21f0ba8 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140813135408) do
+ActiveRecord::Schema.define(version: 20140815110028) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -163,6 +163,16 @@ ActiveRecord::Schema.define(version: 20140813135408) do
t.datetime "updated_at"
end
+ create_table "setting_groups", force: true do |t|
+ t.string "code"
+ end
+
+ create_table "settings", force: true do |t|
+ t.integer "setting_group_id"
+ t.string "code"
+ t.string "value"
+ end
+
create_table "users", force: true do |t|
t.string "username"
t.string "password"
diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb
index 18a6768e5..f03b095d2 100644
--- a/spec/epp/domain_spec.rb
+++ b/spec/epp/domain_spec.rb
@@ -240,6 +240,15 @@ describe 'EPP Domain', epp: true do
expect(response[:results][0][:result_code]).to eq('2303')
expect(response[:results][0][:msg]).to eq('Domain not found')
end
+
+ it 'updates domain', pending: true do
+ response = epp_request('domains/update.xml')
+ expect(response[:results][0][:result_code]).to eq('1000')
+
+ d = Domain.first
+ new_ns = d.nameservers.find_by(hostname: 'ns2.example.com')
+ expect(new_ns).to be_truthy
+ end
end
it 'checks a domain' do
diff --git a/spec/epp/requests/domains/update.xml b/spec/epp/requests/domains/update.xml
new file mode 100644
index 000000000..0c4bd59dd
--- /dev/null
+++ b/spec/epp/requests/domains/update.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ example.ee
+
+
+ ns2.example.com
+
+ mak21
+ Payment overdue.
+
+
+
+ ns1.example.com
+
+ sh8013
+
+
+
+ sh8013
+
+ 2BARfoo
+
+
+
+
+ ABC-12345
+
+