mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Use BaseController in admin
This commit is contained in:
parent
cee4c84edd
commit
a63b989cd6
36 changed files with 1265 additions and 1215 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
10
app/controllers/admin/base_controller.rb
Normal file
10
app/controllers/admin/base_controller.rb
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Admin::ContactsController < AdminController
|
||||
module Admin
|
||||
class ContactsController < BaseController
|
||||
load_and_authorize_resource
|
||||
before_action :set_contact, only: [:show]
|
||||
|
||||
|
@ -79,3 +80,4 @@ class Admin::ContactsController < AdminController
|
|||
params[:q][:created_at_lteq] = ca_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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 |
|
@ -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 |
Loading…
Add table
Add a link
Reference in a new issue