mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 20:19:34 +02:00
Merge branch 'change-registrar-area-controller-hierarchy' into registry-475-refactor-zones
This commit is contained in:
commit
ed8a4bed66
21 changed files with 883 additions and 825 deletions
|
@ -1,4 +1,5 @@
|
|||
class Registrar::AccountActivitiesController < RegistrarController
|
||||
class Registrar
|
||||
class AccountActivitiesController < BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index # rubocop: disable Metrics/AbcSize
|
||||
|
@ -25,4 +26,5 @@ class Registrar::AccountActivitiesController < RegistrarController
|
|||
|
||||
params[:q][:created_at_lteq] = ca_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
40
app/controllers/registrar/base_controller.rb
Normal file
40
app/controllers/registrar/base_controller.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
class Registrar
|
||||
class BaseController < ApplicationController
|
||||
before_action :authenticate_user!, :check_ip
|
||||
|
||||
include Registrar::ApplicationHelper
|
||||
|
||||
helper_method :depp_controller?
|
||||
|
||||
def depp_controller?
|
||||
false
|
||||
end
|
||||
|
||||
def check_ip
|
||||
return unless current_user
|
||||
unless current_user.is_a? ApiUser
|
||||
sign_out(current_user)
|
||||
return
|
||||
end
|
||||
return if Rails.env.development?
|
||||
registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip)
|
||||
|
||||
return if registrar_ip_whitelisted
|
||||
flash[:alert] = t('ip_is_not_whitelisted')
|
||||
sign_out(current_user)
|
||||
redirect_to registrar_login_path and return
|
||||
end
|
||||
|
||||
helper_method :head_title_sufix
|
||||
|
||||
def head_title_sufix
|
||||
t(:registrar_head_title_sufix)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::ContactsController < Registrar::DeppController # EPP controller
|
||||
class Registrar
|
||||
class ContactsController < DeppController
|
||||
before_action :init_epp_contact
|
||||
helper_method :address_processing?
|
||||
|
||||
|
@ -139,4 +140,5 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
|
|||
def address_processing?
|
||||
Contact.address_processing?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::DashboardController < RegistrarController
|
||||
class Registrar
|
||||
class DashboardController < BaseController
|
||||
authorize_resource class: false
|
||||
|
||||
def show
|
||||
|
@ -8,4 +9,5 @@ class Registrar::DashboardController < RegistrarController
|
|||
redirect_to registrar_invoices_url and return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::DepositsController < RegistrarController
|
||||
class Registrar
|
||||
class DepositsController < BaseController
|
||||
authorize_resource class: false
|
||||
|
||||
def new
|
||||
|
@ -23,4 +24,5 @@ class Registrar::DepositsController < RegistrarController
|
|||
def deposit_params
|
||||
params.require(:deposit).permit(:amount, :description)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::DeppController < RegistrarController # EPP controller
|
||||
class Registrar
|
||||
class DeppController < BaseController
|
||||
helper_method :depp_current_user
|
||||
|
||||
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |exception|
|
||||
|
@ -8,6 +9,7 @@ class Registrar::DeppController < RegistrarController # EPP controller
|
|||
end
|
||||
|
||||
before_action :authenticate_user
|
||||
|
||||
def authenticate_user
|
||||
redirect_to registrar_login_url and return unless depp_current_user
|
||||
end
|
||||
|
@ -31,4 +33,5 @@ class Registrar::DeppController < RegistrarController # EPP controller
|
|||
end
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
||||
class Registrar
|
||||
class DomainsController < DeppController
|
||||
before_action :init_domain, except: :new
|
||||
helper_method :contacts
|
||||
|
||||
|
@ -55,6 +56,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
@ -161,7 +163,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
|||
scope = scope.where("name ilike '%#{escaped_str}%' OR code ilike '%#{escaped_str}%' ")
|
||||
end
|
||||
|
||||
render json: scope.pluck(:name, :code).map { |c| {display_key: "#{c.second} #{c.first}", value: c.second} }
|
||||
render json: scope.pluck(:name, :code).map { |c| { display_key: "#{c.second} #{c.first}", value: c.second } }
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -188,4 +190,5 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
|||
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::InvoicesController < RegistrarController
|
||||
class Registrar
|
||||
class InvoicesController < BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
before_action :set_invoice, only: [:show, :forward, :download_pdf]
|
||||
|
@ -14,7 +15,8 @@ class Registrar::InvoicesController < RegistrarController
|
|||
end
|
||||
end
|
||||
|
||||
def show; end
|
||||
def show;
|
||||
end
|
||||
|
||||
def forward
|
||||
@invoice.billing_email = @invoice.buyer.billing_email
|
||||
|
@ -68,4 +70,5 @@ class Registrar::InvoicesController < RegistrarController
|
|||
|
||||
params[:q][:due_date_lteq] = ca_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::KeyrelaysController < Registrar::DeppController # EPP controller
|
||||
class Registrar
|
||||
class KeyrelaysController < DeppController
|
||||
def show
|
||||
authorize! :view, Depp::Keyrelay
|
||||
end
|
||||
|
@ -15,4 +16,5 @@ class Registrar::KeyrelaysController < Registrar::DeppController # EPP controlle
|
|||
render 'show'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::PaymentsController < RegistrarController
|
||||
class Registrar
|
||||
class PaymentsController < BaseController
|
||||
protect_from_forgery except: :back
|
||||
|
||||
skip_authorization_check # actually anyone can pay, no problems at all
|
||||
|
@ -35,6 +36,7 @@ class Registrar::PaymentsController < RegistrarController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def banks
|
||||
ENV['payments_banks'].split(",").map(&:strip)
|
||||
end
|
||||
|
@ -42,5 +44,5 @@ class Registrar::PaymentsController < RegistrarController
|
|||
def check_bank
|
||||
raise StandardError.new("Not Implemented bank") unless banks.include?(params[:bank])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
class Registrar::PollsController < Registrar::DeppController # EPP controller
|
||||
class Registrar
|
||||
class PollsController < DeppController
|
||||
authorize_resource class: false
|
||||
before_action :init_epp_xml
|
||||
|
||||
def show
|
||||
if Rails.env.test? # Stub for depp server request
|
||||
@data = Object.new
|
||||
def @data.css(key); []; end
|
||||
|
||||
def @data.css(key)
|
||||
; [];
|
||||
end
|
||||
else
|
||||
@data = depp_current_user.request(@ex.poll)
|
||||
end
|
||||
|
@ -53,4 +57,5 @@ class Registrar::PollsController < Registrar::DeppController # EPP controller
|
|||
@ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
|
||||
@domain = Depp::Domain.new(current_user: depp_current_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Registrar::SessionsController < Devise::SessionsController
|
||||
layout 'registrar/application'
|
||||
class Registrar
|
||||
class SessionsController < Devise::SessionsController
|
||||
helper_method :depp_controller?
|
||||
|
||||
def depp_controller?
|
||||
false
|
||||
end
|
||||
|
@ -59,6 +60,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
render 'login'
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
|
@ -76,6 +78,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
|
||||
redirect_to registrar_root_url
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
|
||||
|
@ -128,6 +131,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:no_such_user) }, status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
|
@ -169,6 +173,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:internal_error) }, status: :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
@ -185,4 +190,5 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
return if WhiteIp.registrar_ip_white?(request.ip)
|
||||
render text: t('access_denied') and return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Registrar::XmlConsolesController < Registrar::DeppController # EPP controller
|
||||
class Registrar
|
||||
class XmlConsolesController < DeppController
|
||||
authorize_resource class: false
|
||||
|
||||
def show
|
||||
|
@ -20,4 +21,5 @@ class Registrar::XmlConsolesController < Registrar::DeppController # EPP control
|
|||
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
|
||||
render text: xml
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
class RegistrarController < ApplicationController
|
||||
before_action :authenticate_user!, :check_ip
|
||||
layout 'registrar/application'
|
||||
|
||||
include Registrar::ApplicationHelper
|
||||
|
||||
helper_method :depp_controller?
|
||||
def depp_controller?
|
||||
false
|
||||
end
|
||||
|
||||
def check_ip
|
||||
return unless current_user
|
||||
unless current_user.is_a? ApiUser
|
||||
sign_out(current_user)
|
||||
return
|
||||
end
|
||||
return if Rails.env.development?
|
||||
registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip)
|
||||
|
||||
return if registrar_ip_whitelisted
|
||||
flash[:alert] = t('ip_is_not_whitelisted')
|
||||
sign_out(current_user)
|
||||
redirect_to registrar_login_path and return
|
||||
end
|
||||
|
||||
helper_method :head_title_sufix
|
||||
def head_title_sufix
|
||||
t(:registrar_head_title_sufix)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
||||
end
|
||||
end
|
|
@ -1,75 +0,0 @@
|
|||
!!! 5
|
||||
%html{lang: I18n.locale.to_s}
|
||||
%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"}/
|
||||
- if content_for? :head_title
|
||||
= yield :head_title
|
||||
- else
|
||||
%title= t(:registrar_head_title)
|
||||
= csrf_meta_tags
|
||||
= stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true
|
||||
= javascript_include_tag 'registrar-manifest', 'data-turbolinks-track' => true
|
||||
= favicon_link_tag 'favicon.ico'
|
||||
%body
|
||||
/ Fixed navbar
|
||||
%nav.navbar.navbar-default.navbar-fixed-top
|
||||
.container
|
||||
.navbar-header
|
||||
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
|
||||
%span.sr-only Toggle navigation
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
= link_to main_app.registrar_root_path, class: 'navbar-brand' do
|
||||
= t(:registrar_head_title)
|
||||
- if unstable_env.present?
|
||||
.text-center
|
||||
%small{style: 'color: #0074B3;'}= unstable_env
|
||||
- if current_user
|
||||
.navbar-collapse.collapse
|
||||
%ul.nav.navbar-nav.public-nav
|
||||
- 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(:billing), registrar_invoices_path
|
||||
|
||||
- if !Rails.env.production? && can?(:manage, :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.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
= "#{current_user} (#{current_user.roles.first}) - #{current_user.registrar}"
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
- ApiUser.all_by_identity_code(current_user.identity_code).each do |x|
|
||||
%li= link_to "#{x} (#{x.roles.first}) - #{x.registrar}", "/registrar/switch_user/#{x.id}"
|
||||
- if user_signed_in?
|
||||
%li= link_to t(:log_out_), '/registrar/logout'
|
||||
|
||||
.container
|
||||
= render 'shared/flash'
|
||||
- if depp_controller?
|
||||
= render 'registrar/shared/epp_results'
|
||||
= yield
|
||||
|
||||
%footer.footer
|
||||
.container
|
||||
%row
|
||||
.col-md-6
|
||||
= image_tag 'eis-logo-et.png'
|
||||
.col-md-6.text-right
|
||||
Version
|
||||
= CURRENT_COMMIT_HASH
|
48
app/views/layouts/registrar/base.haml
Normal file
48
app/views/layouts/registrar/base.haml
Normal file
|
@ -0,0 +1,48 @@
|
|||
!!! 5
|
||||
%html{lang: I18n.locale.to_s}
|
||||
%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"}/
|
||||
- if content_for? :head_title
|
||||
= yield :head_title
|
||||
- else
|
||||
%title= t(:registrar_head_title)
|
||||
= csrf_meta_tags
|
||||
= stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true
|
||||
= javascript_include_tag 'registrar-manifest', 'data-turbolinks-track' => true
|
||||
= favicon_link_tag 'favicon.ico'
|
||||
%body
|
||||
/ Fixed navbar
|
||||
%nav.navbar.navbar-default.navbar-fixed-top
|
||||
.container
|
||||
.navbar-header
|
||||
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
|
||||
%span.sr-only Toggle navigation
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
%span.icon-bar
|
||||
= link_to main_app.registrar_root_path, class: 'navbar-brand' do
|
||||
= t(:registrar_head_title)
|
||||
- if unstable_env.present?
|
||||
.text-center
|
||||
%small{style: 'color: #0074B3;'}= unstable_env
|
||||
- if current_user
|
||||
= render 'navbar'
|
||||
|
||||
.container
|
||||
= render 'shared/flash'
|
||||
- if depp_controller?
|
||||
= render 'registrar/shared/epp_results'
|
||||
= yield
|
||||
|
||||
%footer.footer
|
||||
.container
|
||||
%row
|
||||
.col-md-6
|
||||
= image_tag 'eis-logo-et.png'
|
||||
.col-md-6.text-right
|
||||
Version
|
||||
= CURRENT_COMMIT_HASH
|
11
app/views/registrar/base/_form_errors.html.erb
Normal file
11
app/views/registrar/base/_form_errors.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<% if target.errors.any? %>
|
||||
<div class="alert alert-danger">
|
||||
<p><%= pluralize(target.errors.count, 'error') %> prohibited this <%= target.model_name.human.downcase %> from being saved:</p>
|
||||
|
||||
<ul>
|
||||
<% target.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
28
app/views/registrar/base/_navbar.haml
Normal file
28
app/views/registrar/base/_navbar.haml
Normal file
|
@ -0,0 +1,28 @@
|
|||
.navbar-collapse.collapse
|
||||
%ul.nav.navbar-nav.public-nav
|
||||
- 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(:billing), registrar_invoices_path
|
||||
|
||||
- if !Rails.env.production? && can?(:manage, :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.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
= "#{current_user} (#{current_user.roles.first}) - #{current_user.registrar}"
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
- ApiUser.all_by_identity_code(current_user.identity_code).each do |x|
|
||||
%li= link_to "#{x} (#{x.roles.first}) - #{x.registrar}", "/registrar/switch_user/#{x.id}"
|
||||
- if user_signed_in?
|
||||
%li= link_to t(:log_out_), '/registrar/logout'
|
|
@ -25,7 +25,7 @@
|
|||
%dt= t(:payment_term)
|
||||
%dd= t(@invoice.payment_term)
|
||||
|
||||
%dt= t(:"invoice no")
|
||||
%dt= t(:invoice_number)
|
||||
%dd= @invoice.number
|
||||
|
||||
- if @invoice.description.present?
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
%dt= t(:payment_term)
|
||||
%dd= t(@invoice.payment_term)
|
||||
|
||||
%dt= t(:"invoice no")
|
||||
%dt= t(:invoice_number)
|
||||
%dd= @invoice.number
|
||||
|
||||
- if @invoice.description.present?
|
||||
|
|
|
@ -666,6 +666,7 @@ en:
|
|||
amount: 'Amount'
|
||||
please_pay_the_following_invoice: 'Please pay the following invoice'
|
||||
invoice_no: 'Invoice no. %{no}'
|
||||
invoice_number: Invoice no.
|
||||
seller: 'Seller'
|
||||
prepayment: 'Prepayment'
|
||||
vat: 'VAT (%{vat_prc}%)'
|
||||
|
@ -934,3 +935,11 @@ en:
|
|||
cant_match_version: 'Impossible match version with request'
|
||||
user_not_authenticated: "user not authenticated"
|
||||
actions: Actions
|
||||
|
||||
number:
|
||||
currency:
|
||||
format:
|
||||
format: "%n %u"
|
||||
delimiter: " "
|
||||
precision: 2
|
||||
unit: €
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue