mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Add tech contacts attaching
This commit is contained in:
parent
80440d741b
commit
a9ee1cdad1
6 changed files with 90 additions and 7 deletions
46
app/controllers/admin/tech_contacts_controller.rb
Normal file
46
app/controllers/admin/tech_contacts_controller.rb
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
class Admin::TechContactsController < ApplicationController
|
||||||
|
before_action :set_domain
|
||||||
|
before_action :set_contact, only: [:destroy]
|
||||||
|
|
||||||
|
def new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
contact = Contact.find_by(id: params[:tech_contact_id])
|
||||||
|
|
||||||
|
unless contact
|
||||||
|
flash.now[:alert] = I18n.t('shared.contact_was_not_found')
|
||||||
|
render 'new' and return
|
||||||
|
end
|
||||||
|
|
||||||
|
if @domain.tech_contacts.exists?(contact)
|
||||||
|
flash.now[:alert] = I18n.t('shared.contact_already_exists')
|
||||||
|
render 'new' and return
|
||||||
|
end
|
||||||
|
|
||||||
|
@domain.tech_contacts << contact
|
||||||
|
flash[:notice] = I18n.t('shared.contact_added')
|
||||||
|
redirect_to [:admin, @domain]
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @domain.tech_contacts.delete(@contact)
|
||||||
|
flash[:notice] = I18n.t('shared.contact_detached')
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('shared.failed_to_detach_contact')
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to [:admin, @domain]
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_domain
|
||||||
|
@domain = Domain.find(params[:domain_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_contact
|
||||||
|
@contact = Contact.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
|
@ -97,10 +97,6 @@ module Epp::DomainsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_create_params
|
def domain_create_params
|
||||||
period = (@ph[:period].to_i == 0) ? 1 : @ph[:period].to_i
|
|
||||||
period_unit = Epp::EppDomain.parse_period_unit_from_frame(parsed_frame) || 'y'
|
|
||||||
valid_to = Date.today + Epp::EppDomain.convert_period_to_time(period, period_unit)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name: @ph[:name],
|
name: @ph[:name],
|
||||||
registrar_id: current_epp_user.registrar.try(:id),
|
registrar_id: current_epp_user.registrar.try(:id),
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
.panel.panel-default
|
- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default'
|
||||||
.panel-heading= t('shared.tech_contacts')
|
.panel{class: panel_class}
|
||||||
|
.panel-heading.clearfix
|
||||||
|
.pull-left
|
||||||
|
= t('shared.tech_contacts')
|
||||||
|
.pull-right
|
||||||
|
= link_to(t('shared.add'), new_admin_domain_tech_contact_path(@domain), class: 'btn btn-primary btn-xs')
|
||||||
.table-responsive
|
.table-responsive
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
%thead
|
%thead
|
||||||
|
@ -14,4 +19,9 @@
|
||||||
%td= x.email
|
%td= x.email
|
||||||
%td
|
%td
|
||||||
= link_to(t('shared.edit'), root_path, class: 'btn btn-primary btn-xs')
|
= link_to(t('shared.edit'), root_path, class: 'btn btn-primary btn-xs')
|
||||||
= link_to(t('shared.detach'), root_path, method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-warning btn-xs')
|
= link_to(t('shared.detach'), admin_domain_tech_contact_path(@domain, x), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-warning btn-xs')
|
||||||
|
- if @domain.errors.messages[:tech_contacts]
|
||||||
|
%tfoot
|
||||||
|
- @domain.errors.messages[:tech_contacts].each do |x|
|
||||||
|
%tr
|
||||||
|
%td{colspan: 4}= x
|
||||||
|
|
22
app/views/admin/tech_contacts/new.haml
Normal file
22
app/views/admin/tech_contacts/new.haml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.new_tech_contact')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.back_to_domain'), [:admin, @domain], class: 'btn btn-default')
|
||||||
|
%hr
|
||||||
|
= form_tag(admin_domain_tech_contacts_path(@domain)) do |f|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.form-group.has-feedback
|
||||||
|
.form-group.has-feedback
|
||||||
|
= label_tag :tech_contact
|
||||||
|
= text_field_tag(:domain_tech_contact, params[:domain_tech_contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
||||||
|
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||||
|
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
||||||
|
= hidden_field_tag(:tech_contact_id, params[:tech_contact_id], class: 'js-contact-id')
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
||||||
|
|
|
@ -206,3 +206,10 @@ en:
|
||||||
nameserver_added: 'Nameserver added!'
|
nameserver_added: 'Nameserver added!'
|
||||||
back_to_domain: 'Back to domain'
|
back_to_domain: 'Back to domain'
|
||||||
edit_domain: 'Edit domain'
|
edit_domain: 'Edit domain'
|
||||||
|
contact_was_not_found: 'Contact was not found!'
|
||||||
|
contact_already_exists: 'Contact already exists on this domain!'
|
||||||
|
contact_added: 'Contact added!'
|
||||||
|
new_tech_contact: 'New tech contact'
|
||||||
|
new_admin_contact: 'New admin contact'
|
||||||
|
contact_detached: 'Contact detached!'
|
||||||
|
failed_to_detach_contact: 'Failed to detach contact!'
|
||||||
|
|
|
@ -8,7 +8,9 @@ Rails.application.routes.draw do
|
||||||
namespace(:admin) do
|
namespace(:admin) do
|
||||||
resources :domains do
|
resources :domains do
|
||||||
resources :nameservers
|
resources :nameservers
|
||||||
|
resources :tech_contacts
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :setting_groups
|
resources :setting_groups
|
||||||
resources :registrars do
|
resources :registrars do
|
||||||
collection do
|
collection do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue