mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Add contact show
This commit is contained in:
parent
1777a0e572
commit
2d2a12b7d0
12 changed files with 131 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
class Admin::ContactsController < ApplicationController
|
||||
before_action :set_contact, only: [:show]
|
||||
|
||||
def index
|
||||
@q = Contact.search(params[:q])
|
||||
|
@ -8,4 +9,10 @@ class Admin::ContactsController < ApplicationController
|
|||
def search
|
||||
render json: Contact.search_by_query(params[:q])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_contact
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,15 +3,19 @@ class Admin::DomainsController < ApplicationController
|
|||
before_action :verify_deletion, only: [:destroy]
|
||||
|
||||
def new
|
||||
@domain = Domain.new
|
||||
owner_contact = Contact.find(params[:owner_contact_id]) if params[:owner_contact_id]
|
||||
@domain = Domain.new(owner_contact: owner_contact)
|
||||
params[:domain_owner_contact] = owner_contact
|
||||
end
|
||||
|
||||
def create
|
||||
@domain = Domain.new(domain_params)
|
||||
|
||||
if @domain.save
|
||||
flash[:notice] = I18n.t('shared.domain_added')
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_add_domain')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
@ -27,7 +31,7 @@ class Admin::DomainsController < ApplicationController
|
|||
|
||||
def edit
|
||||
params[:registrar] = @domain.registrar
|
||||
params[:owner_contact] = @domain.owner_contact_code
|
||||
params[:domain_owner_contact] = @domain.owner_contact
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -26,6 +26,11 @@ class Contact < ActiveRecord::Base
|
|||
validates :code, uniqueness: { message: :epp_id_taken }
|
||||
|
||||
delegate :name, to: :international_address
|
||||
delegate :country, to: :address, prefix: true
|
||||
delegate :city, to: :address, prefix: true
|
||||
delegate :street, to: :address, prefix: true
|
||||
delegate :zip, to: :address, prefix: true
|
||||
delegate :org_name, to: :address, prefix: true
|
||||
|
||||
IDENT_TYPE_ICO = 'ico'
|
||||
IDENT_TYPES = [
|
||||
|
@ -75,7 +80,7 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
# Find a way to use self.domains with contact
|
||||
def domains_owned
|
||||
Domain.find_by(owner_contact_id: id)
|
||||
Domain.where(owner_contact_id: id)
|
||||
end
|
||||
|
||||
def relations_with_domain?
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
class Country < ActiveRecord::Base
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
||||
|
|
19
app/views/admin/contacts/partials/_address.haml
Normal file
19
app/views/admin/contacts/partials/_address.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('shared.address')
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('shared.country')
|
||||
%dd= @contact.address_country
|
||||
|
||||
%dt= t('shared.city')
|
||||
%dd= @contact.address_city
|
||||
|
||||
%dt= t('shared.street')
|
||||
%dd= @contact.address_street
|
||||
|
||||
%dt= t('shared.zip')
|
||||
%dd= @contact.address_zip
|
||||
|
||||
%dt= t('shared.org_name')
|
||||
%dd= @contact.address_org_name
|
23
app/views/admin/contacts/partials/_domains.haml
Normal file
23
app/views/admin/contacts/partials/_domains.haml
Normal file
|
@ -0,0 +1,23 @@
|
|||
#contacts.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
.pull-left
|
||||
= t('shared.domains')
|
||||
.pull-right
|
||||
= link_to(t('shared.add'), new_admin_domain_path(owner_contact_id: @contact), class: 'btn btn-primary btn-xs')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-3'}= t('shared.domain_name')
|
||||
%th{class: 'col-xs-3'}= t('shared.registrar')
|
||||
%th{class: 'col-xs-3'}= t('shared.valid_to')
|
||||
%th{class: 'col-xs-3'}= t('shared.action')
|
||||
%tbody
|
||||
- @contact.domains_owned.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.name, [:admin, x])
|
||||
%td= link_to(x.registrar, [:admin, x.registrar])
|
||||
%td= l(x.valid_to, format: :short)
|
||||
%td
|
||||
= link_to(t('shared.edit'), edit_admin_domain_path(x), class: 'btn btn-primary btn-xs')
|
||||
= link_to(t('shared.delete'), admin_domain_path(x), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger btn-xs')
|
29
app/views/admin/contacts/partials/_general.haml
Normal file
29
app/views/admin/contacts/partials/_general.haml
Normal file
|
@ -0,0 +1,29 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('shared.general')
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('shared.name')
|
||||
%dd= @contact.name
|
||||
|
||||
%dt= t('shared.code')
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t('shared.ident')
|
||||
%dd= @contact.ident
|
||||
|
||||
%dt= t('shared.ident_type')
|
||||
%dd= @contact.ident_type
|
||||
|
||||
%dt= t('shared.email')
|
||||
%dd= @contact.email
|
||||
|
||||
%dt= t('shared.phone')
|
||||
%dd= @contact.phone
|
||||
|
||||
- if @contact.fax
|
||||
%dt= t('shared.fax')
|
||||
%dd= @contact.fax
|
||||
|
||||
%dt= t('shared.password')
|
||||
%dd= @contact.auth_info
|
21
app/views/admin/contacts/show.haml
Normal file
21
app/views/admin/contacts/show.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t('shared.contact_details')}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('shared.edit'), edit_admin_contact_path(@contact), class: 'btn btn-primary')
|
||||
= link_to(t('shared.delete'), admin_contact_path(@contact), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger')
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-6= render 'admin/contacts/partials/general'
|
||||
.col-md-6= render 'admin/contacts/partials/address'
|
||||
.row
|
||||
.col-md-12= render 'admin/contacts/partials/domains'
|
||||
/ .row
|
||||
/ .col-md-12= render 'admin/contacts/partials/addresses'
|
||||
/ .row
|
||||
/ .col-md-12= render 'admin/contacts/partials/tech_contacts'
|
||||
/ .row
|
||||
/ .col-md-12= render 'admin/contacts/partials/admin_contacts'
|
|
@ -3,6 +3,8 @@
|
|||
- @domain.errors.each do |attr, err|
|
||||
= err
|
||||
%br
|
||||
- if @domain.errors.any?
|
||||
%hr
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
|
@ -25,7 +27,7 @@
|
|||
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
||||
.form-group.has-feedback
|
||||
= f.label :owner_contact
|
||||
= text_field_tag(:domain_owner_contact, params[:owner_contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
||||
= text_field_tag(:domain_owner_contact, params[:domain_owner_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
|
||||
= f.hidden_field(:owner_contact_id, class: 'js-contact-id')
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%tr
|
||||
%td= link_to(x, admin_domain_path(x))
|
||||
%td= link_to(x.registrar, root_path) if x.registrar
|
||||
%td= link_to(x.owner_contact, root_path)
|
||||
%td= link_to(x.owner_contact, [:admin, x.owner_contact])
|
||||
%td= l(x.valid_to, format: :short)
|
||||
%td= link_to(t('shared.edit'), edit_admin_domain_path(x), class: 'btn btn-primary btn-xs')
|
||||
.row
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('shared.name')
|
||||
%dd= link_to(@domain.owner_contact, root_path)
|
||||
%dd= link_to(@domain.owner_contact, [:admin, @domain.owner_contact])
|
||||
|
||||
%dt= t('shared.code')
|
||||
%dd= @domain.owner_contact_code
|
||||
|
|
|
@ -244,3 +244,15 @@ en:
|
|||
domain_deleted: 'Domain deleted!'
|
||||
failed_to_delete_domain: 'Failed to delete domain!'
|
||||
email: 'Email'
|
||||
fax: 'Fax'
|
||||
contact_details: 'Contact details'
|
||||
ident: 'Ident'
|
||||
ident_type: 'Ident type'
|
||||
address: 'Address'
|
||||
country: 'Country'
|
||||
city: 'City'
|
||||
street: 'Street'
|
||||
zip: 'Zip'
|
||||
org_name: 'Organisation name'
|
||||
failed_to_add_domain: 'Failed to add domain!'
|
||||
domain_added: 'Domain added!'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue