mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Init depp refactor
This commit is contained in:
parent
f3c9e0aecc
commit
3fe47973e6
156 changed files with 191 additions and 1662 deletions
84
app/controllers/depp/contacts_controller.rb
Normal file
84
app/controllers/depp/contacts_controller.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
module Depp
|
||||
class ContactsController < ApplicationController
|
||||
before_action :init_epp_contact
|
||||
|
||||
def index
|
||||
limit, offset = pagination_details
|
||||
|
||||
res = depp_current_user.repp_request('contacts', { details: true, limit: limit, offset: offset })
|
||||
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
|
||||
@response = res.parsed_body.with_indifferent_access if res.code == '200'
|
||||
@contacts = @response ? @response[:contacts] : []
|
||||
|
||||
@paginatable_array = Kaminari.paginate_array(
|
||||
[], total_count: @response[:total_number_of_records]
|
||||
).page(params[:page]).per(limit)
|
||||
end
|
||||
|
||||
def new
|
||||
@contact = Depp::Contact.new
|
||||
end
|
||||
|
||||
def show
|
||||
@contact = Depp::Contact.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact = Depp::Contact.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
|
||||
if @contact.save
|
||||
redirect_to contact_url(@contact.id)
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
|
||||
if @contact.update_attributes(params[:contact])
|
||||
redirect_to contact_url(@contact.id)
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
@contact = Depp::Contact.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@contact = Depp::Contact.new(params[:contact])
|
||||
|
||||
if @contact.delete
|
||||
redirect_to contacts_url, notice: t(:destroyed)
|
||||
else
|
||||
render 'delete'
|
||||
end
|
||||
end
|
||||
|
||||
def check
|
||||
@ids = params[:contacts]
|
||||
# if @ids
|
||||
# @contacts = []
|
||||
# @ids.split(',').each do |id|
|
||||
# @contacts << id.strip
|
||||
# end
|
||||
# end
|
||||
return unless @ids
|
||||
|
||||
@data = @contact.check(@ids)
|
||||
@contacts = Depp::Contact.construct_check_hash_from_data(@data)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_epp_contact
|
||||
Depp::Contact.user = depp_current_user
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue