mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
111396946-methods
This commit is contained in:
parent
b111285334
commit
793bc359ea
2 changed files with 5 additions and 63 deletions
|
@ -16,66 +16,10 @@ class Admin::ReservedDomainsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
authorize! :update, Depp::Domain
|
authorize! :update, ReservedDomain
|
||||||
@data = @domain.info(params[:domain_name])
|
|
||||||
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
authorize! :update, Depp::Domain
|
|
||||||
@domain_params = params[:domain]
|
|
||||||
@data = @domain.update(@domain_params)
|
|
||||||
|
|
||||||
if response_ok?
|
|
||||||
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
|
|
||||||
else
|
|
||||||
params[:domain_name] = @domain_params[:name]
|
|
||||||
render 'new'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
authorize! :delete, Depp::Domain
|
authorize! :delete, ReservedDomain
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def create
|
|
||||||
@reserved_domains = params[:reserved_domains]
|
|
||||||
|
|
||||||
begin
|
|
||||||
params[:reserved_domains] = "---\n" if params[:reserved_domains].blank?
|
|
||||||
names = YAML.load(params[:reserved_domains])
|
|
||||||
fail if names == false
|
|
||||||
rescue
|
|
||||||
flash.now[:alert] = I18n.t('invalid_yaml')
|
|
||||||
logger.warn 'Invalid YAML'
|
|
||||||
render :index and return
|
|
||||||
end
|
|
||||||
|
|
||||||
result = true
|
|
||||||
ReservedDomain.transaction do
|
|
||||||
# removing old ones
|
|
||||||
existing = ReservedDomain.any_of_domains(names.keys).pluck(:id)
|
|
||||||
ReservedDomain.where.not(id: existing).destroy_all
|
|
||||||
|
|
||||||
#updating and adding
|
|
||||||
names.each do |name, psw|
|
|
||||||
rec = ReservedDomain.find_or_initialize_by(name: name)
|
|
||||||
rec.password = psw
|
|
||||||
|
|
||||||
unless rec.save
|
|
||||||
result = false
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if result
|
|
||||||
flash[:notice] = I18n.t('record_updated')
|
|
||||||
redirect_to :back
|
|
||||||
else
|
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
|
||||||
render :index
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,12 +55,10 @@
|
||||||
%td= l(x.created_at, format: :short)
|
%td= l(x.created_at, format: :short)
|
||||||
%td= l(x.updated_at, format: :short)
|
%td= l(x.updated_at, format: :short)
|
||||||
%td
|
%td
|
||||||
= link_to(t(:edit), edit_admin_reserved_domains_path(name: x.name),
|
= link_to(t(:edit), edit_admin_reserved_domain_path(id: x.id),
|
||||||
|
class: 'btn btn-primary btn-xs')
|
||||||
|
= link_to(t(:delete), delete_admin_reserved_domain_path(id: x.id),
|
||||||
class: 'btn btn-primary btn-xs')
|
class: 'btn btn-primary btn-xs')
|
||||||
= link_to(t(:renew), renew_admin_reserved_domains_path(name: x.name),
|
|
||||||
class: 'btn btn-default btn-xs')
|
|
||||||
= link_to(t(:delete), delete_admin_reserved_domains_path(name: x.name),
|
|
||||||
class: 'btn btn-default btn-xs')
|
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
= paginate @domains
|
= paginate @domains
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue