Context switching for client

This commit is contained in:
Martin Lensment 2014-09-26 17:32:57 +03:00
parent 5dfee40b87
commit b48b91878d
9 changed files with 44 additions and 12 deletions

View file

@ -24,7 +24,7 @@ class Client::ContactsController < ClientController
end
end
def destroy
def destroy
if @contact.destroy_and_clean
flash[:notice] = I18n.t('shared.contact_deleted')
redirect_to client_contacts_path

View file

@ -7,9 +7,10 @@ class Client::DomainTransfersController < ClientController
end
def create
@domain_transfer = @domain.pending_transfer || @domain.domain_transfers.create(domain_transfer_params)
@domain_transfer = @domain.pending_transfer || @domain.domain_transfers.build(domain_transfer_params)
if can? :read, @domain_transfer
flash[:notice] = I18n.t('shared.domain_transfer_requested')
@domain_transfer.save
flash[:notice] = I18n.t('shared.domain_transfer_requested') if @domain.registrar != current_registrar
redirect_to [:client, @domain_transfer]
else
flash.now[:alert] = I18n.t('shared.other_registrar_has_already_requested_to_transfer_this_domain')
@ -38,7 +39,7 @@ class Client::DomainTransfersController < ClientController
ret = {
status: DomainTransfer::PENDING,
transfer_requested_at: Time.zone.now,
transfer_to: current_user.registrar,
transfer_to: current_registrar,
transfer_from: @domain.registrar
}
@ -61,7 +62,7 @@ class Client::DomainTransfersController < ClientController
render 'new' and return
end
if @domain.registrar == current_user.registrar
if @domain.registrar == current_registrar && !@domain.pending_transfer
flash.now[:alert] = I18n.t('shared.domain_already_belongs_to_the_querying_registrar')
render 'new' and return
end

View file

@ -4,14 +4,13 @@ class Client::DomainsController < ClientController
before_action :verify_deletion, only: [:destroy]
def index
@q = Domain.search(params[:q]) if current_user.admin?
@q = current_user.registrar.domains.search(params[:q]) unless current_user.admin?
@q = current_registrar.domains.search(params[:q])
@domains = @q.result.page(params[:page])
end
def new
owner_contact = Contact.find(params[:owner_contact_id]) if params[:owner_contact_id]
@domain = Domain.new(owner_contact: owner_contact, registrar: current_user.registrar)
@domain = Domain.new(owner_contact: owner_contact, registrar: current_registrar)
params[:domain_owner_contact] = owner_contact
build_associations
@ -21,7 +20,7 @@ class Client::DomainsController < ClientController
add_prefix_to_statuses
@domain = Domain.new(domain_params)
@domain.registrar = current_user.registrar
@domain.registrar = current_registrar
if @domain.save
flash[:notice] = I18n.t('shared.domain_added')