Registrar refactor

This commit is contained in:
Priit Tark 2015-04-09 17:09:18 +03:00
parent 6573d81b94
commit ec4c06bb06
95 changed files with 564 additions and 539 deletions

View file

@ -1,38 +0,0 @@
module Depp
# class ApplicationController < ::ApplicationController
class ApplicationController < ActionController::Base
include CurrentUserHelper
include Depp::ApplicationHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :depp_current_user
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |_exception|
redirect_to login_url, alert: t(:no_connection_to_registry)
end
before_action :authenticate_user
def authenticate_user
redirect_to main_app.login_url and return unless depp_current_user
end
def depp_current_user
return nil unless current_user
@depp_current_user ||= Depp::User.new(
tag: current_user.username,
password: current_user.password
)
end
def response_ok?
@data.css('result').each do |x|
success_codes = %(1000, 1300, 1301)
return false unless success_codes.include?(x['code'])
end
true
end
end
end

View file

@ -1,84 +0,0 @@
module Depp
class ContactsController < ApplicationController
before_action :init_epp_contact
def index
limit, offset = pagination_details
res = depp_current_user.repp_request('contacts', { details: true, limit: limit, offset: offset })
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
@response = res.parsed_body.with_indifferent_access if res.code == '200'
@contacts = @response ? @response[:contacts] : []
@paginatable_array = Kaminari.paginate_array(
[], total_count: @response[:total_number_of_records]
).page(params[:page]).per(limit)
end
def new
@contact = Depp::Contact.new
end
def show
@contact = Depp::Contact.find_by_id(params[:id])
end
def edit
@contact = Depp::Contact.find_by_id(params[:id])
end
def create
@contact = Depp::Contact.new(params[:contact])
if @contact.save
redirect_to contact_url(@contact.id)
else
render 'new'
end
end
def update
@contact = Depp::Contact.new(params[:contact])
if @contact.update_attributes(params[:contact])
redirect_to contact_url(@contact.id)
else
render 'edit'
end
end
def delete
@contact = Depp::Contact.find_by_id(params[:id])
end
def destroy
@contact = Depp::Contact.new(params[:contact])
if @contact.delete
redirect_to contacts_url, notice: t(:destroyed)
else
render 'delete'
end
end
def check
@ids = params[:contacts]
# if @ids
# @contacts = []
# @ids.split(',').each do |id|
# @contacts << id.strip
# end
# end
return unless @ids
@data = @contact.check(@ids)
@contacts = Depp::Contact.construct_check_hash_from_data(@data)
end
private
def init_epp_contact
Depp::Contact.user = depp_current_user
end
end
end

View file

@ -1,107 +0,0 @@
module Depp
class DomainsController < ApplicationController
before_action :init_domain, except: :new
def index
limit, offset = pagination_details
res = depp_current_user.repp_request('domains', { details: true, limit: limit, offset: offset })
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
@response = res.parsed_body.with_indifferent_access if res.code == '200'
@contacts = @response ? @response[:contacts] : []
@paginatable_array = Kaminari.paginate_array(
[], total_count: @response[:total_number_of_records]
).page(params[:page]).per(limit)
end
def info
@data = @domain.info(params[:domain_name]) if params[:domain_name]
if response_ok?
render 'info'
else
flash[:alert] = t('domain_not_found')
redirect_to domains_path and return
end
end
def check
if params[:domain_name]
@data = @domain.check(params[:domain_name])
render 'check_index' and return unless response_ok?
else
render 'check_index'
end
end
def new
@domain_params = Depp::Domain.default_params
end
def create
@domain_params = params[:domain]
@data = @domain.create(@domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: @domain_params[:name])
else
render 'new'
end
end
def edit
@data = @domain.info(params[:domain_name])
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
end
def update
@domain_params = params[:domain]
@data = @domain.update(@domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: @domain_params[:name])
else
params[:domain_name] = @domain_params[:name]
render 'new'
end
end
def delete; end
def destroy
@data = @domain.delete(params[:domain])
@results = @data.css('result')
if response_ok?
params[:domain_name] = nil
render 'info_index'
else
params[:domain_name] = params[:domain][:name]
render 'delete'
end
end
def renew
if params[:domain_name] && params[:cur_exp_date]
@data = @domain.renew(params)
render 'renew_index' and return unless response_ok?
else
render 'renew_index'
end
end
def transfer
if params[:domain_name]
@data = @domain.transfer(params)
render 'transfer_index' and return unless response_ok?
else
render 'transfer_index'
end
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end
end

View file

@ -1,17 +0,0 @@
module Depp
class KeyrelaysController < ApplicationController
def show; end
def create
keyrelay = Depp::Keyrelay.new(current_user: depp_current_user)
@data = keyrelay.keyrelay(params)
if response_ok?
flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully' }]
redirect_to keyrelay_path
else
render 'show'
end
end
end
end

View file

@ -1,50 +0,0 @@
module Depp
class PollsController < ApplicationController
before_action :init_epp_xml
def show
@data = depp_current_user.request(@ex.poll)
end
def destroy
@data = depp_current_user.request(@ex.poll(poll: {
value: '', attrs: { op: 'ack', msgID: params[:id] }
}))
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
def confirm_keyrelay
domain_params = params[:domain]
@data = @domain.confirm_keyrelay(domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: domain_params[:name])
else
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
end
def confirm_transfer
domain_params = params[:domain]
@data = @domain.confirm_transfer(domain_params)
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
private
def init_epp_xml
@ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end
end

View file

@ -1,23 +0,0 @@
module Depp
class XmlConsolesController < ApplicationController
def show; end
def create
begin
@result = depp_current_user.server.request(params[:payload])
rescue
@result = 'CONNECTION ERROR - Is the EPP server running?'
end
render :show
end
def load_xml
# binding.pry
cl_trid = "#{depp_current_user.tag}-#{Time.now.to_i}"
xml_dir_path = Depp::Engine.root + 'app/views/depp/xml_consoles/epp_requests'
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
render text: xml
end
end
end

View file

@ -0,0 +1,76 @@
class Registrar::ContactsController < Registrar::DeppController # EPP controller
before_action :init_epp_contact
def index
authorize! :view, Depp::Contact
limit, offset = pagination_details
res = depp_current_user.repp_request('contacts', { details: true, limit: limit, offset: offset })
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
@response = res.parsed_body.with_indifferent_access if res.code == '200'
@contacts = @response ? @response[:contacts] : []
@paginatable_array = Kaminari.paginate_array(
[], total_count: @response[:total_number_of_records]
).page(params[:page]).per(limit)
end
def new
authorize! :create, Depp::Contact
@contact = Depp::Contact.new
end
def show
authorize! :view, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def edit
authorize! :edit, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def create
authorize! :create, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
if @contact.save
redirect_to registrar_contact_url(@contact.id)
else
render 'new'
end
end
def update
authorize! :edit, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
if @contact.update_attributes(params[:contact])
redirect_to registrar_contact_url(@contact.id)
else
render 'edit'
end
end
def delete
authorize! :delete, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def destroy
authorize! :delete, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
if @contact.delete
redirect_to registrar_contacts_url, notice: t(:destroyed)
else
render 'delete'
end
end
private
def init_epp_contact
Depp::Contact.user = depp_current_user
end
end

View file

@ -0,0 +1,35 @@
class Registrar::DeppController < RegistrarController # EPP controller
include CurrentUserHelper
include Depp::ApplicationHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :depp_current_user
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |_exception|
redirect_to registrar_login_url, alert: t(:no_connection_to_registry)
end
before_action :authenticate_user
def authenticate_user
redirect_to registrar_login_url and return unless depp_current_user
end
def depp_current_user
return nil unless current_user
@depp_current_user ||= Depp::User.new(
tag: current_user.username,
password: current_user.password
)
end
def response_ok?
@data.css('result').each do |x|
success_codes = %(1000, 1300, 1301)
return false unless success_codes.include?(x['code'])
end
true
end
end

View file

@ -0,0 +1,117 @@
class Registrar::DomainsController < Registrar::DeppController # EPP controller
before_action :init_domain, except: :new
def index
authorize! :view, Depp::Domain
limit, offset = pagination_details
res = depp_current_user.repp_request('domains', { details: true, limit: limit, offset: offset })
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
@response = res.parsed_body.with_indifferent_access if res.code == '200'
@contacts = @response ? @response[:contacts] : []
@paginatable_array = Kaminari.paginate_array(
[], total_count: @response[:total_number_of_records]
).page(params[:page]).per(limit)
end
def info
authorize! :view, Depp::Domain
@data = @domain.info(params[:domain_name]) if params[:domain_name]
if response_ok?
render 'info'
else
flash[:alert] = t('domain_not_found')
redirect_to domains_path and return
end
end
def check
authorize! :view, Depp::Domain
if params[:domain_name]
@data = @domain.check(params[:domain_name])
render 'check_index' and return unless response_ok?
else
render 'check_index'
end
end
def new
authorize! :create, Depp::Domain
@domain_params = Depp::Domain.default_params
end
def create
authorize! :create, Depp::Domain
@domain_params = params[:domain]
@data = @domain.create(@domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: @domain_params[:name])
else
render 'new'
end
end
def edit
authorize! :update, Depp::Domain
@data = @domain.info(params[:domain_name])
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
end
def update
authorize! :update, Depp::Domain
@domain_params = params[:domain]
@data = @domain.update(@domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: @domain_params[:name])
else
params[:domain_name] = @domain_params[:name]
render 'new'
end
end
def delete
authorize! :delete, Depp::Domain
end
def destroy
authorize! :delete, Depp::Domain
@data = @domain.delete(params[:domain])
@results = @data.css('result')
if response_ok?
params[:domain_name] = nil
render 'info_index'
else
params[:domain_name] = params[:domain][:name]
render 'delete'
end
end
def renew
authorize! :renew, Depp::Domain
if params[:domain_name] && params[:cur_exp_date]
@data = @domain.renew(params)
render 'renew_index' and return unless response_ok?
else
render 'renew_index'
end
end
def transfer
authorize! :transfer, Depp::Domain
if params[:domain_name]
@data = @domain.transfer(params)
render 'transfer_index' and return unless response_ok?
else
render 'transfer_index'
end
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end

View file

@ -0,0 +1,18 @@
class Registrar::KeyrelaysController < Registrar::DeppController # EPP controller
def show
authorize! :view, Depp::Keyrelay
end
def create
authorize! :create, Depp::Keyrelay
keyrelay = Depp::Keyrelay.new(current_user: depp_current_user)
@data = keyrelay.keyrelay(params)
if response_ok?
flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully' }]
redirect_to keyrelay_path
else
render 'show'
end
end
end

View file

@ -0,0 +1,52 @@
class Registrar::PollsController < Registrar::DeppController # EPP controller
before_action :init_epp_xml
def show
authorize! :view, :registrar_dashboard
@data = depp_current_user.request(@ex.poll)
end
def destroy
authorize! :delete, :registrar_poll
@data = depp_current_user.request(@ex.poll(poll: {
value: '', attrs: { op: 'ack', msgID: params[:id] }
}))
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
def confirm_keyrelay
authorize! :confirm, :keyrelay
domain_params = params[:domain]
@data = @domain.confirm_keyrelay(domain_params)
if response_ok?
redirect_to info_domains_path(domain_name: domain_params[:name])
else
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
end
def confirm_transfer
authorize! :confirm, :transfer
domain_params = params[:domain]
@data = @domain.confirm_transfer(domain_params)
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
private
def init_epp_xml
@ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end

View file

@ -1,5 +1,5 @@
class Registrar::SessionsController < SessionsController
layout 'depp/application'
class Registrar::SessionsController < ::SessionsController
layout 'registrar/application'
def create
@user = ApiUser.first if params[:user1]

View file

@ -0,0 +1,24 @@
class Registrar::XmlConsolesController < Registrar::DeppController # EPP controller
def show
authorize! :view, :registrar_xml_console
end
def create
authorize! :create, :registrar_xml_console
begin
@result = depp_current_user.server.request(params[:payload])
rescue
@result = 'CONNECTION ERROR - Is the EPP server running?'
end
render :show
end
def load_xml
# binding.pry
cl_trid = "#{depp_current_user.tag}-#{Time.now.to_i}"
xml_dir_path = Depp::Engine.root + 'app/views/depp/xml_consoles/epp_requests'
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
render text: xml
end
end

View file

@ -1,4 +1,4 @@
class RegistrarController < ApplicationController
before_action :authenticate_user!
layout 'depp/application'
layout 'registrar/application'
end

View file

@ -2,6 +2,7 @@ class Ability
include CanCan::Ability
def initialize(user)
alias_action :show, to: :view
alias_action :show, :create, :update, :destroy, to: :crud
@user = user || AdminUser.new
@ -46,11 +47,20 @@ class Ability
def registrar
can :manage, Invoice
can :view, :registrar_dashboard
can :delete, :registrar_poll
can :manage, :registrar_xml_console
can :manage, Depp::Contact
can :manage, Depp::Domain
can :renew, Depp::Domain
can :transfer, Depp::Domain
can :manage, Depp::Keyrelay
can :confirm, :keyrelay
can :confirm, :transfer
end
def user
can :show, :dashboard
can :manage, Invoice
end
def customer_service

View file

@ -1,24 +0,0 @@
= form_for(@contact, html: {class: 'form-horizontal js-contact-form'}) do |f|
= render 'depp/shared/error_messages', f: f
= f.hidden_field :id
= f.hidden_field :password
.row
.col-md-12
= render 'depp/contacts/form_partials/general', f: f
.row
.col-md-12
= render 'depp/contacts/form_partials/address', f: f
- if !@contact.persisted?
.row
.col-md-12
= render 'depp/contacts/form_partials/code', f: f
.row
.col-md-12
= render 'depp/contacts/form_partials/legal_document', f: f
.row
.col-md-12.text-right
- if @contact.persisted?
= button_tag(t(:save), class: 'btn btn-primary')
- else
= button_tag(t(:create), class: 'btn btn-primary')

View file

@ -1,33 +0,0 @@
= render 'depp/shared/title', name: t(:contact_info)
%hr
.row
.col-md-12
= form_tag check_contacts_path, class: 'form-horizontal', method: :get do
.col-md-11
.form-group
= text_field_tag :contacts, params[:contacts], class: 'form-control', autocomplete: 'off'
.col-md-1.text-right.text-center-xs
.form-group
.col-md-offset-2.col-md-10
%button.btn.btn-primary
&nbsp;
%span.glyphicon.glyphicon-search
&nbsp;
- if @contacts
%hr
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th= t('id')
%th= t('value')
%tbody
- @contacts.each do |contact|
%tr
%td= contact[:id]
%td= contact[:reason]

View file

@ -1,18 +0,0 @@
- if @contact.persisted?
= render 'depp/shared/title', name: "#{t(:delete)}: #{@contact.name}"
= form_for(@contact, class: 'form-horizontal', multipart: true, method: :delete) do |f|
= render 'depp/shared/error_messages', f: f
= f.hidden_field :id
= f.hidden_field :password
.row
.col-md-12
= render 'depp/contacts/form_partials/legal_document', f: f
%hr
.row
.col-md-12.text-right
= button_tag t(:delete), class: 'btn btn-danger'
- else
%h2= "#{t(:delete)}: #{t(:not_found)}"

View file

@ -1,3 +0,0 @@
= render 'depp/shared/title', name: "#{t(:edit)}: #{@contact.name}"
= render 'form'

View file

@ -1,3 +0,0 @@
= render 'depp/shared/title', name: t(:new_contact)
= render 'form'

View file

@ -1,16 +0,0 @@
- if @contact.id.present?
- content_for :actions do
= link_to(t(:edit), edit_contact_path(@contact.id), class: 'btn btn-primary')
= link_to(t(:delete), delete_contact_path(@contact.id), class: 'btn btn-default')
= render 'depp/shared/title', name: truncate(@contact.name)
.row
.col-md-6= render 'depp/contacts/partials/general'
.col-md-6= render 'depp/contacts/partials/address'
.row
.col-md-12= render 'depp/contacts/partials/statuses', statuses: @contact.statuses
- else
.row
.col-sm-6
%h1= t(:not_found)

View file

@ -1,5 +0,0 @@
= render 'depp/shared/title', name: t(:check_domain)
.row
.col-md-12
= render 'check_form'

View file

@ -1,4 +0,0 @@
= render 'depp/shared/title', name: "#{t(:edit)}: #{params[:domain_name]}"
%hr
= render 'form'

View file

@ -1,26 +0,0 @@
- content_for :actions do
= link_to(t(:edit), edit_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-primary')
= link_to(t(:renew), renew_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default')
= link_to(t(:delete), delete_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default')
= render 'depp/shared/title', name: truncate(@data.css('name').text)
.row
.col-sm-12
- if @data.css('result').first['code'] == '1000'
.row
.col-md-12= render 'depp/domains/partials/general'
.row
.col-md-12= render 'depp/domains/partials/contacts'
.row
.col-md-12= render 'depp/domains/partials/statuses'
.row
.col-md-12= render 'depp/domains/partials/nameservers'
.row
.col-md-12= render 'depp/domains/partials/dnskeys'
- else
.row
.col-sm-6
%h1= t(:not_found)

View file

@ -1,3 +0,0 @@
= render 'depp/shared/title', name: t(:new_domain)
= render 'form'

View file

@ -28,39 +28,42 @@
- if current_user
.navbar-collapse.collapse
%ul.nav.navbar-nav.public-nav
- active_class = %w(depp/domains depp/check depp/renew depp/tranfer depp/keyrelays).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:domains), depp.domains_path
- active_class = ['depp/contacts'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:contacts), depp.contacts_path
- if can? :view, Depp::Domain
- active_class = %w(registrar/domains registrar/check registrar/renew registrar/tranfer registrar/keyrelays).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:domains), registrar_domains_path
- if can? :view, Depp::Contact
- active_class = ['registrar/contacts'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:contacts), registrar_contacts_path
- if can? :show, Invoice
- active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t('invoices'), main_app.registrar_invoices_path
- active_class = ['depp/xml_consoles'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:xml_console), depp.xml_console_path
- if can? :view, :registrar_xml_console
- active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
%ul.nav.navbar-nav.navbar-right
%li= link_to t('log_out', user: current_user), '/registrar/logout'
%li.dropdown
= link_to 'Registrar <span class="caret"></span>'.html_safe, '#',
class: 'dropdown-toggle', 'data-toggle': 'dropdown', role: 'button'
%ul.dropdown-menu{'role': 'menu'}
%li.dropdown-header= t(:switch_to) + ':'
%li= link_to t(:registrant), '#'
%li= link_to t(:registrar), '#'
- if user_signed_in?
%li= link_to t('log_out', user: current_user), '/registrar/logout'
-# %li.dropdown
-# = link_to 'Registrar <span class="caret"></span>'.html_safe, '#',
-# class: 'dropdown-toggle', 'data-toggle': 'dropdown', role: 'button'
-# %ul.dropdown-menu{'role': 'menu'}
-# %li.dropdown-header= t(:switch_to) + ':'
-# %li= link_to t(:registrant), '#'
-# %li= link_to t(:registrar), '#'
/ /.nav-collapse
.container
- if params[:controller].start_with?('depp/')
= render 'depp/shared/flash'
= render 'depp/shared/epp_results'
- else
- display = (flash.empty?) ? 'none' : 'block'
#flash{style: "display: #{display};"}
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]
-# - if params[:controller].start_with?('depp/')
-# = render 'depp/shared/flash'
-# = render 'depp/shared/epp_results'
-# - else
- display = (flash.empty?) ? 'none' : 'block'
#flash{style: "display: #{display};"}
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]
= yield
.footer.text-right

View file

@ -0,0 +1,23 @@
= render 'registrar/shared/error_messages', f: f
= f.hidden_field :id
= f.hidden_field :password
.row
.col-md-12
= render 'registrar/contacts/form_partials/general', f: f
.row
.col-md-12
= render 'registrar/contacts/form_partials/address', f: f
- if !@contact.persisted?
.row
.col-md-12
= render 'registrar/contacts/form_partials/code', f: f
.row
.col-md-12
= render 'registrar/contacts/form_partials/legal_document', f: f
.row
.col-md-12.text-right
- if @contact.persisted?
= button_tag(t(:save), class: 'btn btn-primary')
- else
= button_tag(t(:create), class: 'btn btn-primary')

View file

@ -0,0 +1,20 @@
- if @contact.persisted?
= render 'registrar/shared/title', name: "#{t(:delete)}: #{@contact.name}"
= form_for(@contact, url: registrar_contact_path(@contact),
class: 'form-horizontal', multipart: true, method: :delete) do |f|
= render 'registrar/shared/error_messages', f: f
= f.hidden_field :id
= f.hidden_field :password
.row
.col-md-12
= render 'registrar/contacts/form_partials/legal_document', f: f
%hr
.row
.col-md-12.text-right
= button_tag t(:delete), class: 'btn btn-danger'
- else
%h2= "#{t(:delete)}: #{t(:not_found)}"

View file

@ -0,0 +1,5 @@
= render 'registrar/shared/title', name: "#{t(:edit)}: #{@contact.name}"
= form_for(@contact, url: registrar_contact_path(@contact),
html: {class: 'form-horizontal js-contact-form'}) do |f|
- render 'form', f: f

View file

@ -1,6 +1,6 @@
- content_for :actions do
= link_to(t(:new), new_contact_path, class: 'btn btn-primary')
= render 'depp/shared/title', name: t(:contacts)
= link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary')
= render 'registrar/shared/title', name: t(:contacts)
- if @response
.panel.panel-default
@ -15,11 +15,11 @@
%tbody
- @contacts.each do |c|
%tr
%td= link_to(c[:name], contact_path(id: c[:code]))
%td= link_to(c[:name], registrar_contact_path(id: c[:code]))
%td= c[:code]
%td= c[:ident]
%td
= link_to(t(:edit), edit_contact_path(c[:code]), class: 'btn btn-primary btn-xs')
= link_to(t(:delete), delete_contact_path(c[:code]), class: 'btn btn-default btn-xs')
= link_to(t(:edit), edit_registrar_contact_path(c[:code]), class: 'btn btn-primary btn-xs')
= link_to(t(:delete), delete_registrar_contact_path(c[:code]), class: 'btn btn-default btn-xs')
= paginate @paginatable_array

View file

@ -1,8 +1,8 @@
= render 'depp/shared/title', name: t(:contacts_info)
= render 'registrar/shared/title', name: t(:contacts_info)
.row
.col-md-12
= form_tag contact_path, class: 'form-horizontal', method: :get do
= form_tag registrar_contact_path, class: 'form-horizontal', method: :get do
.form-group
= label_tag :contact_id, t('contact_id'), class: 'col-md-2 control-label'
.col-md-10

View file

@ -0,0 +1,5 @@
= render 'registrar/shared/title', name: t(:new_contact)
= form_for(@contact, url: registrar_contacts_path,
html: {class: 'form-horizontal js-contact-form'}) do |f|
- render 'form', f: f

View file

@ -0,0 +1,16 @@
- if @contact.id.present?
- content_for :actions do
= link_to(t(:edit), edit_registrar_contact_path(@contact.id), class: 'btn btn-primary')
= link_to(t(:delete), delete_registrar_contact_path(@contact.id), class: 'btn btn-default')
= render 'registrar/shared/title', name: truncate(@contact.name)
.row
.col-md-6= render 'registrar/contacts/partials/general'
.col-md-6= render 'registrar/contacts/partials/address'
.row
.col-md-12= render 'registrar/contacts/partials/statuses', statuses: @contact.statuses
- else
.row
.col-sm-6
%h1= t(:not_found)

View file

@ -1,4 +1,4 @@
= form_tag check_domains_path, class: 'form-horizontal', method: :get do
= form_tag check_registrar_domains_path, class: 'form-horizontal', method: :get do
.col-md-11
.form-group
= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t('domain_name'), autocomplete: 'off'

View file

@ -1,4 +1,4 @@
- path = (params[:domain_name]) ? update_domains_path : domains_path
- path = (params[:domain_name]) ? update_registrar_domains_path : registrar_domains_path
= form_tag(path, class: 'form-horizontal', multipart: true) do
.row
.col-md-12
@ -12,15 +12,15 @@
/ Tab panes
.tab-content
#general-tab.tab-pane.active
= render 'depp/domains/form_partials/general'
= render 'depp/domains/form_partials/contacts'
= render 'registrar/domains/form_partials/general'
= render 'registrar/domains/form_partials/contacts'
%hr
= render 'depp/domains/form_partials/nameservers'
= render 'registrar/domains/form_partials/nameservers'
%hr
= render 'depp/domains/form_partials/dnskeys'
= render 'registrar/domains/form_partials/dnskeys'
- if params['domain_name']
#statuses-tab.tab-pane
= render 'depp/domains/form_partials/statuses'
= render 'registrar/domains/form_partials/statuses'
.panel.panel-default
.panel-heading.clearfix

View file

@ -1,4 +1,4 @@
= render 'depp/shared/title', name: t(:check_domain)
= render 'registrar/shared/title', name: t(:check_domain)
.row
.col-md-12

View file

@ -0,0 +1,5 @@
= render 'registrar/shared/title', name: t(:check_domain)
.row
.col-md-12
= render 'check_form'

View file

@ -1,6 +1,6 @@
= render 'depp/shared/title', name: "#{t(:delete)}: #{params[:domain_name]}"
= render 'registrar/shared/title', name: "#{t(:delete)}: #{params[:domain_name]}"
= form_tag(destroy_domains_path, class: 'form-horizontal', multipart: true, method: :delete) do
= form_tag(destroy_registrar_domains_path, class: 'form-horizontal', multipart: true, method: :delete) do
.panel.panel-default
.panel-heading.clearfix
= t(:legal_document)

View file

@ -0,0 +1,4 @@
= render 'registrar/shared/title', name: "#{t(:edit)}: #{params[:domain_name]}"
%hr
= render 'form'

View file

@ -1,12 +1,12 @@
- content_for :actions do
= link_to(t(:new), new_domain_path, class: 'btn btn-primary')
= link_to(t(:transfer), transfer_domains_path, class: 'btn btn-default')
= link_to(t(:keyrelay), keyrelay_path, class: 'btn btn-default')
= render 'depp/shared/title', name: t(:domains)
= link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary')
= link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default')
= link_to(t(:keyrelay), registrar_keyrelay_path, class: 'btn btn-default')
= render 'registrar/shared/title', name: t(:domains)
.row
.col-md-12{style: 'margin-bottom: -15px;'}
= form_tag info_domains_path, class: 'form-horizontal', method: :get do
= form_tag info_registrar_domains_path, class: 'form-horizontal', method: :get do
.col-md-11
.form-group
= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t('domain_name'), autocomplete: 'off', autofocus: true
@ -31,17 +31,17 @@
%tbody
- @response['domains'].each do |x|
%tr
%td= link_to(x['name'], info_domains_path(domain_name: x['name']))
%td= link_to(x['name'], info_registrar_domains_path(domain_name: x['name']))
%td
= Time.parse(x['valid_from']).try(:to_date)
= Time.zone.parse(x['valid_from']).try(:to_date)
\-
= Time.parse(x['valid_to']).try(:to_date)
= Time.zone.parse(x['valid_to']).try(:to_date)
%td
= link_to(t(:edit), edit_domains_path(domain_name: x['name']),
= link_to(t(:edit), edit_registrar_domains_path(domain_name: x['name']),
class: 'btn btn-primary btn-xs')
= link_to(t(:renew), renew_domains_path(domain_name: x['name']),
= link_to(t(:renew), renew_registrar_domains_path(domain_name: x['name']),
class: 'btn btn-default btn-xs')
= link_to(t(:delete), delete_domains_path(domain_name: x['name']),
= link_to(t(:delete), delete_registrar_domains_path(domain_name: x['name']),
class: 'btn btn-default btn-xs')
= paginate @paginatable_array

View file

@ -0,0 +1,26 @@
- content_for :actions do
= link_to(t(:edit), edit_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-primary')
= link_to(t(:renew), renew_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default')
= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]),
class: 'btn btn-default')
= render 'registrar/shared/title', name: truncate(@data.css('name').text)
.row
.col-sm-12
- if @data.css('result').first['code'] == '1000'
.row
.col-md-12= render 'registrar/domains/partials/general'
.row
.col-md-12= render 'registrar/domains/partials/contacts'
.row
.col-md-12= render 'registrar/domains/partials/statuses'
.row
.col-md-12= render 'registrar/domains/partials/nameservers'
.row
.col-md-12= render 'registrar/domains/partials/dnskeys'
- else
.row
.col-sm-6
%h1= t(:not_found)

View file

@ -0,0 +1,3 @@
= render 'registrar/shared/title', name: t(:new_domain)
= render 'form'

View file

@ -1,4 +1,4 @@
= render 'depp/shared/title', name: t(:renew_domain)
= render 'registrar/shared/title', name: t(:renew_domain)
.row
.col-md-12

View file

@ -1,8 +1,8 @@
= render 'depp/shared/title', name: t(:renew_domain)
= render 'registrar/shared/title', name: t(:renew_domain)
.row
.col-md-12
= form_tag renew_domains_path, class: 'form-horizontal', method: :get do
= form_tag renew_registrar_domains_path, class: 'form-horizontal', method: :get do
.form-group
= label_tag :domain_name, t('name'), class: 'col-md-2 control-label'
.col-md-10

View file

@ -1,4 +1,4 @@
= render 'depp/shared/title', name: t(:transfer_domain)
= render 'registrar/shared/title', name: t(:transfer_domain)
.row
.col-md-12

View file

@ -1,8 +1,8 @@
= render 'depp/shared/title', name: t(:transfer_domain)
= render 'registrar/shared/title', name: t(:transfer_domain)
.row
.col-md-12
= form_tag transfer_domains_path, class: 'form-horizontal', method: :post, multipart: true do
= form_tag transfer_registrar_domains_path, class: 'form-horizontal', method: :post, multipart: true do
.form-group
= label_tag :domain_name, t('name'), class: 'col-md-2 control-label'
.col-md-10

View file

@ -4,7 +4,7 @@
%hr
.row
.col-md-12
= form_tag keyrelay_path, class: 'form-horizontal', method: :post, multipart: true do
= form_tag registrar_keyrelay_path, class: 'form-horizontal', method: :post, multipart: true do
.form-group
= label_tag :domain_name, t('domain_name'), class: 'col-md-2 control-label'
.col-md-10

View file

@ -15,7 +15,7 @@
- if @data.css('trnData trStatus').any? # this is a transfer request
- unless ['serverApproved', 'clientApproved'].include?(@data.css('trStatus').first.text)
= link_to(t('confirm'), 'javascript: void(0);', class: 'btn btn-primary btn-xs js-transfer-confirm')
= link_to(t('dequeue'), poll_path(id: msg_q['id']), method: :delete, class: 'btn btn-primary btn-xs')
= link_to(t('dequeue'), registrar_poll_path(id: msg_q['id']), method: :delete, class: 'btn btn-primary btn-xs')
.panel-body
%dl.dl-horizontal
%dt= t('message')
@ -56,7 +56,7 @@
%dt= t('public_key')
%dd= @data.css('pubKey').text
= form_tag confirm_keyrelay_poll_path, class: 'js-keyrelay-form' do
= form_tag registrar_confirm_keyrelay_poll_path, class: 'js-keyrelay-form' do
= hidden_field_tag 'domain[name]', @data.css('name').text
= hidden_field_tag 'domain[dnskeys_attributes][0][flags]', @data.css('flags').text
= hidden_field_tag 'domain[dnskeys_attributes][0][protocol]', @data.css('protocol').text
@ -65,7 +65,7 @@
- else
- if @data.css('trnData trStatus').any? # this is a transfer request
= form_tag confirm_transfer_poll_path, class: 'js-transfer-form' do
= form_tag registrar_confirm_transfer_poll_path, class: 'js-transfer-form' do
= hidden_field_tag 'domain[name]', @data.css('name').text
- @data.css('trnData').children.each do |x|

View file

@ -2,12 +2,12 @@
.container.subnav
%ul.nav.nav-tabs.navbar-right
%li{role: :presentation, class: active == :domains ? 'active' : ''}
= link_to t(:all), domains_path
= link_to t(:all), registrar_domains_path
%li{role: :presentation, class: active == :new ? 'active' : ''}
= link_to t(:new), new_domain_path
= link_to t(:new), new_registrar_domain_path
%li{role: :presentation, class: active == :check ? 'active' : ''}
= link_to t(:check), check_domains_path
= link_to t(:check), check_registrar_domains_path
%li{role: :presentation, class: active == :transfer ? 'active' : ''}
= link_to t(:transfer), transfer_domains_path
= link_to t(:transfer), transfer_registrar_domains_path
%li{role: :presentation, class: active == :keyrelay ? 'active' : ''}
= link_to t(:keyrelay), keyrelay_path
= link_to t(:keyrelay), registrar_keyrelay_path

View file

@ -1,6 +1,6 @@
.row
.col-md-8
= form_tag(xml_console_path) do
= form_tag(registrar_xml_console_path) do
.form-group
= text_area_tag(:payload, params[:payload], class: 'form-control', rows: 15, style: 'font-family:monospace; font-size: 11px;')

View file

@ -32,9 +32,7 @@ module Registry
# Autoload all model subdirs
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
# Autoload depp gem
config.autoload_paths += %W(#{config.root}/vendor/gems/depp/lib)
config.autoload_paths << Rails.root.join('lib')
# Add the fonts path
config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')

View file

@ -1,6 +1,10 @@
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
config.warden do |manager|
manager.failure_app = DeviseCustomFailure
end
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
@ -258,3 +262,4 @@ Devise.setup do |config|
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
end

View file

@ -15,7 +15,11 @@ Rails.application.routes.draw do
get 'error/:command', to: 'errors#error'
end
mount Repp::API => '/'
namespace :registrar do
root 'polls#show'
resources :invoices
devise_scope :user do
@ -29,12 +33,6 @@ Rails.application.routes.draw do
get 'logout' => '/devise/sessions#destroy'
end
# authenticated :user do
# root to: 'domains#index', as: :authenticated_root
# end
root to: redirect('/registrar/depp')
resources :domains do
collection do
post 'update', as: 'update'
@ -72,11 +70,9 @@ Rails.application.routes.draw do
get 'load_xml'
end
end
root 'polls#show'
end
## ADMIN ROUTES
# ## ADMIN ROUTES
namespace :admin do
resources :keyrelays
@ -143,5 +139,5 @@ Rails.application.routes.draw do
get 'login' => 'admin/sessions#login'
end
root to: redirect('login')
root to: redirect('admin/login')
end

1
depp
View file

@ -1 +0,0 @@
vendor/gems/depp

View file

@ -0,0 +1,16 @@
class DeviseCustomFailure < Devise::FailureApp
def redirect_url
return registrar_login_url if request.original_fullpath.to_s.match(/^\/registrar/)
return admin_login_url if request.original_fullpath.to_s.match(/^\/admin/)
root_url
end
# You need to override respond to eliminate recall
def respond
if http_auth?
http_auth
else
redirect
end
end
end

View file

@ -0,0 +1,23 @@
require 'rails_helper'
feature 'Root', type: :feature do
before :all do
create_settings
Fabricate(:api_user)
end
fit 'should redirect to registrar login page' do
visit '/registrar/login'
current_path.should == '/registrar/login'
end
fit 'should redirect to registrar login page' do
visit '/registrar'
current_path.should == '/registrar/login'
end
fit 'should redirect to registrar login page' do
visit '/registrar/'
current_path.should == '/registrar/login'
end
end