From fd07b7b85d2d40d7d2999c2899cc890eda2095fd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:41:55 -0500 Subject: more polymorphic objects --- app/controllers/call_forwards_controller.rb | 14 ++++++++------ app/controllers/ringtones_controller.rb | 11 ++++++----- app/models/call_forward.rb | 3 +-- app/models/ringtone.rb | 14 ++++++++++++++ app/models/sip_account.rb | 2 ++ app/views/call_forwards/_form_core.html.haml | 6 +----- app/views/call_forwards/_index_core.html.haml | 10 +--------- app/views/call_forwards/show.html.haml | 8 +------- app/views/ringtones/_form_core.html.haml | 2 +- app/views/ringtones/_index_core.html.haml | 4 ++-- app/views/ringtones/index.html.haml | 4 ++-- app/views/sip_accounts/show.html.haml | 7 +++++++ app/views/users/show.html.haml | 2 +- config/routes.rb | 1 + 14 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index cd72a38..34fb77a 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -48,8 +48,8 @@ class CallForwardsController < ApplicationController @call_forward = @parent.call_forwards.build( params[:call_forward] ) if @call_forward.save - m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) - redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_created') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_created') else @available_call_forward_cases = CallForwardCase.all render :new @@ -64,8 +64,8 @@ class CallForwardsController < ApplicationController def update @available_call_forward_cases = CallForwardCase.all if @call_forward.update_attributes(params[:call_forward]) - m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) - redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_updated') else @call_forwarding_destinations = call_forwarding_destination_types() render :edit @@ -74,7 +74,8 @@ class CallForwardsController < ApplicationController def destroy @call_forward.destroy - redirect_to :root, :notice => t('call_forwards.controller.successfuly_destroyed') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_destroyed') end private @@ -110,7 +111,8 @@ class CallForwardsController < ApplicationController add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account) end - add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@parent) + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + add_breadcrumb t("call_forwards.index.page_title"), m.(@parent) if @call_forward && !@call_forward.new_record? m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) add_breadcrumb @call_forward, m.(@parent, @call_forward) diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index 7ffe30e..f726650 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -1,7 +1,8 @@ class RingtonesController < ApplicationController load_resource :phone_number + load_resource :sip_account load_resource :boss_assistant_cooperation - load_and_authorize_resource :ringtone, :through => [:phone_number, :boss_assistant_cooperation] + load_and_authorize_resource :ringtone, :through => [:phone_number, :sip_account, :boss_assistant_cooperation] before_filter :set_parent before_filter :spread_breadcrumbs @@ -19,7 +20,7 @@ class RingtonesController < ApplicationController def create @ringtone = @parent.ringtones.build(params[:ringtone]) if @ringtone.save - redirect_to phone_number_ringtone_path(@parent, @ringtone), :notice => t('ringtones.controller.successfuly_created') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_created') else render :new end @@ -30,7 +31,7 @@ class RingtonesController < ApplicationController def update if @ringtone.update_attributes(params[:ringtone]) - redirect_to method( :"#{@parent.class.name.underscore}_ringtone_path" ).(@ringtone.ringtoneable, @ringtone), :notice => t('ringtones.controller.successfuly_updated') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_updated') else render :edit end @@ -38,12 +39,12 @@ class RingtonesController < ApplicationController def destroy @ringtone.destroy - redirect_to phone_number_ringtones_path(@parent), :notice => t('ringtones.controller.successfuly_destroyed') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_destroyed') end private def set_parent - @parent = @phone_number || @boss_assistant_cooperation + @parent = @phone_number || @boss_assistant_cooperation || @sip_account end def spread_breadcrumbs diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index b304439..a932e11 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -24,8 +24,8 @@ class CallForward < ActiveRecord::Base belongs_to :call_forward_case - validates_presence_of :depth validates_numericality_of :depth, + :allow_nil => true, :only_integer => true, :greater_than_or_equal_to => 1, :less_than_or_equal_to => (GsParameter.get('MAX_CALL_FORWARD_DEPTH').nil? ? 0 : GsParameter.get('MAX_CALL_FORWARD_DEPTH')) @@ -59,7 +59,6 @@ class CallForward < ActiveRecord::Base before_save :split_and_format_destination_numbers after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } - before_destroy :check_if_other_callforward_rules_have_to_be_destroyed before_destroy :deactivate_connected_softkeys def case_string diff --git a/app/models/ringtone.rb b/app/models/ringtone.rb index 36053c0..45ecd93 100644 --- a/app/models/ringtone.rb +++ b/app/models/ringtone.rb @@ -1,11 +1,25 @@ class Ringtone < ActiveRecord::Base attr_accessible :audio, :bellcore_id + CORE_RINGTONES_AVAILABLE = { + 'Silence' => 0, + 'Ringtone 1' => 1, + 'Ringtone 2' => 2, + 'Ringtone 3' => 3, + 'Ringtone 4' => 4, + 'Ringtone 5' => 5, + 'Ringtone 6' => 6, + 'Ringtone 7' => 7, + 'Ringtone 8' => 8, + 'Ringtone 9' => 9, + 'Ringtone 10' => 10, + } mount_uploader :audio, AudioUploader validates_presence_of :audio, :if => Proc.new{ |ringtone| ringtone.bellcore_id.blank? } validates_presence_of :ringtoneable_type validates_presence_of :ringtoneable_id validates_presence_of :ringtoneable + validates_uniqueness_of :ringtoneable_id, :scope => [:ringtoneable_type] belongs_to :ringtoneable, :polymorphic => true diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index a39982b..034af7c 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -36,6 +36,8 @@ class SipAccount < ActiveRecord::Base has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true has_many :groups, :through => :group_memberships + has_many :ringtones, :as => :ringtoneable, :dependent => :destroy + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true diff --git a/app/views/call_forwards/_form_core.html.haml b/app/views/call_forwards/_form_core.html.haml index b751fb3..83de044 100644 --- a/app/views/call_forwards/_form_core.html.haml +++ b/app/views/call_forwards/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case_id.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false, :autofocus => true + = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false, :autofocus => true = f.input :timeout, :label => t('call_forwards.form.timeout.label'), :hint => conditional_hint('call_forwards.form.timeout.hint') = f.input :call_forwarding_destination , :as => :select, :collection => @call_forwarding_destinations, :label => t('call_forwards.form.call_forwarding_destination.label'), :hint => conditional_hint('call_forwards.form.call_forwarding_destination.hint'), :include_blank => false @@ -8,8 +8,4 @@ = f.input :source, :label => t('call_forwards.form.source.label'), :hint => conditional_hint('call_forwards.form.source.hint') - - if GuiFunction.display?('depth_field_in_call_forward_form', current_user) - = f.input :depth, :collection => 1..GsParameter.get('MAX_CALL_FORWARD_DEPTH'), :label => t('call_forwards.form.depth.label'), :hint => conditional_hint('call_forwards.form.depth.hint') - - else - = f.hidden_field :depth = f.input :active, :label => t('call_forwards.form.active.label'), :hint => conditional_hint('call_forwards.form.active.hint') diff --git a/app/views/call_forwards/_index_core.html.haml b/app/views/call_forwards/_index_core.html.haml index 48afa54..221baf2 100644 --- a/app/views/call_forwards/_index_core.html.haml +++ b/app/views/call_forwards/_index_core.html.haml @@ -1,21 +1,15 @@ %table.table.table-striped %thead %tr - - if !@phone_number - %th= t('call_forwards.index.call_forwardable') - %th= t('call_forwards.index.call_forward_case_id') + %th= t('call_forwards.index.call_forward_case') %th= t('call_forwards.index.timeout') %th= t('call_forwards.index.destination') %th= t('call_forwards.index.source') - - if GuiFunction.display?('depth_field_value_in_index_table', current_user) - %th= t('call_forwards.index.depth') %th= t('call_forwards.index.active') %tbody - for call_forward in call_forwards %tr - - if !@phone_number - %td= call_forward.call_forwardable %td= t("call_forward_cases.#{call_forward.call_forward_case.value}") %td= call_forward.timeout %td @@ -26,7 +20,5 @@ - if call_forward.destinationable_id = ": #{call_forward.destinationable}" %td= call_forward.source - - if GuiFunction.display?('depth_field_value_in_index_table', current_user) - %td= call_forward.depth %td= call_forward.active =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.call_forwardable, :child => call_forward} \ No newline at end of file diff --git a/app/views/call_forwards/show.html.haml b/app/views/call_forwards/show.html.haml index 9f9d27a..ad9ab16 100644 --- a/app/views/call_forwards/show.html.haml +++ b/app/views/call_forwards/show.html.haml @@ -1,8 +1,5 @@ - content_for :title, t("call_forwards.show.page_title") -%p - %strong= t('call_forwards.show.call_forwardable') + ":" - = "#{@call_forward.call_forwardable_type}: #{@call_forward.call_forwardable}" %p %strong= t('call_forwards.show.call_forward_case') + ":" = t("call_forward_cases.#{@call_forward.call_forward_case.value}") @@ -21,11 +18,8 @@ %p %strong= t('call_forwards.show.source') + ":" = @call_forward.source -%p - %strong= t('call_forwards.show.depth') + ":" - = @call_forward.depth %p %strong= t('call_forwards.show.active') + ":" = @call_forward.active -= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @call_forward } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @call_forward } diff --git a/app/views/ringtones/_form_core.html.haml b/app/views/ringtones/_form_core.html.haml index e44c950..de1cc38 100644 --- a/app/views/ringtones/_form_core.html.haml +++ b/app/views/ringtones/_form_core.html.haml @@ -1,3 +1,3 @@ .inputs / = f.input :audio, :label => t('ringtones.form.audio.label'), :hint => conditional_hint('ringtones.form.audio.hint') - = f.input :bellcore_id, :collection => 0..10, :label => t('ringtones.form.bellcore_id.label'), :hint => conditional_hint('ringtones.form.bellcore_id.hint'), :include_blank => true + = f.input :bellcore_id, :collection => Ringtone::CORE_RINGTONES_AVAILABLE, :label => t('ringtones.form.bellcore_id.label'), :hint => conditional_hint('ringtones.form.bellcore_id.hint'), :include_blank => false diff --git a/app/views/ringtones/_index_core.html.haml b/app/views/ringtones/_index_core.html.haml index 715db3c..51347a5 100644 --- a/app/views/ringtones/_index_core.html.haml +++ b/app/views/ringtones/_index_core.html.haml @@ -1,12 +1,12 @@ %table.table.table-striped %thead %tr - %th= t('ringtones.index.audio') + /%th= t('ringtones.index.audio') %th= t('ringtones.index.bellcore_id') %tbody - for ringtone in ringtones %tr - %td= ringtone.audio + /%td= ringtone.audio %td= ringtone.bellcore_id =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => ringtone.ringtoneable, :child => ringtone} \ No newline at end of file diff --git a/app/views/ringtones/index.html.haml b/app/views/ringtones/index.html.haml index 2eea5fe..2e316a5 100644 --- a/app/views/ringtones/index.html.haml +++ b/app/views/ringtones/index.html.haml @@ -2,5 +2,5 @@ - if @ringtones.count > 0 = render "index_core", :ringtones => @ringtones - -= render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => Ringtone} \ No newline at end of file +- else + = render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => Ringtone} \ No newline at end of file diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index 72e10df..0a332af 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -72,6 +72,13 @@ %br = render :partial => 'shared/create_link', :locals => { :parent => @sip_account, :child_class => PhoneNumber } +- if @sip_account.call_forwards.count > 0 || can?(:create, @sip_account.call_forwards.build) + %h2= t('call_forwards.index.page_title') + - if @sip_account.call_forwards.count > 0 + = render "call_forwards/index_core", :call_forwards => @sip_account.call_forwards + %br + = render :partial => 'shared/create_link', :locals => { :parent => @sip_account, :child_class => CallForward } + - if @sip_account.softkeys.count > 0 || can?(:create, @sip_account.softkeys.build) %h2= t("softkeys.index.page_title") - if @sip_account.softkeys.count > 0 diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 0f6cc2c..8882c08 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -38,7 +38,7 @@ %br =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) %br - =link_to t("call_forwards.index.page_title"), phone_number_call_forwards_path(phone_number) + =link_to t("call_forwards.index.page_title"), sip_account_call_forwards_path(sip_account) %br =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) %br diff --git a/config/routes.rb b/config/routes.rb index 03fd4cf..b6943ab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -254,6 +254,7 @@ Gemeinschaft42c::Application.routes.draw do resources :phone_numbers resources :softkeys resources :call_forwards + resources :ringtones resources :call_histories do collection do delete 'destroy_multiple' -- cgit v1.2.3 From 3ce588cd21c15acc0f7c66339d68e7651a798cc6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:43:54 -0500 Subject: destinationable columns added../db/migrate/20130225091200_add_destinationable_to_call_forward.rb --- ...225091200_add_destinationable_to_call_forward.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 db/migrate/20130225091200_add_destinationable_to_call_forward.rb diff --git a/db/migrate/20130225091200_add_destinationable_to_call_forward.rb b/db/migrate/20130225091200_add_destinationable_to_call_forward.rb new file mode 100644 index 0000000..89e4b3b --- /dev/null +++ b/db/migrate/20130225091200_add_destinationable_to_call_forward.rb @@ -0,0 +1,21 @@ +class AddDestinationableToCallForward < ActiveRecord::Migration + def up + add_column :call_forwards, :destinationable_type, :string + add_column :call_forwards, :destinationable_id, :integer + + CallForward.all.each do |call_forward| + call_forward.update_attributes(:destinationable_type => call_forward.call_forwardable_type, :destinationable_id => call_forward.call_forwardable_id, :call_forwardable_type => 'PhoneNumber', :call_forwardable_id => call_forward.phone_number_id ) + end + + remove_column :call_forwards, :phone_number_id + end + + def down + add_column :call_forwards, :phone_number_id, :integer + CallForward.where(:call_forwardable_type => 'PhoneNumber').each do |call_forward| + call_forward.update_attributes(:phone_number_id => call_forward.call_forwardable_id, :call_forwardable_type => call_forward.destinationable_type, :call_forwardable_id => call_forward.destinationable_id) + end + remove_column :call_forwards, :destinationable_type + remove_column :call_forwards, :destinationable_id + end +end -- cgit v1.2.3 From 26e2e09b20f7f775942b415df6eb55ddb7193879 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:57:28 -0500 Subject: sip_account ringtone as default --- app/views/users/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 8882c08..d3b1cf3 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -44,7 +44,7 @@ %br =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) %br - =link_to t("ringtones.show.page_title"), phone_number_ringtones_path(phone_number) + =link_to t("ringtones.show.page_title"), sip_account_ringtones_path(sip_account) - if @user.conferences.any? %p -- cgit v1.2.3 From c6d5308480df11e3ebc829a3fa7df8f0453c9630 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:57:55 -0500 Subject: edit ringtone --- app/views/sip_accounts/show.html.haml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index 0a332af..bf9d692 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -65,6 +65,13 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account } +%p + %strong= t('ringtones.name') + ':' + - if @sip_account.ringtones.count > 0 + = link_to @sip_account.ringtones.first, sip_account_ringtone_path(@sip_account, @sip_account.ringtones.first) + - else + = link_to t('ringtones.set_a_ringtone'), new_sip_account_ringtone_path(@sip_account) + - if @sip_account.phone_numbers.count > 0 || can?(:create, @sip_account.phone_numbers.build) %h2= t('phone_numbers.index.page_title') - if @sip_account.phone_numbers.count > 0 -- cgit v1.2.3 From dca264b22845b7875b9493c17cc185e809372cc1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:58:20 -0500 Subject: use dialplan ringtone as default --- app/controllers/ringtones_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index f726650..e5a4f64 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -15,6 +15,7 @@ class RingtonesController < ApplicationController def new @ringtone = @parent.ringtones.build + @ringtone.bellcore_id = GsParameter.get('default_ringtone', 'dialplan', 'parameters') end def create -- cgit v1.2.3 From 08285c5324b03c307d34313d5030a6e95ed09068 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 17:11:00 -0500 Subject: return active groups only --- misc/freeswitch/scripts/common/group.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/misc/freeswitch/scripts/common/group.lua b/misc/freeswitch/scripts/common/group.lua index 1a2d315..c4125bc 100644 --- a/misc/freeswitch/scripts/common/group.lua +++ b/misc/freeswitch/scripts/common/group.lua @@ -48,6 +48,7 @@ function Group.name_id_by_permission(self, member_id, member_type, permission) WHERE `b`.`item_type` = ' .. self.database:escape(member_type, '"') .. ' \ AND `b`.`item_id` = ' .. member_id .. ' \ AND `a`.`permission` = ' .. self.database:escape(permission, '"') .. ' \ + AND `c`.`active` IS TRUE \ GROUP BY `b`.`group_id` LIMIT ' .. MAX_GROUP_MEMBERSHIPS; local group_names = {}; @@ -72,6 +73,7 @@ function Group.name_id_by_member(self, member_id, member_type) JOIN `groups` `c` ON `c`.`id` = `b`.`group_id` \ WHERE `b`.`item_type` = ' .. self.database:escape(member_type, '"') .. ' \ AND `b`.`item_id` = ' .. member_id .. ' \ + AND `c`.`active` IS TRUE \ GROUP BY `b`.`group_id` LIMIT ' .. MAX_GROUP_MEMBERSHIPS; local group_names = {}; -- cgit v1.2.3 From 04bcdeca551f21748becfbf610e6ea2001c18bc1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 17:12:34 -0500 Subject: icons --- app/views/groups/_index_core.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/groups/_index_core.html.haml b/app/views/groups/_index_core.html.haml index d99874a..3a444bf 100644 --- a/app/views/groups/_index_core.html.haml +++ b/app/views/groups/_index_core.html.haml @@ -1,13 +1,17 @@ %table.table.table-striped %tr + %th %th= t('groups.index.name') - %th= t('groups.index.active') %th= t('groups.index.comment') - for group in groups %tr + %td + -if group.active + %i.icon-ok + - else + %i.icon-ban-circle %td= group.name - %td= group.active %td= group.comment =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => group} \ No newline at end of file -- cgit v1.2.3 From 90ccb06c88c920c0a21282acf86c0ecad6b6310a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 17:12:49 -0500 Subject: icons --- app/views/call_forwards/_index_core.html.haml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/call_forwards/_index_core.html.haml b/app/views/call_forwards/_index_core.html.haml index 221baf2..3c57405 100644 --- a/app/views/call_forwards/_index_core.html.haml +++ b/app/views/call_forwards/_index_core.html.haml @@ -1,15 +1,20 @@ %table.table.table-striped %thead %tr + %th %th= t('call_forwards.index.call_forward_case') %th= t('call_forwards.index.timeout') %th= t('call_forwards.index.destination') - %th= t('call_forwards.index.source') - %th= t('call_forwards.index.active') + %th= t('call_forwards.index.source') %tbody - for call_forward in call_forwards %tr + %td + -if call_forward.active + %i.icon-ok + - else + %i.icon-ban-circle %td= t("call_forward_cases.#{call_forward.call_forward_case.value}") %td= call_forward.timeout %td @@ -20,5 +25,5 @@ - if call_forward.destinationable_id = ": #{call_forward.destinationable}" %td= call_forward.source - %td= call_forward.active - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.call_forwardable, :child => call_forward} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.call_forwardable, :child => call_forward} + -- cgit v1.2.3 From cf89633baaa6e9bc901c2cc630ed2c94296109f1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 18:02:59 -0500 Subject: callforward_rules_act_per_sip_account removed from views --- app/views/sip_accounts/_form_core.html.haml | 2 -- app/views/sip_accounts/show.html.haml | 5 ----- 2 files changed, 7 deletions(-) diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index 1a09912..d7c65d0 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -13,6 +13,4 @@ - if @sip_account.sip_accountable_type == 'User' = f.input :hotdeskable, :label => t('sip_accounts.form.hotdeskable.label'), :hint => conditional_hint('sip_accounts.form.hotdeskable.hint') = f.input :clip_no_screening, :label => t('sip_accounts.form.clip_no_screening.label'), :hint => conditional_hint('sip_accounts.form.clip_no_screening.hint') - - if CallForward.where(:call_forwardable_id => @sip_account.phone_number_ids, :call_forwardable_type => 'PhoneNumber').count == 0 || @sip_account.callforward_rules_act_per_sip_account == true - = f.input :callforward_rules_act_per_sip_account, :label => t('sip_accounts.form.callforward_rules_act_per_sip_account.label'), :hint => conditional_hint('sip_accounts.form.callforward_rules_act_per_sip_account.hint') = f.input :language_code, :collection => Language.all.collect{|l| [l.to_s, l.code]}, :label => t('sip_accounts.form.language_code.label'), :hint => conditional_hint('sip_accounts.form.language_id.hint'), :include_blank => false diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index bf9d692..ede5150 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -37,11 +37,6 @@ %strong= t('sip_accounts.show.hotdeskable') + ":" %td = @sip_account.hotdeskable == true ? t('simple_form.yes') : t('simple_form.no') - %tr - %td - %strong= t('sip_accounts.show.callforward_rules_act_per_sip_account') + ":" - %td - = @sip_account.callforward_rules_act_per_sip_account == true ? t('simple_form.yes') : t('simple_form.no') - if @sip_account.registration.try(:network_ip) && @sip_account.registration.try(:network_port) %tr -- cgit v1.2.3 From 387ce8f6694b41ab73d264190ce41dcd13484ede Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 18:03:42 -0500 Subject: icons --- app/controllers/intruders_controller.rb | 2 +- app/views/intruders/_index_core.html.haml | 9 ++++++++- app/views/sip_accounts/_index_core.html.haml | 4 ++-- app/views/users/show.html.haml | 16 ++++++++++++---- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index 147e06d..99cb023 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -1,6 +1,6 @@ class IntrudersController < ApplicationController def index - @intruders = Intruder.all + @intruders = Intruder.order('list_type ASC, contact_last DESC').all spread_breadcrumbs end diff --git a/app/views/intruders/_index_core.html.haml b/app/views/intruders/_index_core.html.haml index 31bbd11..63f2253 100644 --- a/app/views/intruders/_index_core.html.haml +++ b/app/views/intruders/_index_core.html.haml @@ -16,7 +16,14 @@ - for intruder in intruders %tr - %td= intruder.list_type.chars.first + %td + - if intruder.list_type == 'whitelist' + %i.icon-ok + - elsif intruder.bans > 0 + %i.icon-fire + - elsif intruder.points > 0 + %i.icon-warning-sign + %td= intruder.contact_ip %td= intruder.contact_port %td= intruder.points diff --git a/app/views/sip_accounts/_index_core.html.haml b/app/views/sip_accounts/_index_core.html.haml index 34aac64..d98ea0a 100644 --- a/app/views/sip_accounts/_index_core.html.haml +++ b/app/views/sip_accounts/_index_core.html.haml @@ -20,13 +20,13 @@ - if sip_account.registration %i.icon-ok - else - %i.icon-thumbs-down + %i.icon-ban-circle %td = sip_account.caller_name - phone_numbers = sip_account.phone_numbers %td - if sip_account.phone_numbers.count > 0 - = render 'phone_numbers/listing', :phone_numbers => sip_account.phone_numbers.order(:number) + = render 'phone_numbers/listing', :phone_numbers => sip_account.phone_numbers.order(:position) - if sip_accounts.map{ |sip_account| sip_account.phone_sip_accounts.any? }.include?(true) %td %span.hidden-phone diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index d3b1cf3..8148005 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -29,10 +29,18 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } - @user.sip_accounts.each do |sip_account| - - phone_number = sip_account.phone_numbers.order(:number).last - - if phone_number && !phone_number.number.blank? && phone_number.number[0] != '+' - %p - %strong= sip_account.phone_numbers.order(:number).last.number + - phone_numbers = sip_account.phone_numbers.order(:position) + %p + - if phone_numbers[0] + %strong= phone_numbers[0].number + - else + %strong= sip_account.to_s + - if phone_numbers[1] + %strong= phone_numbers[1].number + - if phone_numbers[2] + %strong= phone_numbers[2].number + - if phone_numbers[3] + %strong ... %p =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) %br -- cgit v1.2.3 From ad2121462a9ea9a776756a188779a9d504f078b7 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 18:11:50 -0500 Subject: authorization added --- app/controllers/intruders_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index 99cb023..d3c767e 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -1,4 +1,6 @@ class IntrudersController < ApplicationController + load_and_authorize_resource :intruder + def index @intruders = Intruder.order('list_type ASC, contact_last DESC').all spread_breadcrumbs -- cgit v1.2.3