mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Registrar refactor fixes
This commit is contained in:
parent
d09855bc6d
commit
9bb20365c9
15 changed files with 46 additions and 57 deletions
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -16,23 +16,32 @@ class ApplicationController < ActionController::Base
|
|||
redirect_to registrar_root_path, alert: exception.message if current_user.is_a?(ApiUser)
|
||||
end
|
||||
|
||||
helper_method :registrar_request?, :admin_request?
|
||||
def registrar_request?
|
||||
request.path.match(/^\/registrar/)
|
||||
end
|
||||
|
||||
def admin_request?
|
||||
request.path.match(/^\/admin/)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(_resource)
|
||||
rt = session[:user_return_to].to_s.presence
|
||||
login_paths = [admin_login_path, registrar_login_path, '/login']
|
||||
return rt if rt && !login_paths.include?(rt)
|
||||
|
||||
if request.path.match('registrar')
|
||||
registrar_root_path
|
||||
elsif request.path.match('admin')
|
||||
admin_root_path
|
||||
if registrar_request?
|
||||
registrar_root_url
|
||||
elsif admin_request?
|
||||
admin_root_url
|
||||
end
|
||||
end
|
||||
|
||||
def after_sign_out_path_for(_resource)
|
||||
if request.path.match('registrar')
|
||||
registrar_login_path
|
||||
elsif request.path.match('admin')
|
||||
admin_login_path
|
||||
if registrar_request?
|
||||
registrar_login_url
|
||||
elsif admin_request?
|
||||
admin_login_url
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
|
|||
|
||||
def create
|
||||
authorize! :create, Depp::Contact
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
@contact = Depp::Contact.new(params[:depp_contact])
|
||||
|
||||
if @contact.save
|
||||
redirect_to registrar_contact_url(@contact.id)
|
||||
|
@ -43,9 +43,9 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
|
|||
|
||||
def update
|
||||
authorize! :edit, Depp::Contact
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
@contact = Depp::Contact.new(params[:depp_contact])
|
||||
|
||||
if @contact.update_attributes(params[:contact])
|
||||
if @contact.update_attributes(params[:depp_contact])
|
||||
redirect_to registrar_contact_url(@contact.id)
|
||||
else
|
||||
render 'edit'
|
||||
|
@ -59,7 +59,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
|
|||
|
||||
def destroy
|
||||
authorize! :delete, Depp::Contact
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
@contact = Depp::Contact.new(params[:depp_contact])
|
||||
|
||||
if @contact.delete
|
||||
redirect_to registrar_contacts_url, notice: t(:destroyed)
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
class Registrar::DeppController < RegistrarController # EPP controller
|
||||
include CurrentUserHelper
|
||||
include Depp::ApplicationHelper
|
||||
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :depp_current_user
|
||||
|
||||
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |_exception|
|
||||
|
|
|
@ -14,9 +14,9 @@ class Registrar::XmlConsolesController < Registrar::DeppController # EPP control
|
|||
end
|
||||
|
||||
def load_xml
|
||||
# binding.pry
|
||||
cl_trid = "#{depp_current_user.tag}-#{Time.now.to_i}"
|
||||
xml_dir_path = Depp::Engine.root + 'app/views/depp/xml_consoles/epp_requests'
|
||||
authorize! :create, :registrar_xml_console
|
||||
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
|
||||
xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests'
|
||||
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
|
||||
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
|
||||
render text: xml
|
||||
|
|
|
@ -2,6 +2,8 @@ class RegistrarController < ApplicationController
|
|||
before_action :authenticate_user!
|
||||
layout 'registrar/application'
|
||||
|
||||
include Registrar::ApplicationHelper
|
||||
|
||||
helper_method :depp_controller?
|
||||
def depp_controller?
|
||||
false
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
module CurrentUserHelper
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
module Depp
|
||||
module ApplicationHelper
|
||||
def unstable_env
|
||||
return nil if Rails.env.production?
|
||||
Rails.env
|
||||
end
|
||||
|
||||
def env_style
|
||||
return '' if unstable_env.nil?
|
||||
"background-image: url(#{image_path("depp/bg-#{unstable_env}.png")});"
|
||||
end
|
||||
|
||||
def ident_for(contact)
|
||||
case contact.ident_type
|
||||
when 'birthday'
|
||||
"#{contact.ident} [#{contact.ident_type}]"
|
||||
else
|
||||
"#{contact.ident} [#{contact.ident_country_code} #{contact.ident_type}]"
|
||||
end
|
||||
end
|
||||
|
||||
def pagination_details
|
||||
params[:page] ||= 1
|
||||
limit = ENV['depp_records_on_page'] || 20
|
||||
offset = ((params[:page].to_i - 1) * limit.to_i)
|
||||
[limit, offset]
|
||||
end
|
||||
end
|
||||
end
|
15
app/helpers/registrar/application_helper.rb
Normal file
15
app/helpers/registrar/application_helper.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Registrar
|
||||
module ApplicationHelper
|
||||
def env_style
|
||||
return '' if unstable_env.nil?
|
||||
"background-image: url(#{image_path("registrar/bg-#{unstable_env}.png")});"
|
||||
end
|
||||
|
||||
def pagination_details
|
||||
params[:page] ||= 1
|
||||
limit = ENV['depp_records_on_page'] || 20
|
||||
offset = ((params[:page].to_i - 1) * limit.to_i)
|
||||
[limit, offset]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -48,14 +48,15 @@ module Depp
|
|||
data = info_xml(id)
|
||||
|
||||
res = data.css('epp response resData infData')
|
||||
ext = data.css('epp response extension')
|
||||
new(
|
||||
id: res.css('id').text,
|
||||
code: res.css('id').text,
|
||||
email: res.css('email').text,
|
||||
phone: res.css('voice').text,
|
||||
ident: res.css('ident').text,
|
||||
ident_type: res.css('ident').first.try(:attributes).try(:[], 'type').try(:value),
|
||||
ident_country_code: res.css('ident').first.try(:attributes).try(:[], 'cc').try(:value),
|
||||
ident: ext.css('ident').text,
|
||||
ident_type: ext.css('ident').first.try(:attributes).try(:[], 'type').try(:value),
|
||||
ident_country_code: ext.css('ident').first.try(:attributes).try(:[], 'cc').try(:value),
|
||||
|
||||
# postalInfo
|
||||
name: res.css('postalInfo name').text,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
= csrf_meta_tags
|
||||
= stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true
|
||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||
= favicon_link_tag 'favicon.ico'
|
||||
= favicon_link_tag 'registrar/favicon.ico'
|
||||
%title EIS Registrar Portal
|
||||
%body
|
||||
/ Static navbar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue