From 29ac1a26b5d78c3d8570928df73610de0a361297 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 28 Jan 2013 09:26:47 +0100 Subject: render route endpoint --- app/models/call_route.rb | 11 +++++++++++ app/views/call_routes/_index_core.html.haml | 11 ++++++++--- app/views/call_routes/show.html.haml | 11 ++++++----- config/locales/views/call_routes/de.yml | 6 ++---- config/locales/views/call_routes/en.yml | 6 ++---- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 28120c1..b4496ab 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -238,4 +238,15 @@ class CallRoute < ActiveRecord::Base end end end + + def endpoint + if self.endpoint_id.to_i > 0 + begin + return self.endpoint_type.camelize.constantize.where(:id => self.endpoint_id.to_i).first + rescue + return nil + end + end + end + end diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 2e9238e..f0acebb 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -4,7 +4,7 @@ %tr %th= t('call_routes.index.name') %th= t('route_elements.index.pattern') - %th= t('call_routes.index.endpoint_type') + %th= t('call_routes.index.endpoint') %tbody - for call_route in call_routes @@ -18,5 +18,10 @@ = ', ...' - else = '-' - %td= call_route.endpoint_type - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} \ No newline at end of file + %td + - endpoint = call_route.endpoint + - if endpoint + = endpoint + - else + = call_route.endpoint_type + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml index 70fe13e..09daf53 100644 --- a/app/views/call_routes/show.html.haml +++ b/app/views/call_routes/show.html.haml @@ -7,11 +7,12 @@ %strong= t('call_routes.show.name') + ":" = @call_route.name %p - %strong= t('call_routes.show.endpoint_type') + ":" - = @call_route.endpoint_type -%p - %strong= t('call_routes.show.endpoint_id') + ":" - = @call_route.endpoint_id + %strong= t('call_routes.show.endpoint') + ":" + - endpoint = @call_route.endpoint + - if endpoint + = endpoint + - else + = @call_route.endpoint_type = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } diff --git a/config/locales/views/call_routes/de.yml b/config/locales/views/call_routes/de.yml index 260b869..a8d6f4b 100644 --- a/config/locales/views/call_routes/de.yml +++ b/config/locales/views/call_routes/de.yml @@ -9,8 +9,7 @@ de: page_title: 'Liste aller Call Routen' routing_table: 'Routing Table' name: 'Name' - endpoint_type: 'Endpoint type' - endpoint_id: 'Endpoint' + endpoint: 'Endpoint' position: 'Position' actions: confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Call Route' @@ -23,8 +22,7 @@ de: page_title: 'Call Route bearbeiten' routing_table: 'Routing Table' name: 'Name' - endpoint_type: 'Endpoint type' - endpoint_id: 'Endpoint' + endpoint: 'Endpoint' position: 'Position' actions: confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' diff --git a/config/locales/views/call_routes/en.yml b/config/locales/views/call_routes/en.yml index 25e4c51..8596474 100644 --- a/config/locales/views/call_routes/en.yml +++ b/config/locales/views/call_routes/en.yml @@ -9,8 +9,7 @@ en: page_title: 'Listing Call route' table: 'Table' name: 'Name' - endpoint_type: 'Endpoint type' - endpoint_id: 'Endpoint' + endpoint: 'Endpoint' position: 'Position' actions: confirm_destroy: 'Are you sure you want to delete this Call route?' @@ -23,8 +22,7 @@ en: page_title: 'Show Call route' table: 'Table' name: 'Name' - endpoint_type: 'Endpoint type' - endpoint_id: 'Endpoint' + endpoint: 'Endpoint' position: 'Position' actions: confirm_destroy: 'Are you sure you want to delete this element?' -- cgit v1.2.3 From 7f751576ae36f387bafa63e900fa21353a2ce3fb Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 28 Jan 2013 10:11:39 +0100 Subject: sip_registration model added --- app/models/sip_registration.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/models/sip_registration.rb diff --git a/app/models/sip_registration.rb b/app/models/sip_registration.rb new file mode 100644 index 0000000..b668301 --- /dev/null +++ b/app/models/sip_registration.rb @@ -0,0 +1,21 @@ +class SipRegistration < ActiveRecord::Base + # Makes sure that this is a readonly model. + def readonly? + return true + end + + # Prevent objects from being destroyed + def before_destroy + raise ActiveRecord::ReadOnlyRecord + end + + # Prevent objects from being deleted + def self.delete_all + raise ActiveRecord::ReadOnlyRecord + end + + # Prevent objects from being deleted + def delete + raise ActiveRecord::ReadOnlyRecord + end +end -- cgit v1.2.3 From 3e66e066c2f19a8b27233dff1abdf3908debae36 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 28 Jan 2013 10:12:40 +0100 Subject: use sip_registration in sip_views --- app/models/sip_account.rb | 2 +- app/views/sip_accounts/show.html.haml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index d35f9b4..444eb12 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -133,7 +133,7 @@ class SipAccount < ActiveRecord::Base end def registration - return FreeswitchRegistration.where(:reg_user => self.auth_name).first + return SipRegistration.where(:sip_user => self.auth_name).first end def call( phone_number ) diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index c21b3f4..72e10df 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -55,6 +55,13 @@ %strong= t('sip_accounts.show.expires') + ":" %td = "#{@sip_account.registration.try(:expires) - Time.now.to_i} s" + - if @sip_account.registration.try(:user_agent) + %tr + %td + %strong= t('sip_accounts.show.user_agent') + ":" + %td + = @sip_account.registration.try(:user_agent) + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account } -- cgit v1.2.3 From 5908ea469819cfcd7e05ce2f22ffe1412d474b7e Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 28 Jan 2013 10:17:42 +0100 Subject: translations --- config/locales/views/sip_accounts/de.yml | 1 + config/locales/views/sip_accounts/en.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/config/locales/views/sip_accounts/de.yml b/config/locales/views/sip_accounts/de.yml index e711137..2820336 100644 --- a/config/locales/views/sip_accounts/de.yml +++ b/config/locales/views/sip_accounts/de.yml @@ -40,6 +40,7 @@ de: callforward_rules_act_per_sip_account: 'Rufweiterleitungen gelten für das gesamte SIP-Account' registration: 'Registrierung' expires: 'Läuft ab' + user_agent: 'User Agent' actions: confirm_destroy: 'Sind Sie sicher, dass Sie diesen SIP-Account löschen möchten?' destroy: 'Löschen' diff --git a/config/locales/views/sip_accounts/en.yml b/config/locales/views/sip_accounts/en.yml index 99d14b5..aa934e9 100644 --- a/config/locales/views/sip_accounts/en.yml +++ b/config/locales/views/sip_accounts/en.yml @@ -40,6 +40,7 @@ en: callforward_rules_act_per_sip_account: 'Callforwards work for the whole sip account' registration: 'Registration' expires: 'Expires' + user_agent: 'User Agent' actions: confirm_destroy: 'Are you sure you want to delete this SIP account?' destroy: 'Delete' -- cgit v1.2.3 From 553115fd50ef3c35d961fa98abfd593386da5c94 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 28 Jan 2013 11:07:14 +0100 Subject: fax document count fixed --- app/views/fax_accounts/_index_core.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/fax_accounts/_index_core.html.haml b/app/views/fax_accounts/_index_core.html.haml index f86a4ac..d694f8f 100644 --- a/app/views/fax_accounts/_index_core.html.haml +++ b/app/views/fax_accounts/_index_core.html.haml @@ -28,9 +28,11 @@ %br = truncate(fax_account.station_id, :length => 20) %td - = link_to fax_account.fax_documents.inbound.count, fax_account_fax_documents_path(fax_account, :anchor => "fax_document_#{fax_account.fax_documents.inbound.first.try(:id)}") + - inbound_documents = fax_account.fax_documents.where(:inbound => true) + - outbound_documents = fax_account.fax_documents.where(:inbound => [false, nil]) + = link_to inbound_documents.count, fax_account_fax_documents_path(fax_account, :anchor => "fax_document_#{inbound_documents.first.try(:id)}") = '/' - = link_to fax_account.fax_documents.outbound.count, fax_account_fax_documents_path(fax_account, :anchor => "fax_document_#{fax_account.fax_documents.outbound.first.try(:id)}") + = link_to outbound_documents.count, fax_account_fax_documents_path(fax_account, :anchor => "fax_document_#{outbound_documents.first.try(:id)}") - if fax_account.fax_documents.any? %br %small -- cgit v1.2.3