mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Add domain transfers UI
This commit is contained in:
parent
6b1c98f431
commit
f42a390968
12 changed files with 173 additions and 1 deletions
3
Gemfile
3
Gemfile
|
@ -51,6 +51,9 @@ gem 'kaminari', '~> 0.16.1'
|
||||||
# for searching
|
# for searching
|
||||||
gem 'ransack', '~> 1.3.0'
|
gem 'ransack', '~> 1.3.0'
|
||||||
|
|
||||||
|
# for rights
|
||||||
|
gem 'cancan', '~> 1.6.10'
|
||||||
|
|
||||||
group :assets do
|
group :assets do
|
||||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||||
gem 'therubyracer', platforms: :ruby
|
gem 'therubyracer', platforms: :ruby
|
||||||
|
|
|
@ -34,6 +34,7 @@ GEM
|
||||||
bootstrap-sass (3.2.0.2)
|
bootstrap-sass (3.2.0.2)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
|
cancan (1.6.10)
|
||||||
capybara (2.4.1)
|
capybara (2.4.1)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
|
@ -253,6 +254,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bootstrap-sass (~> 3.2.0.1)
|
bootstrap-sass (~> 3.2.0.1)
|
||||||
|
cancan (~> 1.6.10)
|
||||||
capybara (~> 2.4.1)
|
capybara (~> 2.4.1)
|
||||||
coffee-rails (~> 4.0.0)
|
coffee-rails (~> 4.0.0)
|
||||||
database_cleaner (~> 1.3.0)
|
database_cleaner (~> 1.3.0)
|
||||||
|
|
56
app/controllers/client/domain_transfers_controller.rb
Normal file
56
app/controllers/client/domain_transfers_controller.rb
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
class Client::DomainTransfersController < ClientController
|
||||||
|
before_action :set_domain_transfer, only: :show
|
||||||
|
before_action :set_domain, only: [:create]
|
||||||
|
|
||||||
|
def new
|
||||||
|
@domain_transfer = DomainTransfer.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@domain_transfer = @domain.pending_transfer || @domain.domain_transfers.create(domain_transfer_params)
|
||||||
|
if can? :read, @domain_transfer
|
||||||
|
flash[:notice] = I18n.t('shared.domain_transfer_requested')
|
||||||
|
redirect_to [:client, @domain_transfer]
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('shared.other_registrar_has_already_requested_to_transfer_this_domain')
|
||||||
|
render 'new'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_domain_transfer
|
||||||
|
@domain_transfer = DomainTransfer.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def domain_transfer_params
|
||||||
|
ret = {
|
||||||
|
status: DomainTransfer::PENDING,
|
||||||
|
transfer_requested_at: Time.zone.now,
|
||||||
|
transfer_to: current_user.registrar,
|
||||||
|
transfer_from: @domain.registrar
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
||||||
|
|
||||||
|
if wait_time == 0
|
||||||
|
ret[:status] = DomainTransfer::SERVER_APPROVED
|
||||||
|
ret[:transferred_at] = Time.zone.now
|
||||||
|
end
|
||||||
|
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_domain
|
||||||
|
@domain_transfer = DomainTransfer.new
|
||||||
|
@domain = Domain.find_by(name: params[:domain_name])
|
||||||
|
if @domain
|
||||||
|
return if @domain.auth_info == params[:domain_pw]
|
||||||
|
flash[:alert] = I18n.t('shared.password_invalid')
|
||||||
|
render 'new'
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('shared.domain_was_not_found')
|
||||||
|
render 'new'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
36
app/models/ability.rb
Normal file
36
app/models/ability.rb
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
class Ability
|
||||||
|
include CanCan::Ability
|
||||||
|
|
||||||
|
def initialize(user)
|
||||||
|
|
||||||
|
# user ||= EppUser.last
|
||||||
|
|
||||||
|
can :read, DomainTransfer, transfer_to_id: user.registrar.id
|
||||||
|
# Define abilities for the passed in user here. For example:
|
||||||
|
#
|
||||||
|
# user ||= User.new # guest user (not logged in)
|
||||||
|
# if user.admin?
|
||||||
|
# can :manage, :all
|
||||||
|
# else
|
||||||
|
# can :read, :all
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# The first argument to `can` is the action you are giving the user
|
||||||
|
# permission to do.
|
||||||
|
# If you pass :manage it will apply to every action. Other common actions
|
||||||
|
# here are :read, :create, :update and :destroy.
|
||||||
|
#
|
||||||
|
# The second argument is the resource the user can perform the action on.
|
||||||
|
# If you pass :all it will apply to every resource. Otherwise pass a Ruby
|
||||||
|
# class of the resource.
|
||||||
|
#
|
||||||
|
# The third argument is an optional hash of conditions to further filter the
|
||||||
|
# objects.
|
||||||
|
# For example, here the user can only update published articles.
|
||||||
|
#
|
||||||
|
# can :update, Article, :published => true
|
||||||
|
#
|
||||||
|
# See the wiki for details:
|
||||||
|
# https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,7 @@ class Registrar < ActiveRecord::Base
|
||||||
has_many :domains
|
has_many :domains
|
||||||
has_many :ns_sets
|
has_many :ns_sets
|
||||||
has_many :epp_users
|
has_many :epp_users
|
||||||
|
has_many :domain_transfers, foreign_key: 'transfer_to_id'
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
|
|
19
app/views/client/domain_transfers/new.haml
Normal file
19
app/views/client/domain_transfers/new.haml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
%h2= t('shared.transfer_domain')
|
||||||
|
%hr
|
||||||
|
= form_for([:client, @domain_transfer]) do |f|
|
||||||
|
= render 'shared/errors', object: @domain_transfer
|
||||||
|
- if @domain_transfer.errors.any?
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= label_tag :domain_name
|
||||||
|
= text_field_tag(:domain_name, params[:domain_name], class: 'form-control')
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= label_tag :domain_pw
|
||||||
|
= text_field_tag(:domain_pw, params[:domain_pw], class: 'form-control')
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
= button_tag(t('shared.save'), class: 'btn btn-primary', name: 'request')
|
32
app/views/client/domain_transfers/show.haml
Normal file
32
app/views/client/domain_transfers/show.haml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.domain_transfer')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t('shared.domain')
|
||||||
|
%dd= @domain_transfer.domain.name
|
||||||
|
|
||||||
|
%dt= t('shared.status')
|
||||||
|
%dd= @domain_transfer.status
|
||||||
|
|
||||||
|
%dt= t('shared.transfer_requested_at')
|
||||||
|
%dd= l(@domain_transfer.transfer_requested_at)
|
||||||
|
|
||||||
|
%dt= t('shared.transfer_from')
|
||||||
|
%dd= @domain_transfer.transfer_from
|
||||||
|
|
||||||
|
- if @domain_transfer.transferred_at
|
||||||
|
%dt= t('shared.transferred_at')
|
||||||
|
%dd= l(@domain_transfer.transferred_at)
|
||||||
|
- else
|
||||||
|
%dt= t('shared.transfer_confirm_time')
|
||||||
|
%dd= l(@domain_transfer.transfer_confirm_time)
|
||||||
|
|
||||||
|
%dt= t('shared.domain_valid_to')
|
||||||
|
%dd= l(@domain_transfer.domain.valid_to)
|
|
@ -3,6 +3,7 @@
|
||||||
%h2.text-center-xs= t('shared.domains')
|
%h2.text-center-xs= t('shared.domains')
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
%h2.text-right.text-center-xs
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.request_domain_transfer'), new_client_domain_transfer_path, class: 'btn btn-primary')
|
||||||
= link_to(t('shared.add'), new_client_domain_path, class: 'btn btn-primary')
|
= link_to(t('shared.add'), new_client_domain_path, class: 'btn btn-primary')
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
= "#{t('shared.domain_details')}"
|
= "#{t('shared.domain_details')}"
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
%h2.text-right.text-center-xs
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.transfer'), new_client_domain_domain_transfer_path(@domain), class: 'btn btn-primary')
|
||||||
= link_to(t('shared.edit'), edit_client_domain_path(@domain), class: 'btn btn-primary')
|
= link_to(t('shared.edit'), edit_client_domain_path(@domain), class: 'btn btn-primary')
|
||||||
= link_to(t('shared.delete'), client_domain_path(@domain), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger')
|
= link_to(t('shared.delete'), client_domain_path(@domain), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger')
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
= link_to t('shared.check'), '#'
|
= link_to t('shared.check'), '#'
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.register'), '#'
|
= link_to t('shared.register'), '#'
|
||||||
|
%li
|
||||||
|
= link_to 'Admin', '/'
|
||||||
%ul.nav.navbar-nav.navbar-right
|
%ul.nav.navbar-nav.navbar-right
|
||||||
%li= link_to t('shared.log_out'), '/logout'
|
%li= link_to t('shared.log_out'), '/logout'
|
||||||
/ /.nav-collapse
|
/ /.nav-collapse
|
||||||
|
|
|
@ -109,6 +109,13 @@ en:
|
||||||
domain:
|
domain:
|
||||||
<<: *epp_domain_ar_attributes
|
<<: *epp_domain_ar_attributes
|
||||||
|
|
||||||
|
domain_transfer:
|
||||||
|
attributes:
|
||||||
|
base:
|
||||||
|
transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar'
|
||||||
|
domain:
|
||||||
|
not_found: 'Domain was not found'
|
||||||
|
|
||||||
nameserver:
|
nameserver:
|
||||||
attributes:
|
attributes:
|
||||||
hostname:
|
hostname:
|
||||||
|
@ -272,4 +279,15 @@ en:
|
||||||
failed_to_update_setting: 'Failed to update setting'
|
failed_to_update_setting: 'Failed to update setting'
|
||||||
status: 'Status'
|
status: 'Status'
|
||||||
eedirekt: 'EEDirekt'
|
eedirekt: 'EEDirekt'
|
||||||
|
domain_transfer_requested: 'Domain transfer requested!'
|
||||||
|
other_registrar_has_already_requested_to_transfer_this_domain: 'Other registrar has already requested to transfer this domain.'
|
||||||
|
transfer: 'Transfer'
|
||||||
|
transfer_domain: 'Transfer domain'
|
||||||
|
failed_to_request_domain_transfer: 'Failed to request domain transfer'
|
||||||
|
domain_transfer: 'Domain transfer'
|
||||||
|
domain_valid_to: 'Domain valid to'
|
||||||
|
transfer_requested_at: 'Transfer requested at'
|
||||||
|
transfer_from: 'Transfer from'
|
||||||
|
transferred_at: 'Transferred at'
|
||||||
|
transfer_confirm_time: 'Transfer confirm time'
|
||||||
|
request_domain_transfer: 'Request domain transfer'
|
||||||
|
|
|
@ -23,6 +23,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
namespace(:client) do
|
namespace(:client) do
|
||||||
resources :domains
|
resources :domains
|
||||||
|
resources :domain_transfers
|
||||||
|
|
||||||
resources :contacts do
|
resources :contacts do
|
||||||
collection do
|
collection do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue