mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
105842700-portal
This commit is contained in:
parent
360fb57a68
commit
6077f6c36d
16 changed files with 378 additions and 16 deletions
|
@ -1,5 +1,41 @@
|
|||
class Registrant::DomainsController < RegistrantController
|
||||
|
||||
def index
|
||||
authorize! :view, :registrant_domains
|
||||
|
||||
authorize! :view, :registrant_domains
|
||||
params[:q] ||= {}
|
||||
|
||||
domains = Domain.includes(:registrar, :registrant).where(registrant_id: 76246)
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
end
|
||||
end
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
|
||||
end
|
||||
|
||||
def show
|
||||
@domain = Domain.find(params[:id])
|
||||
@domain.valid?
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
||||
def normalize_search_parameters
|
||||
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
||||
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
|
||||
rescue
|
||||
logger.warn('Invalid date')
|
||||
end
|
||||
|
||||
yield
|
||||
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
|
||||
end
|
64
app/controllers/registrant/registrars_controller.rb
Normal file
64
app/controllers/registrant/registrars_controller.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
class Registrar::RegistrarsController < RegistrartController
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
def search
|
||||
render json: Registrar.search_by_query(params[:q])
|
||||
end
|
||||
|
||||
def index
|
||||
@q = Registrar.ordered.search(params[:q])
|
||||
@registrars = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@registrar = Registrar.new
|
||||
end
|
||||
|
||||
def create
|
||||
@registrar = Registrar.new(registrar_params)
|
||||
|
||||
if @registrar.save
|
||||
flash[:notice] = I18n.t('registrar_added')
|
||||
redirect_to [:admin, @registrar]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @registrar.update(registrar_params)
|
||||
flash[:notice] = I18n.t('registrar_updated')
|
||||
redirect_to [:admin, @registrar]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_registrar')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @registrar.destroy
|
||||
flash[:notice] = I18n.t('registrar_deleted')
|
||||
redirect_to admin_registrars_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_registrar')
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_registrar
|
||||
@registrar = Registrar.find(params[:id])
|
||||
end
|
||||
|
||||
def registrar_params
|
||||
params.require(:registrar).permit(
|
||||
:name, :reg_no, :vat_no, :street, :city, :state, :zip, :billing_address,
|
||||
:country_code, :email, :phone, :billing_email, :code
|
||||
)
|
||||
end
|
||||
end
|
|
@ -2,6 +2,8 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
layout 'registrant/application'
|
||||
|
||||
def login
|
||||
@user = RegistrantUser.find_by_username('registrar1')
|
||||
sign_in(@user, event: :authentication)
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
class Registrant::WhoisController < RegistrantController
|
||||
def index
|
||||
authorize! :view, :registrant_whois
|
||||
|
||||
if params[:domain_name].present?
|
||||
@domain = WhoisRecord.find_by(name: params[:domain_name]);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue