summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/gemeinschaft-generic.css.scss7
-rw-r--r--app/controllers/call_forwards_controller.rb48
-rw-r--r--app/controllers/calls_controller.rb24
-rw-r--r--app/controllers/conference_invitees_controller.rb2
-rw-r--r--app/controllers/fax_documents_controller.rb10
-rw-r--r--app/controllers/groups_controller.rb2
-rw-r--r--app/controllers/gs_parameters_controller.rb12
-rw-r--r--app/controllers/intruders_controller.rb3
-rw-r--r--app/controllers/softkeys_controller.rb8
-rw-r--r--app/controllers/trigger_controller.rb18
-rw-r--r--app/models/ability.rb16
-rw-r--r--app/models/backup_job.rb9
-rw-r--r--app/models/call.rb78
-rw-r--r--app/models/call_forward.rb2
-rw-r--r--app/models/fax_document.rb11
-rw-r--r--app/models/group.rb21
-rw-r--r--app/models/group_permission.rb2
-rw-r--r--app/models/intruder.rb86
-rw-r--r--app/models/route_element.rb2
-rw-r--r--app/models/sip_account.rb25
-rw-r--r--app/models/softkey.rb63
-rw-r--r--app/models/tenant.rb4
-rw-r--r--app/views/calls/_form_core.html.haml2
-rw-r--r--app/views/calls/_index_core.html.haml10
-rw-r--r--app/views/config_polycom/idle_screen.xml.haml17
-rw-r--r--app/views/fax_documents/_index_core.html.haml17
-rw-r--r--app/views/group_memberships/_index_core.html.haml3
-rw-r--r--app/views/group_memberships/show.html.haml4
-rw-r--r--app/views/groups/_form_core.html.haml2
-rw-r--r--app/views/groups/_index_core.html.haml10
-rw-r--r--app/views/gs_parameters/index.html.haml48
-rw-r--r--app/views/gs_parameters/show.html.haml10
-rw-r--r--app/views/intruders/_form_core.html.haml4
-rw-r--r--app/views/intruders/_index_core.html.haml25
-rw-r--r--app/views/intruders/index.html.haml9
-rw-r--r--app/views/phone_book_entries/show.html.haml27
-rw-r--r--app/views/phones/_form_core.html.haml2
-rw-r--r--app/views/phones/show.html.haml11
-rw-r--r--app/views/softkeys/_form_core.html.haml5
-rw-r--r--app/views/tenants/_table_of_automatic_call_distributors.html.haml2
-rw-r--r--app/views/tenants/_table_of_hunt_groups.html.haml2
-rw-r--r--app/views/users/show.html.haml5
42 files changed, 452 insertions, 216 deletions
diff --git a/app/assets/stylesheets/gemeinschaft-generic.css.scss b/app/assets/stylesheets/gemeinschaft-generic.css.scss
index 9448b84..515a5fe 100644
--- a/app/assets/stylesheets/gemeinschaft-generic.css.scss
+++ b/app/assets/stylesheets/gemeinschaft-generic.css.scss
@@ -32,6 +32,7 @@ input, textarea, .uneditable-input {
width: 96%;
}
}
+
input, textarea {
&.invalid {
box-shadow: inset -9px 0px 0px rgb(255, 219, 219), inset -14px 0px 0px rgb(255, 245, 245) !important;
@@ -46,7 +47,13 @@ select {
@media (max-width: 480px) {
width: 99.5%;
}
+}
+.form-horizontal {
+ input + .help-block, select + .help-block, textarea + .help-block {
+ font-size: 11px;
+ margin-top: 1px;
+ }
}
@media (max-width: 979px) {
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index 34fb77a..b30ee9e 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -1,7 +1,10 @@
class CallForwardsController < ApplicationController
load_resource :phone_number
load_resource :sip_account
- load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account]
+ load_resource :automatic_call_distributor
+ load_resource :hunt_group
+
+ load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account, :automatic_call_distributor, :hunt_group]
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
@@ -81,7 +84,7 @@ class CallForwardsController < ApplicationController
private
private
def set_and_authorize_parent
- @parent = @sip_account || @phone_number
+ @parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group
authorize! :read, @parent
end
@@ -90,27 +93,30 @@ class CallForwardsController < ApplicationController
if @parent.class == PhoneNumber && @parent.phone_numberable_type == 'SipAccount'
@sip_account = @parent.phone_numberable
end
- if @sip_account.sip_accountable_type == 'User'
- @user = @sip_account.sip_accountable
- if @parent.class == PhoneNumber
- add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
- add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
- add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
- add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account)
- add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account)
- add_breadcrumb @parent, sip_account_phone_number_path(@sip_account, @parent)
- elsif @parent.class == SipAccount
- add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
- add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
- add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
+
+ if @sip_account
+ if @sip_account.sip_accountable_type == 'User'
+ @user = @sip_account.sip_accountable
+ if @parent.class == PhoneNumber
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
+ add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
+ add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account)
+ add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account)
+ add_breadcrumb @parent, sip_account_phone_number_path(@sip_account, @parent)
+ elsif @parent.class == SipAccount
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
+ add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
+ end
+ end
+ if @sip_account.sip_accountable_type == 'Tenant'
+ @tenant = @sip_account.sip_accountable
+ add_breadcrumb t("sip_accounts.index.page_title"), tenant_sip_accounts_path(@tenant)
+ add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account)
end
end
- if @sip_account.sip_accountable_type == 'Tenant'
- @tenant = @sip_account.sip_accountable
- add_breadcrumb t("sip_accounts.index.page_title"), tenant_sip_accounts_path(@tenant)
- add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account)
- end
-
+
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?
diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb
index 5534b1b..9d85a10 100644
--- a/app/controllers/calls_controller.rb
+++ b/app/controllers/calls_controller.rb
@@ -3,6 +3,7 @@ class CallsController < ApplicationController
load_resource :call
before_filter :set_and_authorize_parent
+ before_filter :spread_breadcrumbs
def index
if @parent
@@ -17,11 +18,11 @@ class CallsController < ApplicationController
protocol, separator, phone_number = params[:url].partition(':')
if ! phone_number.blank?
@call = @parent.calls.new()
- @call.dest = phone_number
+ @call.destination = phone_number
end
elsif !params[:number].blank?
@call = @parent.calls.new()
- @call.dest = params[:number]
+ @call.destination = params[:number]
end
end
@@ -30,8 +31,7 @@ class CallsController < ApplicationController
end
def create
- params[:call][:sip_account] = @sip_account
- @call = Call.create(params[:call])
+ @call = @sip_account.calls.create(params[:call])
if @call && @call.call
m = method( :"#{@parent.class.name.underscore}_calls_url" )
@@ -55,4 +55,20 @@ class CallsController < ApplicationController
def set_and_authorize_parent
@parent = @sip_account
end
+
+ def spread_breadcrumbs
+ if @parent.class == SipAccount
+ if @sip_account.sip_accountable.class == User
+ add_breadcrumb t('users.name'), tenant_users_path(@sip_account.sip_accountable.current_tenant)
+ add_breadcrumb @sip_account.sip_accountable, tenant_user_path(@sip_account.sip_accountable.current_tenant, @sip_account.sip_accountable)
+ add_breadcrumb t('sip_accounts.index.page_title'), user_sip_accounts_path(@sip_account.sip_accountable)
+ add_breadcrumb @sip_account, user_sip_account_path(@sip_account.sip_accountable, @sip_account)
+ add_breadcrumb t('calls.index.page_title'), sip_account_calls_path(@sip_account)
+ elsif @sip_account.sip_accountable.class == Tenant
+ add_breadcrumb t('sip_accounts.index.page_title'), tenant_sip_accounts_path(@sip_account.sip_accountable)
+ add_breadcrumb @sip_account, tenant_sip_account_path(@sip_account.sip_accountable, @sip_account)
+ add_breadcrumb t('calls.index.page_title'), sip_account_calls_path(@sip_account)
+ end
+ end
+ end
end
diff --git a/app/controllers/conference_invitees_controller.rb b/app/controllers/conference_invitees_controller.rb
index ce55b5a..e891ebc 100644
--- a/app/controllers/conference_invitees_controller.rb
+++ b/app/controllers/conference_invitees_controller.rb
@@ -58,7 +58,7 @@ class ConferenceInviteesController < ApplicationController
def destroy
@conference_invitee.destroy
- redirect_to conference_invitees_url, :notice => t('conference_invitees.controller.successfuly_destroyed')
+ redirect_to conference_conference_invitees_url(@conference), :notice => t('conference_invitees.controller.successfuly_destroyed')
end
private
diff --git a/app/controllers/fax_documents_controller.rb b/app/controllers/fax_documents_controller.rb
index c2b3083..43852c6 100644
--- a/app/controllers/fax_documents_controller.rb
+++ b/app/controllers/fax_documents_controller.rb
@@ -61,8 +61,14 @@ class FaxDocumentsController < ApplicationController
@fax_document = @fax_account.fax_documents.build(params[:fax_document])
@fax_document.retry_counter = @fax_account.retries
if @fax_document.save
- @fax_document.queue_for_sending!
- redirect_to fax_account_fax_document_path(@fax_document.fax_account, @fax_document), :notice => t('fax_documents.controller.successfuly_created')
+ if @fax_document.tiff.blank?
+ @fax_document.destroy
+ @fax_document.errors.add(:document, t('fax_documents.controller.tiff_not_created'))
+ render :new
+ else
+ @fax_document.queue_for_sending!
+ redirect_to fax_account_fax_document_path(@fax_document.fax_account, @fax_document), :notice => t('fax_documents.controller.successfuly_created')
+ end
else
render :new
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 74ad7c8..d48707c 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -11,7 +11,7 @@ class GroupsController < ApplicationController
end
def new
- @group = Group.new
+ @group.active = true;
end
def create
diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb
index bd8b44b..106ce76 100644
--- a/app/controllers/gs_parameters_controller.rb
+++ b/app/controllers/gs_parameters_controller.rb
@@ -4,9 +4,15 @@ class GsParametersController < ApplicationController
before_filter :spread_breadcrumbs
def index
- @gs_parameters_unordered = GsParameter.scoped
- @gs_parameters = GsParameter.order([:section, :name])
- @sections = @gs_parameters.pluck(:section).uniq.sort
+ @gs_parameters = GsParameter.order([:entity, :section, :name])
+
+ @entities = Hash.new()
+ @gs_parameters.each do |parameter|
+ if !@entities[parameter.entity]
+ @entities[parameter.entity] = Hash.new()
+ end
+ @entities[parameter.entity][parameter.section] = true
+ end
end
def show
diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb
index d3c767e..bdda230 100644
--- a/app/controllers/intruders_controller.rb
+++ b/app/controllers/intruders_controller.rb
@@ -2,7 +2,8 @@ class IntrudersController < ApplicationController
load_and_authorize_resource :intruder
def index
- @intruders = Intruder.order('list_type ASC, contact_last DESC').all
+ @intruders = Intruder.order('list_type ASC, contact_last DESC')
+ @list_types = @intruders.pluck(:list_type).uniq.sort
spread_breadcrumbs
end
diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index c9e8c20..9179d8c 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -2,7 +2,7 @@ class SoftkeysController < ApplicationController
load_and_authorize_resource :sip_account, :except => [:sort]
load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort]
- before_filter :set_available_call_forwards_and_softkey_functions, :only => [ :new, :edit, :update ]
+ before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update ]
before_filter :spread_breadcrumbs, :except => [:sort]
def index
@@ -54,12 +54,8 @@ class SoftkeysController < ApplicationController
render nothing: true
end
-
private
-
- def set_available_call_forwards_and_softkey_functions
- @available_call_forwards = @softkey.possible_blf_call_forwards
-
+ def set_available_softkey_functions
@softkey_functions = []
SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function|
if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user)
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index 64a5f91..5e836c4 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -62,12 +62,14 @@ class TriggerController < ApplicationController
def fax
if !params[:fax_account_id].blank?
fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first
+ errors = Array.new()
if fax_account
fax_account.fax_documents.where(:state => 'received').each do |fax_document|
pdf_file = fax_document.tiff_to_pdf
if !pdf_file
+ errors << "#{fax_document.tiff} cound not be converted"
fax_document.state = 'unsuccessful'
fax_document.save
next
@@ -84,20 +86,26 @@ class TriggerController < ApplicationController
fax_document.state = 'successful'
if fax_document.save
+ Notifications.new_fax(fax_document).deliver
begin
File.delete(pdf_file)
rescue => e
logger.error "PDF fax file could not be deleted: #{pdf_file} => #{e.inspect}"
+ errors << "#{pdf_file} cound not be deleted"
end
- fax_document.tiff = nil
fax_document.save
fax_document.render_thumbnails
else
+ errors << "#{fax_document.id} cound not be saved"
fax_document.state = 'unsuccessful'
fax_document.save
end
end
-
+ else
+ errors << "fax_account=#{params[:fax_account_id]} not found"
+ end
+
+ if errors.count == 0
render(
:status => 200,
:layout => false,
@@ -105,11 +113,11 @@ class TriggerController < ApplicationController
:text => "<!-- OK -->",
)
else
- render(
- :status => 404,
+ render(
+ :status => 501,
:layout => false,
:content_type => 'text/plain',
- :text => "<!-- Account not found -->",
+ :text => "<!-- ERRORS: #{errors.join(', ')} -->",
)
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 48cce84..3cd1d4d 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -134,9 +134,6 @@ class Ability
can :read, SipAccount, :sip_accountable_type => 'User', :sip_accountable_id => user.id
user.sip_accounts.each do |sip_account|
can :read, PhoneNumber, :id => sip_account.phone_number_ids
- can :manage, CallForward, :call_forwardable_id => sip_account.phone_number_ids
- can :manage, Ringtone, :ringtoneable_type => 'PhoneNumber', :ringtoneable_id => sip_account.phone_number_ids
- can :manage, Ringtone, :ringtoneable_type => 'SipAccount', :ringtoneable_id => sip_account.id
can [:read, :destroy, :call] , CallHistory, :id => sip_account.call_history_ids
end
can :read, Phone, :phoneable_type => 'User', :phoneable_id => user.id
@@ -161,10 +158,17 @@ class Ability
can :manage, ConferenceInvitee, :conference_id => conference.id
end
- # User can manage CallForwards of the PhoneNumbers of his
- # own SipAccounts:
+ # User can manage CallForwards of its SipAccount and PhoneNumbers
#
- can :manage, CallForward, :call_forwardable_id => user.phone_number_ids
+ can :manage, CallForward, :call_forwardable_type => 'PhoneNumber', :call_forwardable_id => user.phone_number_ids
+ can :manage, CallForward, :call_forwardable_type => 'SipAccount', :call_forwardable_id => user.sip_account_ids
+ can :create, CallForward
+
+ # User can manage Ringtones of its SipAccount and PhoneNumbers
+ #
+ can :manage, Ringtone, :ringtoneable_type => 'PhoneNumber', :ringtoneable_id => user.phone_number_ids
+ can :manage, Ringtone, :ringtoneable_type => 'SipAccount', :ringtoneable_id => user.sip_account_ids
+ can :create, Ringtone
# SoftkeyFunctions
#
diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb
index a04f6c0..48dd27e 100644
--- a/app/models/backup_job.rb
+++ b/app/models/backup_job.rb
@@ -12,12 +12,17 @@ class BackupJob < ActiveRecord::Base
private
def set_state_to_queued
- self.state = 'queued'
+ self.state ||= 'queued'
self.started_at = Time.now
end
def initiate_backup
- self.delay.make_a_backup
+ if self.state == 'force now'
+ self.state = 'queued'
+ self.make_a_backup
+ else
+ self.delay.make_a_backup
+ end
end
def make_a_backup
diff --git a/app/models/call.rb b/app/models/call.rb
index db6d9d6..8f657fa 100644
--- a/app/models/call.rb
+++ b/app/models/call.rb
@@ -1,30 +1,32 @@
class Call < ActiveRecord::Base
- self.table_name = 'detailed_calls'
+ self.table_name = 'calls_active'
self.primary_key = 'uuid'
- attr_writer :sip_account_id
+ belongs_to :sip_account
+ belongs_to :b_sip_account, :class_name => SipAccount
- validates :dest,
+ validates :sip_account_id,
:presence => true
-
- def create(attributes=nil)
- if ! attributes
- return
- end
- self.sip_account = SipAccount.where(:id => attributes[:sip_account_id]).first
- self.dest = attributes[:dest]
- return self
+ validates :destination,
+ :presence => true
+
+ def save(attributes=nil)
end
- def save(attributes=nil)
-
- end
+ def call
+ if self.sip_account && self.destination
+ return self.sip_account.call(self.destination)
+ end
- def call(number=nil)
- if @sip_account && self.dest
- return @sip_account.call(self.dest)
+ if !self.sip_account
+ errors.add(:sip_account_id, 'no sip_account')
end
+
+ if self.destination.blank?
+ errors.add(:destination, 'no destination')
+ end
+
return false
end
@@ -37,38 +39,6 @@ class Call < ActiveRecord::Base
return FreeswitchAPI.execute('uuid_kill', self.uuid, true);
end
- def sip_account=(sip_a)
- @sip_account = sip_a
- end
-
- def sip_account
- if @sip_account
- return @sip_account
- end
-
- result = self.presence_id.match('^(.+)@(.+)$')
-
- if result && ! result[1].blank? and ! result[2].blank?
- domain = SipDomain.where(:host => result[2]).first
- if domain
- @sip_account = SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first
- end
- end
-
- return @sip_account
- end
-
- def sip_account_bleg
- result = self.b_presence_id.match('^(.+)@(.+)$')
-
- if result && ! result[1].blank? and ! result[2].blank?
- domain = SipDomain.where(:host => result[2]).first
- if domain
- return SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first
- end
- end
- end
-
def get_variable_from_uuid(channel_uuid, variable_name)
if channel_uuid.blank?
return nil
@@ -92,14 +62,4 @@ class Call < ActiveRecord::Base
return get_variable_from_uuid(self.b_uuid, variable_name);
end
- def is_sip
- return self.name.match('^sofia') != nil
- end
-
- def is_caller
- if (self.uuid == self.call_uuid) || self.call_uuid.blank?
- true
- end
- end
-
end
diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb
index a932e11..195ac36 100644
--- a/app/models/call_forward.rb
+++ b/app/models/call_forward.rb
@@ -177,7 +177,7 @@ class CallForward < ActiveRecord::Base
end
def deactivate_concurring_entries
- CallForward.where(:call_forwardable_id => self.call_forwardable_id, :call_forwardable_type => self.call_forwardable_type, :call_forward_case_id => self.call_forward_case_id, :active => true).each do |call_forwarding_entry|
+ CallForward.where(:call_forwardable_id => self.call_forwardable_id, :call_forwardable_type => self.call_forwardable_type, :call_forward_case_id => self.call_forward_case_id, :source => self.source, :active => true).each do |call_forwarding_entry|
if call_forwarding_entry.id != self.id
call_forwarding_entry.update_attributes(:active => false)
end
diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb
index 5b27965..3cb92ea 100644
--- a/app/models/fax_document.rb
+++ b/app/models/fax_document.rb
@@ -96,9 +96,18 @@ class FaxDocument < ActiveRecord::Base
page_size_command = "<< /Policies << /PageSize 3 >> /InputAttributes currentpagedevice /InputAttributes get dup { pop 1 index exch undef } forall dup 0 << /PageSize [ #{page_size_a4} ] >> put >> setpagedevice"
working_path, file_name = File.split(self.document.to_s)
tiff_file = File.basename(file_name.to_s.downcase, File.extname(file_name)) + '.tiff'
- result = system "cd #{store_dir} && gs -q -r#{self.fax_resolution.resolution_value} -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=\"#{tiff_file}\" -c \"#{page_size_command}\" -- \"#{self.document.to_s}\""
+ result = system "cd #{store_dir} && gs -q -r#{self.fax_resolution.resolution_value} -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=\"#{store_dir}/#{tiff_file}\" -c \"#{page_size_command}\" -- \"#{self.document.to_s}\""
if !File.exists?("#{store_dir}/#{tiff_file}")
+ page_size = "1728x1078" or "1728x1186";
+ command = "cd #{store_dir} && convert -quiet -density #{self.fax_resolution.resolution_value} -units PixelsPerInch -resize #{page_size}\! -monochrome -compress Fax \"#{self.document.to_s}\" \"#{store_dir}/#{tiff_file}\""
+ result = system(command)
+ if result.nil?
+ logger.error "### FAX_DOCUMENT_TO_TIFF - error: #{$?}, command: #{command}"
+ end
+ end
+
+ if !File.exists?("#{store_dir}/#{tiff_file}")
return nil
end
diff --git a/app/models/group.rb b/app/models/group.rb
index e0cfaab..6c65f70 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -5,7 +5,28 @@ class Group < ActiveRecord::Base
has_many :group_permissions, :dependent => :destroy
has_many :permittances, :foreign_key => :target_group_id, :class_name => "GroupPermission", :dependent => :destroy
+ validates :name,
+ :presence => true
+
def to_s
self.name
end
+
+ def permission_targets(permission)
+ group_permissions.where(:permission => permission).pluck(:target_group_id)
+ end
+
+ def has_permission(target_type, target_id, permission)
+ target_group_ids = GroupMembership.where(:item_id => target_id, :item_type => target_type).pluck(:group_id)
+ return group_permissions.where(:permission => permission, :target_group_id => target_group_ids).first != nil
+ end
+
+ def self.union(sets=[])
+ group_ids = []
+ sets.each do |set|
+ group_ids = group_ids + set
+ end
+
+ return group_ids.uniq
+ end
end
diff --git a/app/models/group_permission.rb b/app/models/group_permission.rb
index fe988ba..c859f52 100644
--- a/app/models/group_permission.rb
+++ b/app/models/group_permission.rb
@@ -1,7 +1,7 @@
class GroupPermission < ActiveRecord::Base
attr_accessible :group_id, :permission, :target_group_id
- PERMISSION_TYPES = ['pickup']
+ PERMISSION_TYPES = ['pickup', 'presence']
belongs_to :group
belongs_to :target_group, :class_name => "Group"
diff --git a/app/models/intruder.rb b/app/models/intruder.rb
index 97e3773..9a1c39a 100644
--- a/app/models/intruder.rb
+++ b/app/models/intruder.rb
@@ -17,6 +17,10 @@ class Intruder < ActiveRecord::Base
before_validation :set_key_if_empty
+ after_create :check_if_new_entry_relevant
+ after_update :check_if_update_relevant
+ after_destroy :check_if_delete_relevant
+
def to_s
key
end
@@ -31,26 +35,6 @@ class Intruder < ActiveRecord::Base
end
end
- def self.write_firewall_blacklist
- firewall_blacklist_file = GsParameter.get('blacklist_file', 'perimeter', 'general')
- entry_template = GsParameter.get('blacklist_file_entry', 'perimeter', 'general')
- comment_template = GsParameter.get('blacklist_file_comment', 'perimeter', 'general')
- File.open(firewall_blacklist_file, 'w') do |file|
- Intruder.where(:list_type => 'blacklist').where('bans > 0').all.each do |entry|
- if ! comment_template.blank?
- file.write(self.expand_variables(comment_template, entry.to_hash) + "\n")
- end
- file.write(self.expand_variables(entry_template, entry.to_hash) + "\n")
- end
- end
- end
-
- def self.expand_variables(line, variables)
- return line.gsub(/\{([a-z_]+)\}/) do |m|
- variables[$1.to_sym]
- end
- end
-
def to_hash
return {
:key => self.key,
@@ -72,4 +56,66 @@ class Intruder < ActiveRecord::Base
self.key = self.contact_ip
end
end
+
+ def expand_variables(line, variables)
+ return line.gsub(/\{([a-z_]+)\}/) do |m|
+ variables[$1.to_sym]
+ end
+ end
+
+ def write_firewall_list
+ firewall_blacklist_file = GsParameter.get('blacklist_file', 'perimeter', 'general')
+ blacklist_entry_template = GsParameter.get('blacklist_file_entry', 'perimeter', 'general')
+ whitelist_entry_template = GsParameter.get('whitelist_file_entry', 'perimeter', 'general')
+ comment_template = GsParameter.get('blacklist_file_comment', 'perimeter', 'general')
+ File.open(firewall_blacklist_file, 'w') do |file|
+ Intruder.where(:list_type => ['whitelist', 'blacklist']).order('list_type DESC, contact_last ASC').all.each do |entry|
+ if !whitelist_entry_template.blank? && entry.list_type == 'whitelist'
+ if ! comment_template.blank?
+ file.write(expand_variables(comment_template, entry.to_hash) + "\n")
+ end
+ file.write(expand_variables(whitelist_entry_template, entry.to_hash) + "\n")
+ elsif !blacklist_entry_template.blank? && entry.list_type == 'blacklist' && entry.bans.to_i > 0
+ if ! comment_template.blank?
+ file.write(expand_variables(comment_template, entry.to_hash) + "\n")
+ end
+ file.write(expand_variables(blacklist_entry_template, entry.to_hash) + "\n")
+ end
+ end
+ end
+ end
+
+ def restart_firewall
+ command = GsParameter.get('ban_command', 'perimeter', 'general')
+ if !command.blank?
+ system expand_variables(command, self.to_hash)
+ end
+ end
+
+ def check_if_update_relevant
+ if key_changed? || contact_ip_changed? || list_type_changed? || bans_changed? || points_changed?
+ if !GsParameter.get("#{self.list_type}_file_entry", 'perimeter', 'general').blank?
+ write_firewall_list
+ restart_firewall
+ end
+ end
+ end
+
+ def check_if_new_entry_relevant
+ if !GsParameter.get("#{self.list_type}_file_entry", 'perimeter', 'general').blank?
+ if self.list_type != 'blacklist' || self.bans.to_i > 0
+ write_firewall_list
+ restart_firewall
+ end
+ end
+ end
+
+ def check_if_delete_relevant
+ if !GsParameter.get("#{self.list_type}_file_entry", 'perimeter', 'general').blank?
+ if self.list_type != 'blacklist' || self.bans.to_i > 0
+ write_firewall_list
+ restart_firewall
+ end
+ end
+ end
end
diff --git a/app/models/route_element.rb b/app/models/route_element.rb
index 94f0f84..7d37db0 100644
--- a/app/models/route_element.rb
+++ b/app/models/route_element.rb
@@ -3,7 +3,7 @@ class RouteElement < ActiveRecord::Base
attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position
- belongs_to :call_route
+ belongs_to :call_route, :touch => true
acts_as_list :scope => :call_route
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 5660e37..cdb609d 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -38,7 +38,8 @@ class SipAccount < ActiveRecord::Base
has_many :ringtones, :as => :ringtoneable, :dependent => :destroy
- has_many :calls, :finder_sql => lambda { |s| "SELECT DISTINCT detailed_calls.* FROM detailed_calls WHERE presence_id LIKE '#{self.auth_name}@%' OR b_presence_id LIKE '#{self.auth_name}@%'" }
+ has_many :call_legs, :class_name => 'Call'
+ has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id'
# Delegations:
#
@@ -83,6 +84,10 @@ class SipAccount < ActiveRecord::Base
def to_s
truncate((self.caller_name || "SipAccount ID #{self.id}"), :length => GsParameter.get('TO_S_MAX_CALLER_NAME_LENGTH')) + " (#{truncate(self.auth_name, :length => GsParameter.get('TO_S_MAX_LENGTH_OF_AUTH_NAME'))}@...#{self.host.split(/\./)[2,3].to_a.join('.') if self.host })"
end
+
+ def calls
+ self.call_legs + self.b_call_legs
+ end
def call_forwarding_toggle( call_forwarding_service, to_voicemail = nil )
if ! self.phone_numbers.first
@@ -156,6 +161,24 @@ class SipAccount < ActiveRecord::Base
end
+ def target_sip_accounts_by_permission(permission)
+ target_groups = Group.union(self.groups.collect{|g| g.permission_targets(permission)})
+ target_groups = target_groups + Group.union(self.sip_accountable.groups.collect{|g| g.permission_targets(permission)})
+ sip_accounts = []
+ GroupMembership.where(:group_id => target_groups).each do |group_membership|
+ if group_membership.item.class == User || group_membership.item.class == Tenant
+ sip_accounts = sip_accounts + group_membership.item.sip_accounts
+ elsif group_membership.item.class == SipAccount
+ sip_accounts << group_membership.item
+ end
+
+ sip_accounts = sip_accounts.uniq
+ end
+
+ return sip_accounts
+ end
+
+
private
def save_value_of_to_s
diff --git a/app/models/softkey.rb b/app/models/softkey.rb
index 8049456..6063017 100644
--- a/app/models/softkey.rb
+++ b/app/models/softkey.rb
@@ -22,29 +22,28 @@ class Softkey < ActiveRecord::Base
after_save :resync_phone
after_destroy :resync_phone
- def possible_blf_call_forwards
- if self.sip_account.phone_numbers.count == 0
- nil
- else
- if self.sip_account.callforward_rules_act_per_sip_account == true
- # We pick one phone_number and display the rules of it.
- #
- phone_number = self.sip_account.phone_numbers.order(:number).first
- call_forwards = self.sip_account.call_forwards.where(:call_forwardable_id => phone_number.id, :call_forwardable_type => 'PhoneNumber')
- else
- call_forwards = self.sip_account.call_forwards
- end
-
- phone_numbers_ids = self.sip_account.phone_number_ids
- phone_numbers = PhoneNumber.where(:id => phone_numbers_ids).pluck(:number)
+ def possible_call_forwards
+ call_forwards = self.sip_account.call_forwards
+ self.sip_account.phone_numbers.each do |phone_number|
+ call_forwards = call_forwards + phone_number.call_forwards
+ end
- hunt_group_ids = PhoneNumber.where(:phone_numberable_type => 'HuntGroupMember', :number => phone_numbers).
- map{ |phone_number| phone_number.phone_numberable.hunt_group.id }.
- uniq
- call_forwards + CallForward.where(:destinationable_type => 'HuntGroup', :destinationable_id => hunt_group_ids, :call_forwardable_type => 'PhoneNumber').
- where('call_forwardable_id NOT IN (?)', phone_numbers_ids)
- end
+ phone_numbers_ids = self.sip_account.phone_number_ids
+ phone_numbers = PhoneNumber.where(:id => phone_numbers_ids).pluck(:number)
+
+ hunt_group_ids = PhoneNumber.where(:phone_numberable_type => 'HuntGroupMember', :number => phone_numbers).
+ map{ |phone_number| phone_number.phone_numberable.hunt_group.id }.
+ uniq
+
+ call_forwards = call_forwards + CallForward.where(:destinationable_type => 'HuntGroup', :destinationable_id => hunt_group_ids, :call_forwardable_type => 'PhoneNumber').
+ where('call_forwardable_id NOT IN (?)', phone_numbers_ids)
+
+ return call_forwards
+ end
+
+ def possible_blf_sip_accounts
+ self.sip_account.target_sip_accounts_by_permission('presence')
end
def to_s
@@ -82,7 +81,29 @@ class Softkey < ActiveRecord::Base
if self.softkey_function_id != nil
case self.softkey_function.name
when 'blf'
+ has_permission = false
self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'SipAccount').first.try(:phone_numberable)
+ if self.softkeyable
+ self.sip_account.groups.each do |group|
+ if group.has_permission(self.softkeyable.class.name, self.softkeyable.id, :presence)
+ has_permission = true
+ break
+ end
+ end
+ if !has_permission && self.sip_account.sip_accountable
+ self.sip_account.sip_accountable.groups.each do |group|
+ if group.has_permission(self.softkeyable.class.name, self.softkeyable.id, :presence)
+ has_permission = true
+ break
+ end
+ end
+ end
+ end
+
+ if !has_permission
+ self.softkeyable = nil
+ self.number = nil
+ end
when 'conference'
self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'Conference').first.try(:phone_numberable)
when 'call_forwarding'
diff --git a/app/models/tenant.rb b/app/models/tenant.rb
index 0622f52..ffa68a7 100644
--- a/app/models/tenant.rb
+++ b/app/models/tenant.rb
@@ -59,6 +59,10 @@ class Tenant < ActiveRecord::Base
has_many :users_fax_accounts, :through => :users, :source => :fax_accounts, :readonly => true
has_many :users_fax_accounts_phone_numbers, :through => :users_fax_accounts, :source => :phone_numbers, :readonly => true
+ # Groups
+ has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true
+ has_many :groups, :through => :group_memberships
+
# Validations:
#
validates_presence_of :name, :state, :country, :language
diff --git a/app/views/calls/_form_core.html.haml b/app/views/calls/_form_core.html.haml
index 4cdd55e..ec795f2 100644
--- a/app/views/calls/_form_core.html.haml
+++ b/app/views/calls/_form_core.html.haml
@@ -1,2 +1,2 @@
.inputs
- = f.input :dest, :as => :string, :label => t('calls.form.destination.label'), :hint => conditional_hint('calls.form.destination.hint'), :autofocus => true
+ = f.input :destination, :as => :string, :label => t('calls.form.destination.label'), :hint => conditional_hint('calls.form.destination.hint'), :autofocus => true
diff --git a/app/views/calls/_index_core.html.haml b/app/views/calls/_index_core.html.haml
index e5b769e..5ed5538 100644
--- a/app/views/calls/_index_core.html.haml
+++ b/app/views/calls/_index_core.html.haml
@@ -19,17 +19,17 @@
- else
%i.icon-arrow-right
%td
- = call.created
+ = l Time.at(call.start_stamp), :format => :short
%td
- = call.dest
+ = call.destination
%td
- = "#{call.cid_name} #{call.cid_num}"
+ = "#{call.caller_id_name} #{call.caller_id_number}"
%td
- = "#{call.callee_name} #{call.callee_num}"
+ = "#{call.callee_name} #{call.callee_number}"
%td
= call.callstate
%td
- = "#{call.read_codec}/#{call.write_codec}"
+ = "#{call.read_codec}/#{call.read_rate}:#{call.write_codec}/#{call.write_rate}"
%td
%p
diff --git a/app/views/config_polycom/idle_screen.xml.haml b/app/views/config_polycom/idle_screen.xml.haml
index fa52c4f..f6d8cf9 100644
--- a/app/views/config_polycom/idle_screen.xml.haml
+++ b/app/views/config_polycom/idle_screen.xml.haml
@@ -3,5 +3,18 @@
%head
%title= @sip_account.caller_name
%body
- - @sip_account.phone_numbers.each do |number|
- %br= number.number
+ - phone_numbers = @sip_account.phone_numbers.order(:position)
+ - 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 ...
+ - call = @sip_account.call_histories.where(:entry_type => 'missed').order('start_stamp DESC').first
+ %p
+ Missed:
+ %br= "#{call.start_stamp.strftime('%d.%m %H:%M')} #{call.display_name} #{call.display_number}"
diff --git a/app/views/fax_documents/_index_core.html.haml b/app/views/fax_documents/_index_core.html.haml
index 2f9b214..df1e2ac 100644
--- a/app/views/fax_documents/_index_core.html.haml
+++ b/app/views/fax_documents/_index_core.html.haml
@@ -25,9 +25,24 @@
%tr{:class => current_status}
%td
- case fax_document.state
+ - when 'received'
+ %i.icon-warning-sign
+ = l fax_document.sent_at, :format => :short
+ - when 'unsuccessful'
+ %i.icon-ban-circle
+ = t("fax_documents.states.#{fax_document.state}")
- when 'successful'
- = "#{fax_document.inbound ? '&#8680;' : '&#8678;'}".html_safe
+ - if fax_document.inbound
+ %i.icon-arrow-right
+ - else
+ %i.icon-arrow-left
= l fax_document.sent_at, :format => :short
+ - when 'queued_for_sending'
+ %i.icon-time
+ = t("fax_documents.states.#{fax_document.state}")
+ - when 'sending'
+ %i.icon-print
+ = t("fax_documents.states.#{fax_document.state}")
- else
= t("fax_documents.states.#{fax_document.state}")
%td
diff --git a/app/views/group_memberships/_index_core.html.haml b/app/views/group_memberships/_index_core.html.haml
index beeefc9..31a9050 100644
--- a/app/views/group_memberships/_index_core.html.haml
+++ b/app/views/group_memberships/_index_core.html.haml
@@ -2,10 +2,11 @@
%tr
%th= t('group_memberships.index.item_type')
%th= t('group_memberships.index.item_id')
-
+ %th= t('group_memberships.index.item')
- for group_membership in group_memberships
%tr
%td= group_membership.item_type
%td= group_membership.item_id
+ %td= group_membership.item
=render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => group_membership.group, :child => group_membership}
diff --git a/app/views/group_memberships/show.html.haml b/app/views/group_memberships/show.html.haml
index 0875f0b..362b25f 100644
--- a/app/views/group_memberships/show.html.haml
+++ b/app/views/group_memberships/show.html.haml
@@ -7,4 +7,8 @@
%strong= t('group_memberships.show.item_id') + ":"
= @group_membership.item_id
+%p
+ %strong= t('group_memberships.show.item') + ":"
+ = @group_membership.item
+
= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @group, :child => @group_membership }
diff --git a/app/views/groups/_form_core.html.haml b/app/views/groups/_form_core.html.haml
index 1f9a39f..02f296b 100644
--- a/app/views/groups/_form_core.html.haml
+++ b/app/views/groups/_form_core.html.haml
@@ -1,4 +1,4 @@
.inputs
= f.input :name, :label => t('groups.form.name.label'), :hint => conditional_hint('groups.form.name.hint')
- = f.input :active, :label => t('groups.form.active.label'), :hint => conditional_hint('groups.form.active.hint')
= f.input :comment, :label => t('groups.form.comment.label'), :hint => conditional_hint('groups.form.comment.hint')
+ = f.input :active, :label => t('groups.form.active.label'), :hint => conditional_hint('groups.form.active.hint')
diff --git a/app/views/groups/_index_core.html.haml b/app/views/groups/_index_core.html.haml
index 3a444bf..e67eb66 100644
--- a/app/views/groups/_index_core.html.haml
+++ b/app/views/groups/_index_core.html.haml
@@ -2,6 +2,8 @@
%tr
%th
%th= t('groups.index.name')
+ %th= t('groups.index.permissions')
+ %th= t('groups.index.memberships')
%th= t('groups.index.comment')
@@ -13,5 +15,11 @@
- else
%i.icon-ban-circle
%td= group.name
+ %td
+ - if group.group_permissions.count > 0 && group.group_permissions.count < 4
+ = group.group_permissions.pluck(:permission).uniq.join(' ')
+ - else
+ = group.group_permissions.count
+ %td= group.group_memberships.count
%td= group.comment
- =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => group} \ No newline at end of file
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => group}
diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml
index 8df2bb3..9d757a0 100644
--- a/app/views/gs_parameters/index.html.haml
+++ b/app/views/gs_parameters/index.html.haml
@@ -2,12 +2,42 @@
- cache(['gs_parameter_all_tables', I18n.locale, @gs_parameters.count, @gs_parameters.reorder(:updated_at).first, @gs_parameters.reorder(:updated_at).last]) do
- if @gs_parameters && @gs_parameters.count > 0
- - if @sections
- - @sections.each do |section|
- %h3= section
- %table.table.table-striped
- -# Template Dependency: gs_parameters/_index_core
- = render "index_core", :gs_parameters => @gs_parameters.where(:section => section)
- - else
- %table.table.table-striped
- = render "index_core", :gs_parameters => @gs_parameters
+ %table.table.table-striped
+ %thead
+ %tr
+ %th
+ %th
+ %th
+ %th
+
+ %tbody
+ - @entities.each do |entity_name, entity|
+ %tr.table.info
+ %td{:colspan => 5}
+ - if !entity_name.blank?
+ %strong= entity_name
+ - entity.each do |section_name, section|
+ %tr.table.success
+ %td
+ %td{:colspan => 4}
+ %strong= section_name
+ - gs_parameters = @gs_parameters.where(:entity => entity_name, :section => section_name)
+ - cache(['gs_parameter_sub_table', I18n.locale, gs_parameters.count, gs_parameters.reorder(:updated_at).first, gs_parameters.reorder(:updated_at).last]) do
+
+ - for gs_parameter in gs_parameters
+ - cache(['gs_parameters_table_single_row', I18n.locale, gs_parameter]) do
+ %tr
+ %td
+ %td
+ %td
+ %span.hidden-phone
+ = truncate(gs_parameter.name, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH'))
+ %span.visible-phone
+ = truncate(gs_parameter.name, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH'))
+ %td
+ %span.hidden-phone
+ = truncate(gs_parameter.value, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH'))
+ %span.visible-phone
+ = truncate(gs_parameter.value, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH'))
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gs_parameter}
+
diff --git a/app/views/gs_parameters/show.html.haml b/app/views/gs_parameters/show.html.haml
index 706625f..85e9b98 100644
--- a/app/views/gs_parameters/show.html.haml
+++ b/app/views/gs_parameters/show.html.haml
@@ -4,10 +4,11 @@
%table.table.table-striped
%tbody
%tr
+ %tr
%td
- %strong= t('gs_parameters.show.name') + ":"
+ %strong= t('gs_parameters.show.entity') + ":"
%td
- = @gs_parameter.name
+ = @gs_parameter.entity
%tr
%td
%strong= t('gs_parameters.show.section') + ":"
@@ -15,6 +16,11 @@
= @gs_parameter.section
%tr
%td
+ %strong= t('gs_parameters.show.name') + ":"
+ %td
+ = @gs_parameter.name
+ %tr
+ %td
%strong= t('gs_parameters.show.value') + ":"
%td
= @gs_parameter.value
diff --git a/app/views/intruders/_form_core.html.haml b/app/views/intruders/_form_core.html.haml
index 780d8cd..a0c2eb0 100644
--- a/app/views/intruders/_form_core.html.haml
+++ b/app/views/intruders/_form_core.html.haml
@@ -1,5 +1,7 @@
.inputs
= f.input :list_type, :collection => Intruder::LIST_TYPES, :label => t('intruders.form.list_type.label'), :hint => conditional_hint('intruders.form.list_type.hint'), :include_blank => false
= f.input :contact_ip, :label => t('intruders.form.contact_ip.label'), :hint => conditional_hint('intruders.form.contact_ip.hint')
- = f.input :ban_end, :label => t('intruders.form.ban_end.label'), :hint => conditional_hint('intruders.form.ban_end.hint')
+ = f.input :points, :label => t('intruders.form.points.label'), :hint => conditional_hint('intruders.form.points.hint')
+ = f.input :bans, :label => t('intruders.form.bans.label'), :hint => conditional_hint('intruders.form.bans.hint'), as: :boolean
+
= f.input :comment, :label => t('intruders.form.comment.label'), :hint => conditional_hint('intruders.form.comment.hint')
diff --git a/app/views/intruders/_index_core.html.haml b/app/views/intruders/_index_core.html.haml
index 63f2253..1fca601 100644
--- a/app/views/intruders/_index_core.html.haml
+++ b/app/views/intruders/_index_core.html.haml
@@ -2,38 +2,39 @@
%tr
%th
%th= t('intruders.index.contact_ip')
- %th= t('intruders.index.contact_port')
%th= t('intruders.index.points')
- %th= t('intruders.index.bans')
%th= t('intruders.index.ban_last')
- %th= t('intruders.index.ban_end')
%th= t('intruders.index.contact_count')
%th= t('intruders.index.contact_last')
%th= t('intruders.index.contacts_per_second')
%th= t('intruders.index.user_agent')
%th= t('intruders.index.to_user')
+ %th
- for intruder in intruders
- %tr
+ - if intruder.list_type == 'whitelist'
+ - entry_class = 'success'
+ - elsif intruder.bans.to_i > 0
+ - entry_class = 'error'
+ - elsif intruder.points.to_i > 0
+ - entry_class = 'warn'
+ - else
+ - entry_class = ''
+ %tr{:class => "table #{entry_class}"}
%td
- - if intruder.list_type == 'whitelist'
+ - if entry_class == 'success'
%i.icon-ok
- - elsif intruder.bans > 0
+ - elsif entry_class == 'error'
%i.icon-fire
- - elsif intruder.points > 0
+ - elsif entry_class == 'warn'
%i.icon-warning-sign
%td= intruder.contact_ip
- %td= intruder.contact_port
%td= intruder.points
- %td= intruder.bans
%td
- if intruder.ban_last
= l intruder.ban_last, :format => :short
- %td
- - if intruder.ban_end
- = l intruder.ban_end, :format => :short
%td= intruder.contact_count
%td
diff --git a/app/views/intruders/index.html.haml b/app/views/intruders/index.html.haml
index 72b8882..79b4ceb 100644
--- a/app/views/intruders/index.html.haml
+++ b/app/views/intruders/index.html.haml
@@ -1,6 +1,9 @@
- content_for :title, t("intruders.index.page_title")
-- if @intruders && @intruders.count > 0
- = render "index_core", :intruders => @intruders
+- if @intruders && @intruders.count > 0 && @list_types && @list_types.count > 0
+ - @list_types.each do |list_type|
+ %h3= list_type
+ %table.table.table-striped
+ = render "index_core", :intruders => @intruders.where(:list_type => list_type)
-= render :partial => 'shared/create_link', :locals => {:child_class => Intruder} \ No newline at end of file
+= render :partial => 'shared/create_link', :locals => {:child_class => Intruder}
diff --git a/app/views/phone_book_entries/show.html.haml b/app/views/phone_book_entries/show.html.haml
index 7dd9bcb..1afb019 100644
--- a/app/views/phone_book_entries/show.html.haml
+++ b/app/views/phone_book_entries/show.html.haml
@@ -70,26 +70,39 @@
- case phone_number.name.to_s.downcase
- when /fax/
.fax
+ %i.icon-print
+ = phone_number.name
= link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
- %span= phone_number.name
- when /home/
.home
+ %i.icon-home
+ = phone_number.name
= link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
- %span
- when /mobile/
.cellphone
+ %i.icon-signal
+ = phone_number.name
= link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
- %span= phone_number.name
- when /office/
.office
+ %i.icon-briefcase
+ = phone_number.name
= link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
- %span= phone_number.name
- - else
+ - when /phone/
.phone
+ %i.icon-asterisk
+ = phone_number.name
+ = link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
+ - else
+ .phone_number
+ %i.icon-star
+ = phone_number.name
= link_to phone_number, call_phone_book_entry_phone_number_path(@phone_book_entry, phone_number), :method => :put, :title => t('phone_numbers.show.actions.call')
- %span= phone_number.name
- = link_to t('phone_book_entries.show.manage_phone_numbers'), phone_book_entry_phone_numbers_path(@phone_book_entry)
+ %p
+ %a.btn.btn-small.btn-default{ :href => phone_book_entry_phone_numbers_path(@phone_book_entry) }
+ %i.icon-edit
+ = t('phone_book_entries.show.manage_phone_numbers')
.widget.adresses
- @phone_book_entry.addresses.each do |address|
diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml
index 31f3c24..e093899 100644
--- a/app/views/phones/_form_core.html.haml
+++ b/app/views/phones/_form_core.html.haml
@@ -11,5 +11,5 @@
- if defined? GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') && GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') == true
= f.input :nightly_reboot, :label => t('phones.form.nightly_reboot.label'), :hint => conditional_hint('phones.form.nightly_reboot.hint')
- - if GsParameter.get('PROVISIONING_KEY_LENGTH') == 0
+ - if @phone && @phone.provisioning_key_active
= f.input :provisioning_key_active, :label => t('phones.form.provisioning_key_active.label'), :hint => conditional_hint('phones.form.provisioning_key_active.hint')
diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml
index e9b8b21..1996d48 100644
--- a/app/views/phones/show.html.haml
+++ b/app/views/phones/show.html.haml
@@ -34,12 +34,11 @@
%td
= @phone.nightly_reboot == true ? t('simple_form.yes') : t('simple_form.no')
- - if GsParameter.get('PROVISIONING_KEY_LENGTH') == 0
- %tr
- %td
- %strong= t('phones.show.provisioning_key_active') + ":"
- %td
- = @phone.provisioning_key_active == true ? t('simple_form.yes') : t('simple_form.no')
+ %tr
+ %td
+ %strong= t('phones.show.provisioning_key_active') + ":"
+ %td
+ = @phone.provisioning_key_active == true ? t('simple_form.yes') : t('simple_form.no')
%tr{:class => (@phone.ip_address.blank? ? 'warning' : '')}
%td
diff --git a/app/views/softkeys/_form_core.html.haml b/app/views/softkeys/_form_core.html.haml
index 2863d5c..f447aa6 100644
--- a/app/views/softkeys/_form_core.html.haml
+++ b/app/views/softkeys/_form_core.html.haml
@@ -6,7 +6,8 @@
.inputs
= f.input :softkey_function_id, :as => :select, :collection => @softkey_functions.map {|x| [I18n.t("softkeys.functions.#{x}"), x.id] }, :label => t('softkeys.form.function.label'), :hint => conditional_hint('softkeys.form.function.hint'), :include_blank => false
- - if @available_call_forwards && @available_call_forwards.count > 0
- = f.association :softkeyable, :collection => @available_call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false
+ - call_forwards = @softkey.possible_call_forwards
+ - if call_forwards && call_forwards.count > 0
+ = f.association :softkeyable, :collection => call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false
= f.input :number, :label => t('softkeys.form.number.label'), :hint => conditional_hint('softkeys.form.number.hint')
= f.input :label, :label => t('softkeys.form.label.label'), :hint => conditional_hint('softkeys.form.label.hint')
diff --git a/app/views/tenants/_table_of_automatic_call_distributors.html.haml b/app/views/tenants/_table_of_automatic_call_distributors.html.haml
index 22796af..c3ab309 100644
--- a/app/views/tenants/_table_of_automatic_call_distributors.html.haml
+++ b/app/views/tenants/_table_of_automatic_call_distributors.html.haml
@@ -1,4 +1,4 @@
-- cache(['tenant_show_table_of_automatic_call_distributors', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.reorder(:updated_at).last]) do
+- cache(['tenant_show_table_of_automatic_call_distributors', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.reorder(:updated_at).last, PhoneNumber.where(:phone_numberable_type => 'AutomaticCallDistributor').order(:updated_at).last]) do
-# AutomaticCallDistributors
-#
- if (can?( :index, AutomaticCallDistributor ) && tenant.automatic_call_distributors.count > 0 ) || can?( :create, AutomaticCallDistributor )
diff --git a/app/views/tenants/_table_of_hunt_groups.html.haml b/app/views/tenants/_table_of_hunt_groups.html.haml
index aca570d..d93ebe6 100644
--- a/app/views/tenants/_table_of_hunt_groups.html.haml
+++ b/app/views/tenants/_table_of_hunt_groups.html.haml
@@ -1,4 +1,4 @@
-- cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.reorder(:updated_at).last]) do
+- cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.reorder(:updated_at).last, PhoneNumber.where(:phone_numberable_type => 'HuntGroup').order(:updated_at).last]) do
-# HuntGroups
-#
- if (can?( :index, HuntGroup ) && tenant.hunt_groups.count > 0 ) || can?( :create, HuntGroup )
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index 8148005..ea90ab4 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -75,10 +75,11 @@
- cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do
= render :partial => 'phones', :locals => {:user => @user}
- - if GsParameter.get('SIM_CARDS') == true
+ - if GsParameter.get('SIM_CARDS') == true && (@user.sim_cards.count > 0 || can?( :create, SimCard ))
- cache(['user_show_sim_cards_overview', I18n.locale, @user, @user.sim_cards]) do
%h2=t('sim_cards.index.page_title')
- = render :partial => 'sim_cards/index_core', :locals => {:parent => SimCardProvider.first, :sim_cards => @user.sim_cards}
+ - if @user.sim_cards.count > 0
+ = render :partial => 'sim_cards/index_core', :locals => {:parent => SimCardProvider.first, :sim_cards => @user.sim_cards}
= render :partial => 'shared/create_link', :locals => {:parent => SimCardProvider.first, :child_class => SimCard}
- cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do