Merge branch 'master' into registry-569

# Conflicts:
#	app/controllers/admin/contacts_controller.rb
This commit is contained in:
Artur Beljajev 2017-09-11 17:09:58 +03:00
commit e4740f3f32
40 changed files with 1287 additions and 1236 deletions

View file

@ -1,4 +1,5 @@
class Admin::AccountActivitiesController < AdminController
module Admin
class AccountActivitiesController < BaseController
load_and_authorize_resource
before_action :set_default_dates, only: [:index]
@ -58,3 +59,4 @@ class Admin::AccountActivitiesController < AdminController
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::AdminUsersController < AdminController
module Admin
class AdminUsersController < BaseController
load_and_authorize_resource
before_action :set_user, only: [:show, :edit, :update, :destroy]
@ -11,9 +12,11 @@ class Admin::AdminUsersController < AdminController
@admin_user = AdminUser.new
end
def show; end
def show;
end
def edit; end
def edit;
end
def create
@admin_user = AdminUser.new(admin_user_params)
@ -61,3 +64,4 @@ class Admin::AdminUsersController < AdminController
:password, :password_confirmation, :identity_code, :email, :country_code, { roles: [] })
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ApiUsersController < AdminController
module Admin
class ApiUsersController < BaseController
load_and_authorize_resource
before_action :set_api_user, only: [:show, :edit, :update, :destroy]
@ -24,9 +25,11 @@ class Admin::ApiUsersController < AdminController
end
end
def show; end
def show;
end
def edit; end
def edit;
end
def update
params[:api_user].delete(:password) if params[:api_user][:password].blank?
@ -61,3 +64,4 @@ class Admin::ApiUsersController < AdminController
:identity_code, { roles: [] })
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::BankStatementsController < AdminController
module Admin
class BankStatementsController < BaseController
load_and_authorize_resource
before_action :set_bank_statement, only: [:show, :download_import_file, :bind_invoices]
@ -85,3 +86,4 @@ class Admin::BankStatementsController < AdminController
])
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::BankTransactionsController < AdminController
module Admin
class BankTransactionsController < BaseController
load_and_authorize_resource
def new
@ -52,3 +53,4 @@ class Admin::BankTransactionsController < AdminController
)
end
end
end

View file

@ -0,0 +1,10 @@
module Admin
class BaseController < ApplicationController
before_action :authenticate_user!
helper_method :head_title_sufix
def head_title_sufix
t(:admin_head_title_sufix)
end
end
end

View file

@ -1,6 +1,6 @@
module Admin
module Billing
class PricesController < AdminController
class PricesController < BaseController
authorize_resource(class: 'Billing::Price')
before_action :load_price, only: %i[edit update expire]
helper_method :zones

View file

@ -1,4 +1,5 @@
class Admin::BlockedDomainsController < AdminController
module Admin
class BlockedDomainsController < BaseController
load_and_authorize_resource
def index
@ -53,3 +54,4 @@ class Admin::BlockedDomainsController < AdminController
@domain = BlockedDomain.find(params[:id])
end
end
end

View file

@ -1,8 +1,10 @@
class Admin::CertificatesController < AdminController
module Admin
class CertificatesController < BaseController
load_and_authorize_resource
before_action :set_certificate, :set_api_user, only: [:sign, :show, :download_csr, :download_crt, :revoke, :destroy]
def show; end
def show;
end
def new
@api_user = ApiUser.find(params[:api_user_id])
@ -82,3 +84,4 @@ class Admin::CertificatesController < AdminController
end
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ContactVersionsController < AdminController
module Admin
class ContactVersionsController < BaseController
load_and_authorize_resource
def index
@ -52,5 +53,5 @@ class Admin::ContactVersionsController < AdminController
def create_where_string(key, value)
" AND object->>'#{key}' ~* '#{value}'"
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ContactsController < AdminController
module Admin
class ContactsController < BaseController
load_and_authorize_resource
before_action :set_contact, only: [:show]
helper_method :ident_types
@ -84,3 +85,4 @@ class Admin::ContactsController < AdminController
Contact::Ident.types
end
end
end

View file

@ -1,7 +1,9 @@
class Admin::DashboardsController < AdminController
module Admin
class DashboardsController < BaseController
authorize_resource class: false
def show
redirect_to [:admin, :domains] if can? :show, Domain
end
end
end

View file

@ -1,7 +1,9 @@
class Admin::DelayedJobsController < AdminController
module Admin
class DelayedJobsController < BaseController
authorize_resource class: false
def index
@jobs = Delayed::Job.all
end
end
end

View file

@ -1,6 +1,6 @@
module Admin
module DNS
class ZonesController < AdminController
class ZonesController < BaseController
authorize_resource(class: 'DNS::Zone')
before_action :load_zone, only: %i[edit update destroy]

View file

@ -1,4 +1,5 @@
class Admin::DomainVersionsController < AdminController
module Admin
class DomainVersionsController < BaseController
load_and_authorize_resource
def index
@ -70,6 +71,5 @@ class Admin::DomainVersionsController < AdminController
def create_where_string(key, value)
" AND object->>'#{key}' ~* '#{value}'"
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::DomainsController < AdminController
module Admin
class DomainsController < BaseController
load_and_authorize_resource
before_action :set_domain, only: [:show, :edit, :update, :zonefile]
helper_method :force_delete_templates
@ -33,6 +34,7 @@ class Admin::DomainsController < AdminController
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/AbcSize
@ -131,3 +133,4 @@ class Admin::DomainsController < AdminController
%w(removed_company death)
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::EppLogsController < AdminController
module Admin
class EppLogsController < BaseController
load_and_authorize_resource class: ApiLog::EppLog
before_action :set_default_dates, only: [:index]
@ -31,3 +32,4 @@ class Admin::EppLogsController < AdminController
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::InvoicesController < AdminController
module Admin
class InvoicesController < BaseController
load_and_authorize_resource
before_action :set_invoice, only: [:forward, :download_pdf]
@ -71,3 +72,4 @@ class Admin::InvoicesController < AdminController
@invoice = Invoice.find(params[:invoice_id])
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::KeyrelaysController < AdminController
module Admin
class KeyrelaysController < BaseController
load_and_authorize_resource
def index
@ -6,5 +7,7 @@ class Admin::KeyrelaysController < AdminController
@keyrelays = @q.result.page(params[:page])
end
def show; end
def show;
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::LegalDocumentsController < AdminController
module Admin
class LegalDocumentsController < BaseController
load_and_authorize_resource
def show
@ -7,3 +8,4 @@ class Admin::LegalDocumentsController < AdminController
send_data File.open(@ld.path).read, filename: filename
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::MailTemplatesController < AdminController
module Admin
class MailTemplatesController < BaseController
load_and_authorize_resource
def index
@ -59,3 +60,4 @@ class Admin::MailTemplatesController < AdminController
params.require(:mail_template).permit(:name, :subject, :from, :bcc, :cc, :body, :text_body)
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::PendingDeletesController < AdminController
module Admin
class PendingDeletesController < BaseController
before_action :find_domain
before_action :check_status
@ -40,3 +41,4 @@ class Admin::PendingDeletesController < AdminController
return redirect_to admin_domain_path(@domain.id), alert: t(:something_wrong) unless @domain.pending_delete?
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::PendingUpdatesController < AdminController
module Admin
class PendingUpdatesController < BaseController
before_action :find_domain
before_action :check_status
@ -39,3 +40,4 @@ class Admin::PendingUpdatesController < AdminController
return redirect_to admin_domain_path(@domain.id), alert: t(:something_wrong) unless @domain.pending_update?
end
end
end

View file

@ -1,6 +1,8 @@
class Admin::RegistrarsController < AdminController
module Admin
class RegistrarsController < BaseController
load_and_authorize_resource
before_action :set_registrar, only: [:show, :edit, :update, :destroy]
def search
render json: Registrar.search_by_query(params[:q])
end
@ -31,7 +33,8 @@ class Admin::RegistrarsController < AdminController
end
end
def edit; end
def edit;
end
def update
if @registrar.update(registrar_params)
@ -66,3 +69,4 @@ class Admin::RegistrarsController < AdminController
)
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ReppLogsController < AdminController
module Admin
class ReppLogsController < BaseController
load_and_authorize_resource class: ApiLog::ReppLog
before_action :set_default_dates, only: [:index]
@ -32,3 +33,4 @@ class Admin::ReppLogsController < AdminController
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ReservedDomainsController < AdminController
module Admin
class ReservedDomainsController < BaseController
load_and_authorize_resource
before_action :set_domain, only: [:edit, :update]
@ -66,3 +67,4 @@ class Admin::ReservedDomainsController < AdminController
@domain = ReservedDomain.find(params[:id])
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::SessionsController < Devise::SessionsController
module Admin
class SessionsController < Devise::SessionsController
skip_authorization_check only: :create
def login
@ -24,3 +25,4 @@ class Admin::SessionsController < Devise::SessionsController
end
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::SettingsController < AdminController
module Admin
class SettingsController < BaseController
load_and_authorize_resource
before_action :set_setting_group, only: [:show, :update]
@ -21,7 +22,8 @@ class Admin::SettingsController < AdminController
end
end
def show; end
def show;
end
def update
if @setting_group.update(setting_group_params)
@ -93,3 +95,4 @@ class Admin::SettingsController < AdminController
settings
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::WhiteIpsController < AdminController
module Admin
class WhiteIpsController < BaseController
load_and_authorize_resource
before_action :set_registrar, only: [:new, :show, :edit, :destroy, :update]
@ -7,9 +8,11 @@ class Admin::WhiteIpsController < AdminController
@white_ip = WhiteIp.new(registrar: @registrar)
end
def show; end
def show;
end
def edit; end
def edit;
end
def destroy
if @white_ip.destroy
@ -54,3 +57,4 @@ class Admin::WhiteIpsController < AdminController
params.require(:white_ip).permit(:ipv4, :ipv6, :registrar_id, { interfaces: [] })
end
end
end

View file

@ -1,4 +1,5 @@
class Admin::ZonefilesController < ApplicationController
module Admin
class ZonefilesController < BaseController
authorize_resource class: false
# TODO: Refactor this
@ -16,3 +17,4 @@ class Admin::ZonefilesController < ApplicationController
end
end
end
end

View file

@ -1,8 +0,0 @@
class AdminController < ApplicationController
before_action :authenticate_user!
helper_method :head_title_sufix
def head_title_sufix
t(:admin_head_title_sufix)
end
end

View file

@ -1,5 +1,6 @@
en:
admin:
base:
menu:
users: Users
api_users: API users

View file

@ -52,11 +52,6 @@
<ellipse fill="none" stroke="black" cx="532" cy="-462" rx="87.9851" ry="18"/>
<text text-anchor="middle" x="532" y="-458.3" font-family="Times,serif" font-size="14.00">Epp::ErrorsController</text>
</g>
<!-- AdminController -->
<g id="node9" class="node"><title>AdminController</title>
<ellipse fill="none" stroke="black" cx="-361" cy="66" rx="71.4873" ry="18"/>
<text text-anchor="middle" x="-361" y="69.7" font-family="Times,serif" font-size="14.00">AdminController</text>
</g>
<!-- RegistrarController -->
<g id="node10" class="node"><title>RegistrarController</title>
<ellipse fill="none" stroke="black" cx="-173" cy="-462" rx="79.0865" ry="18"/>

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

@ -131,16 +131,6 @@
<polyline fill="none" stroke="black" points="740.5,56 875.5,56 "/>
<text text-anchor="start" x="748.5" y="71.2" font-family="Times,serif" font-size="14.00">_layout</text>
</g>
<!-- AdminController -->
<g id="node9" class="node"><title>AdminController</title>
<path fill="none" stroke="black" d="M152,239.5C152,239.5 238,239.5 238,239.5 244,239.5 250,233.5 250,227.5 250,227.5 250,158.5 250,158.5 250,152.5 244,146.5 238,146.5 238,146.5 152,146.5 152,146.5 146,146.5 140,152.5 140,158.5 140,158.5 140,227.5 140,227.5 140,233.5 146,239.5 152,239.5"/>
<text text-anchor="middle" x="195" y="161.7" font-family="Times,serif" font-size="14.00">AdminController</text>
<polyline fill="none" stroke="black" points="140,169.5 250,169.5 "/>
<text text-anchor="start" x="148" y="184.7" font-family="Times,serif" font-size="14.00">head_title_sufix</text>
<polyline fill="none" stroke="black" points="140,192.5 250,192.5 "/>
<polyline fill="none" stroke="black" points="140,216.5 250,216.5 "/>
<text text-anchor="start" x="148" y="231.7" font-family="Times,serif" font-size="14.00">_layout</text>
</g>
<!-- RegistrarController -->
<g id="node10" class="node"><title>RegistrarController</title>
<path fill="none" stroke="black" d="M-708,539.5C-708,539.5 -610,539.5 -610,539.5 -604,539.5 -598,533.5 -598,527.5 -598,527.5 -598,428.5 -598,428.5 -598,422.5 -604,416.5 -610,416.5 -610,416.5 -708,416.5 -708,416.5 -714,416.5 -720,422.5 -720,428.5 -720,428.5 -720,527.5 -720,527.5 -720,533.5 -714,539.5 -708,539.5"/>

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Before After
Before After

View file

@ -17,7 +17,7 @@ RSpec.feature 'New price in admin area', settings: false do
end
def open_list
click_link_or_button t('admin.menu.prices')
click_link_or_button t('admin.base.menu.prices')
end
def open_form

View file

@ -16,7 +16,7 @@ RSpec.feature 'Editing zone in admin area', settings: false do
end
def open_list
click_link_or_button t('admin.menu.zones')
click_link_or_button t('admin.base.menu.zones')
end
def open_form

View file

@ -15,7 +15,7 @@ RSpec.feature 'New zone in admin area', settings: false do
end
def open_list
click_link_or_button t('admin.menu.zones')
click_link_or_button t('admin.base.menu.zones')
end
def open_form