mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
Nest API users under registrar in admin area
This commit is contained in:
parent
c680b688e4
commit
de6934625c
10 changed files with 65 additions and 62 deletions
|
@ -2,7 +2,6 @@ module Admin
|
|||
class ApiUsersController < BaseController
|
||||
load_and_authorize_resource
|
||||
before_action :set_api_user, only: [:show, :edit, :update, :destroy]
|
||||
before_action :find_registrar, only: %i[new create]
|
||||
|
||||
def index
|
||||
@q = ApiUser.includes(:registrar).search(params[:q])
|
||||
|
@ -10,15 +9,15 @@ module Admin
|
|||
end
|
||||
|
||||
def new
|
||||
@api_user = ApiUser.new
|
||||
@api_user = registrar.api_users.build
|
||||
end
|
||||
|
||||
def create
|
||||
@api_user = @registrar.api_users.build(api_user_params)
|
||||
@api_user = registrar.api_users.build(api_user_params)
|
||||
|
||||
if @api_user.save
|
||||
flash[:notice] = I18n.t('record_created')
|
||||
redirect_to [:admin, @api_user]
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||
render 'new'
|
||||
|
@ -38,7 +37,7 @@ module Admin
|
|||
|
||||
if @api_user.update(api_user_params)
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to [:admin, @api_user]
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render 'edit'
|
||||
|
@ -48,7 +47,7 @@ module Admin
|
|||
def destroy
|
||||
if @api_user.destroy
|
||||
flash[:notice] = I18n.t('record_deleted')
|
||||
redirect_to admin_api_users_path
|
||||
redirect_to admin_registrar_path(@api_user.registrar)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_record')
|
||||
render 'show'
|
||||
|
@ -66,8 +65,8 @@ module Admin
|
|||
:identity_code, { roles: [] })
|
||||
end
|
||||
|
||||
def find_registrar
|
||||
@registrar = Registrar.find(params[:registrar_id])
|
||||
def registrar
|
||||
Registrar.find(params[:registrar_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ module Admin
|
|||
|
||||
if @certificate.destroy
|
||||
flash[:notice] = I18n.t('record_deleted')
|
||||
redirect_to admin_api_user_path(@api_user)
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_record')
|
||||
render 'show'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form_for([:admin, @registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f|
|
||||
= form_for([:admin, @api_user.registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f|
|
||||
= render 'shared/full_errors', object: @api_user
|
||||
|
||||
.row
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:back_to_api_user), [:admin, @api_user], class: 'btn btn-default')
|
||||
= link_to(t(:back_to_api_user), admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default')
|
||||
= render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}"
|
||||
|
||||
= render 'form'
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
%tbody
|
||||
- @api_users.each do |api_user|
|
||||
%tr
|
||||
%td= link_to api_user, [:admin, api_user]
|
||||
%td= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user)
|
||||
%td= link_to api_user.registrar, [:admin, api_user.registrar]
|
||||
%td= api_user.active
|
||||
.row
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:edit), edit_admin_api_user_path(@api_user), class: 'btn btn-default')
|
||||
= link_to(t(:delete), admin_api_user_path(@api_user),
|
||||
= link_to(t(:edit), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default')
|
||||
= link_to(t(:delete), admin_registrar_api_user_path(@api_user.registrar, @api_user),
|
||||
method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger')
|
||||
= render 'shared/title', name: @api_user.username
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:api_user)
|
||||
%dd= link_to(@certificate.api_user, [:admin, @api_user])
|
||||
%dd= link_to(@certificate.api_user, [:admin, @api_user.registrar, @api_user])
|
||||
|
||||
%dt= t(:common_name)
|
||||
%dd= @certificate.common_name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue