105842700-download_list_added

This commit is contained in:
Stas 2015-12-06 20:47:34 +02:00
parent da910bc660
commit 2748f3be55
11 changed files with 163 additions and 88 deletions

View file

@ -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

View file

@ -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