mirror of
https://github.com/internetee/registry.git
synced 2025-07-12 05:58:23 +02:00
Add form to epp users
This commit is contained in:
parent
0504ca7ca4
commit
ba775f4e73
10 changed files with 196 additions and 3 deletions
58
app/controllers/admin/epp_users_controller.rb
Normal file
58
app/controllers/admin/epp_users_controller.rb
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
class Admin::EppUsersController < AdminController
|
||||||
|
before_action :set_epp_user, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@q = EppUser.search(params[:q])
|
||||||
|
@epp_users = @q.result.page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@epp_user = EppUser.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@epp_user = EppUser.new(epp_user_params)
|
||||||
|
|
||||||
|
if @epp_user.save
|
||||||
|
flash[:notice] = I18n.t('shared.record_created')
|
||||||
|
redirect_to [:admin, @epp_user]
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('shared.failed_to_create_record')
|
||||||
|
render 'new'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show; end
|
||||||
|
|
||||||
|
def edit; end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @epp_user.update(epp_user_params)
|
||||||
|
flash[:notice] = I18n.t('shared.record_updated')
|
||||||
|
redirect_to [:admin, @epp_user]
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('shared.failed_to_update_record')
|
||||||
|
render 'edit'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @epp_user.destroy
|
||||||
|
flash[:notice] = I18n.t('shared.record_deleted')
|
||||||
|
redirect_to admin_epp_users_path
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('shared.failed_to_delete_record')
|
||||||
|
render 'show'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_epp_user
|
||||||
|
@epp_user = EppUser.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def epp_user_params
|
||||||
|
params.require(:epp_user).permit(:username, :password, :crt, :active, :registrar_id, :registrar_typeahead)
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,4 +2,14 @@ class EppUser < ActiveRecord::Base
|
||||||
# TODO should have max request limit per day
|
# TODO should have max request limit per day
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
has_many :contacts
|
has_many :contacts
|
||||||
|
|
||||||
|
attr_accessor :registrar_typeahead
|
||||||
|
|
||||||
|
def registrar_typeahead
|
||||||
|
@registrar_typeahead || registrar || nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
username
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
40
app/views/admin/epp_users/_form.haml
Normal file
40
app/views/admin/epp_users/_form.haml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
= form_for([:admin, @epp_user]) do |f|
|
||||||
|
- if @epp_user.errors.any?
|
||||||
|
- @epp_user.errors.each do |attr, err|
|
||||||
|
= err
|
||||||
|
%br
|
||||||
|
- if @epp_user.errors.any?
|
||||||
|
%hr
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :username
|
||||||
|
= f.text_field(:username, class: 'form-control')
|
||||||
|
.form-group
|
||||||
|
= f.label :password
|
||||||
|
= f.text_field(:password, class: 'form-control')
|
||||||
|
.form-group
|
||||||
|
.form-group.has-feedback.js-typeahead-container
|
||||||
|
= f.label :registrar_typeahead
|
||||||
|
= f.text_field(:registrar_typeahead, class: 'form-control js-registrar-typeahead', placeholder: t('shared.registrar'), 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
|
||||||
|
.checkbox
|
||||||
|
%label{for: 'epp_user_active'}
|
||||||
|
= f.check_box(:active)
|
||||||
|
= t('shared.active')
|
||||||
|
|
||||||
|
.col-md-6.text-left
|
||||||
|
.form-group
|
||||||
|
= f.label :crt, t('shared.crt')
|
||||||
|
= f.text_area :crt, class: 'form-control'
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
Autocomplete.bindAdminRegistrarSearch();
|
9
app/views/admin/epp_users/edit.haml
Normal file
9
app/views/admin/epp_users/edit.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.edit_epp_user')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.back_to_epp_user'), [:admin, @epp_user], class: 'btn btn-default')
|
||||||
|
%hr
|
||||||
|
= render 'form'
|
28
app/views/admin/epp_users/index.haml
Normal file
28
app/views/admin/epp_users/index.haml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs= t('shared.epp_users')
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.create_new_epp_user'), new_admin_epp_user_path, class: 'btn btn-primary')
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= sort_link(@q, 'username')
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= sort_link(@q, 'registrar', t('shared.registrar'))
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= sort_link(@q, 'active', t('shared.active'))
|
||||||
|
%tbody
|
||||||
|
- @epp_users.each do |x|
|
||||||
|
%tr
|
||||||
|
%td= link_to(x, [:admin, x])
|
||||||
|
%td= link_to(x.registrar, [:admin, x.registrar])
|
||||||
|
%td= x.active
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= paginate @epp_users
|
3
app/views/admin/epp_users/new.haml
Normal file
3
app/views/admin/epp_users/new.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
%h2= t('shared.create_new_epp_user')
|
||||||
|
%hr
|
||||||
|
= render 'form'
|
40
app/views/admin/epp_users/show.haml
Normal file
40
app/views/admin/epp_users/show.haml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.epp_user_details')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.edit'), edit_admin_epp_user_path(@epp_user), class: 'btn btn-primary')
|
||||||
|
= link_to(t('shared.delete'), admin_epp_user_path(@epp_user), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger')
|
||||||
|
|
||||||
|
%hr
|
||||||
|
- if @epp_user.errors.any?
|
||||||
|
- @epp_user.errors.each do |attr, err|
|
||||||
|
= err
|
||||||
|
%br
|
||||||
|
- if @epp_user.errors.any?
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
%h3.panel-title= t('shared.general')
|
||||||
|
.panel-body
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t('shared.username')
|
||||||
|
%dd= @epp_user.username
|
||||||
|
|
||||||
|
%dt= t('shared.password')
|
||||||
|
%dd= @epp_user.password
|
||||||
|
|
||||||
|
%dt= t('shared.active')
|
||||||
|
%dd= @epp_user.active
|
||||||
|
|
||||||
|
.col-md-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
%h3.panel-title= t('shared.certificates')
|
||||||
|
.panel-body
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t('shared.crt')
|
||||||
|
%dd= @epp_user.crt
|
|
@ -40,7 +40,7 @@
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.users'), admin_users_path
|
= link_to t('shared.users'), admin_users_path
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.epp_users'), '#'
|
= link_to t('shared.epp_users'), admin_epp_users_path
|
||||||
%li.divider
|
%li.divider
|
||||||
%li.dropdown-header= 'Something else'
|
%li.dropdown-header= 'Something else'
|
||||||
%li
|
%li
|
||||||
|
|
|
@ -349,13 +349,17 @@ en:
|
||||||
|
|
||||||
users: 'Users'
|
users: 'Users'
|
||||||
create_new_user: 'Create new user'
|
create_new_user: 'Create new user'
|
||||||
user_added: 'User added!'
|
|
||||||
failed_to_add_user: 'Failed to add user'
|
|
||||||
admin: 'Admin'
|
admin: 'Admin'
|
||||||
user_details: 'User details'
|
user_details: 'User details'
|
||||||
edit_user: 'Edit user'
|
edit_user: 'Edit user'
|
||||||
back_to_user: 'Back to user'
|
back_to_user: 'Back to user'
|
||||||
|
|
||||||
|
create_new_epp_user: 'Create new EPP user'
|
||||||
|
crt: 'Certificate'
|
||||||
|
epp_user_details: 'EPP user details'
|
||||||
|
edit_epp_user: 'Edit EPP user'
|
||||||
|
back_to_epp_user: 'Back to EPP user'
|
||||||
|
|
||||||
record_created: 'Record created'
|
record_created: 'Record created'
|
||||||
failed_to_create_record: 'Failed to create record'
|
failed_to_create_record: 'Failed to create record'
|
||||||
record_updated: 'Record updated'
|
record_updated: 'Record updated'
|
||||||
|
|
|
@ -22,6 +22,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :users
|
resources :users
|
||||||
|
resources :epp_users
|
||||||
|
|
||||||
root 'domains#index'
|
root 'domains#index'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue