mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
105842700-download_list_added
This commit is contained in:
parent
da910bc660
commit
2748f3be55
11 changed files with 163 additions and 88 deletions
|
@ -1,12 +1,9 @@
|
|||
class Registrant::DomainsController < RegistrantController
|
||||
|
||||
def index
|
||||
|
||||
authorize! :view, :registrant_domains
|
||||
params[:q] ||= {}
|
||||
|
||||
domains = current_user.domains
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
|
@ -16,15 +13,32 @@ class Registrant::DomainsController < RegistrantController
|
|||
|
||||
def show
|
||||
@domain = Domain.find(params[:id])
|
||||
@domain.valid?
|
||||
if !(current_user.domains.include?(@domain) || @domain.valid?)
|
||||
redirect_to registrant_domains_path
|
||||
end
|
||||
authorize! :read, @domain
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
||||
def normalize_search_parameters
|
||||
def download_list
|
||||
authorize! :view, :registrant_domains
|
||||
params[:q] ||= {}
|
||||
domains = current_user.domains
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { render text: @domains.to_csv }
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_search_parameters
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
||||
|
@ -32,10 +46,7 @@ class Registrant::DomainsController < RegistrantController
|
|||
rescue
|
||||
logger.warn('Invalid date')
|
||||
end
|
||||
|
||||
yield
|
||||
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
|
||||
end
|
|
@ -1,64 +1,8 @@
|
|||
class Registrar::RegistrarsController < RegistrartController
|
||||
load_and_authorize_resource
|
||||
class Registrant::RegistrarsController < RegistrantController
|
||||
|
||||
|
||||
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
|
||||
def show
|
||||
@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
|
||||
)
|
||||
authorize! :read, @registrar
|
||||
@registrar.valid?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -117,9 +117,11 @@ class Ability
|
|||
end
|
||||
|
||||
def static_registrant
|
||||
customer_service
|
||||
can :manage, :registrant_domains
|
||||
can :manage, :registrant_whois
|
||||
can :manage, Depp::Domain
|
||||
can :manage, Domain
|
||||
end
|
||||
|
||||
def user
|
||||
|
|
|
@ -774,5 +774,14 @@ class Domain < ActiveRecord::Base
|
|||
status_notes[status] = notes[i]
|
||||
end
|
||||
end
|
||||
|
||||
def self.to_csv
|
||||
CSV.generate do |csv|
|
||||
csv << column_names
|
||||
all.each do |domain|
|
||||
csv << domain.attributes.values_at(*column_names)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/ClassLength
|
||||
|
|
0
app/views/registrant/domains/download_list.haml
Normal file
0
app/views/registrant/domains/download_list.haml
Normal file
|
@ -12,10 +12,6 @@
|
|||
.form-group
|
||||
= f.label t(:registrant_ident)
|
||||
= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:nameserver_hostname)
|
||||
= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname)
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
|
@ -36,6 +32,20 @@
|
|||
|
||||
%button.btn.btn-default.js-reset-form
|
||||
= t(:clear_fields)
|
||||
.row
|
||||
.col-md-3
|
||||
.btn-group{:role => "group"}
|
||||
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
|
||||
Download
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to 'PDF', download_list_registrant_domain_path(params[:q], format: "pdf")
|
||||
%li= link_to 'CSV', download_list_registrant_domain_path(params[:q], format: "csv")
|
||||
.col-md-3
|
||||
.col-md-3
|
||||
.col-md-3
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
.row
|
||||
|
@ -58,7 +68,20 @@
|
|||
%td= link_to(x, registrant_domain_path(x))
|
||||
%td
|
||||
- if x.registrant
|
||||
= link_to(x.registrant, [:admin, x.registrant])
|
||||
= link_to(x.registrant, [:registrant, x.registrant]) if x.registrant
|
||||
|
||||
%td= l(x.valid_to, format: :short)
|
||||
%td= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar
|
||||
%td= link_to(x.registrar, registrant_registrar_path(x.registrar)) if x.registrar
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
= paginate @domains
|
||||
.col-md-6.text-right
|
||||
.pagination
|
||||
= t(:result_count, count: @domains.total_count)
|
||||
|
||||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{registrant_domains_path}"
|
||||
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
-#= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
|
||||
= render 'shared/title', name: @domain.name
|
||||
|
||||
.row
|
||||
.col-md-6= render 'admin/domains/partials/general'
|
||||
.col-md-6= render 'admin/domains/partials/owner'
|
||||
.col-md-6= render 'registrant/domains/partials/general'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/tech_contacts'
|
||||
.col-md-12= render 'registrant/domains/partials/tech_contacts'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/admin_contacts'
|
||||
.col-md-12= render 'registrant/domains/partials/admin_contacts'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/statuses'
|
||||
.col-md-12= render 'registrant/domains/partials/statuses'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/nameservers'
|
||||
.col-md-12= render 'registrant/domains/partials/nameservers'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/dnskeys'
|
||||
.col-md-12= render 'registrant/domains/partials/dnskeys'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/keyrelays'
|
||||
.row
|
||||
.col-md-12
|
||||
= render 'admin/domains/partials/legal_documents', legal_documents: @domain.legal_documents
|
||||
.col-md-12= render 'registrant/domains/partials/keyrelays'
|
||||
|
|
22
app/views/registrant/registrars/index.haml
Normal file
22
app/views/registrant/registrars/index.haml
Normal file
|
@ -0,0 +1,22 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:new), new_admin_registrar_path, class: 'btn btn-primary')
|
||||
= render 'shared/title', name: t(:registrars)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}
|
||||
= sort_link(@q, 'name')
|
||||
%th{class: 'col-xs-6'}
|
||||
= sort_link(@q, 'reg_no', t(:reg_no))
|
||||
%tbody
|
||||
- @registrars.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, [:admin, x])
|
||||
%td= x.reg_no
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @registrars
|
53
app/views/registrant/registrars/show.haml
Normal file
53
app/views/registrant/registrars/show.haml
Normal file
|
@ -0,0 +1,53 @@
|
|||
= render 'shared/title', name: @registrar.name
|
||||
|
||||
- if @registrar.errors.any?
|
||||
- @registrar.errors.each do |attr, err|
|
||||
= err
|
||||
%br
|
||||
- if @registrar.errors.any?
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:general)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:name)
|
||||
%dd= @registrar.name
|
||||
|
||||
%dt= t(:reg_no)
|
||||
%dd= @registrar.reg_no
|
||||
|
||||
%dt= t(:vat_no)
|
||||
%dd= @registrar.vat_no
|
||||
|
||||
%dt= t(:reference_no)
|
||||
%dd= @registrar.reference_no
|
||||
|
||||
%dt= t(:id)
|
||||
%dd= @registrar.code
|
||||
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:contact)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:country)
|
||||
%dd= @registrar.country
|
||||
|
||||
%dt= t(:address)
|
||||
%dd= @registrar.address
|
||||
|
||||
%dt= t(:contact_phone)
|
||||
%dd= @registrar.phone
|
||||
|
||||
%dt= t(:contact_email)
|
||||
%dd= @registrar.email
|
||||
|
||||
%dt= t(:billing_address)
|
||||
%dd= @registrar.billing_address
|
||||
|
||||
%dt= t(:billing_email)
|
||||
%dd= @registrar.billing_email
|
|
@ -7,6 +7,8 @@ require 'action_controller/railtie'
|
|||
require 'action_mailer/railtie'
|
||||
require 'action_view/railtie'
|
||||
require 'sprockets/railtie'
|
||||
require 'csv'
|
||||
require 'rails/all'
|
||||
# require "rails/test_unit/railtie"
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
|
|
|
@ -102,6 +102,12 @@ Rails.application.routes.draw do
|
|||
namespace :registrant do
|
||||
root 'domains#index'
|
||||
|
||||
resources :domains do
|
||||
member do
|
||||
get :download_list
|
||||
end
|
||||
end
|
||||
|
||||
# resources :invoices do
|
||||
# member do
|
||||
# get 'download_pdf'
|
||||
|
@ -140,6 +146,14 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :registrars do
|
||||
resources :api_users
|
||||
resources :white_ips
|
||||
collection do
|
||||
get :search
|
||||
end
|
||||
end
|
||||
|
||||
resources :whois
|
||||
# resources :contacts do
|
||||
# member do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue