mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Pass registrar in URL instead of POST params
This commit is contained in:
parent
044bf9caad
commit
3c5c0c4310
5 changed files with 10 additions and 35 deletions
|
@ -47,12 +47,6 @@ class @Autocomplete
|
|||
selector: '.js-contact-typeahead'
|
||||
hiddenSelector: '.js-contact-id'
|
||||
|
||||
@bindAdminRegistrarSearch: ->
|
||||
Autocomplete.bindTypeahead
|
||||
remote: '/admin/registrars/search'
|
||||
selector: '.js-registrar-typeahead'
|
||||
hiddenSelector: '.js-registrar-id'
|
||||
|
||||
@bindClientContactSearch: ->
|
||||
Autocomplete.bindTypeahead
|
||||
remote: '/client/contacts/search'
|
||||
|
|
|
@ -2,6 +2,7 @@ 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])
|
||||
|
@ -9,12 +10,11 @@ module Admin
|
|||
end
|
||||
|
||||
def new
|
||||
@registrar = Registrar.find_by(id: params[:registrar_id])
|
||||
@api_user = ApiUser.new(registrar: @registrar)
|
||||
@api_user = ApiUser.new
|
||||
end
|
||||
|
||||
def create
|
||||
@api_user = ApiUser.new(api_user_params)
|
||||
@api_user = @registrar.api_users.build(api_user_params)
|
||||
|
||||
if @api_user.save
|
||||
flash[:notice] = I18n.t('record_created')
|
||||
|
@ -63,8 +63,11 @@ module Admin
|
|||
|
||||
def api_user_params
|
||||
params.require(:api_user).permit(:username, :plain_text_password, :active,
|
||||
:registrar_id, :registrar_typeahead,
|
||||
:identity_code, { roles: [] })
|
||||
end
|
||||
|
||||
def find_registrar
|
||||
@registrar = Registrar.find(params[:registrar_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,6 @@ class ApiUser < User
|
|||
delegate :code, :name, to: :registrar, prefix: true
|
||||
|
||||
alias_attribute :login, :username
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
SUPER = 'super'
|
||||
EPP = 'epp'
|
||||
|
@ -53,10 +52,6 @@ class ApiUser < User
|
|||
end
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form_for([:admin, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f|
|
||||
= form_for([:admin, @registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f|
|
||||
= render 'shared/full_errors', object: @api_user
|
||||
|
||||
.row
|
||||
|
@ -20,18 +20,6 @@
|
|||
.col-md-7
|
||||
= f.text_field(:identity_code, class: 'form-control')
|
||||
|
||||
.form-group
|
||||
.form-group.has-feedback.js-typeahead-container
|
||||
.col-md-4.control-label
|
||||
= f.label :registrar_typeahead, t(:registrar_name), class: 'required'
|
||||
.col-md-7
|
||||
= f.text_field(:registrar_typeahead,
|
||||
class: 'form-control js-registrar-typeahead typeahead required',
|
||||
placeholder: t(:registrar_name), autocomplete: 'off')
|
||||
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
||||
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
||||
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :role, nil, class: 'required'
|
||||
|
@ -49,8 +37,3 @@
|
|||
.row
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
||||
|
||||
:javascript
|
||||
window.addEventListener('load', function() {
|
||||
Autocomplete.bindAdminRegistrarSearch();
|
||||
});
|
||||
|
|
|
@ -259,7 +259,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :registrars do
|
||||
resources :api_users, except: %i[create show edit update destroy]
|
||||
resources :api_users, except: %i[show edit update destroy]
|
||||
resources :white_ips
|
||||
end
|
||||
|
||||
|
@ -270,7 +270,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :admin_users
|
||||
resources :api_users, except: %i[new] do
|
||||
resources :api_users, except: %i[new create] do
|
||||
resources :certificates do
|
||||
member do
|
||||
post 'sign'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue