summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-16 11:10:02 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-16 11:10:02 +0100
commit5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (patch)
tree49ed889b1d10cda98c475f3453abff1b97afb4e7 /app/controllers
parentc9066760fd1f5f2f892ce2be5cf2a83bb5210246 (diff)
parent55784bcffc0678ce6102c0b81447434a8030ebd2 (diff)
Merge branch 'develop'5.1-beta5
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/config_snom_controller.rb51
-rw-r--r--app/controllers/intruders_controller.rb18
-rw-r--r--app/controllers/parking_stalls_controller.rb69
-rw-r--r--app/controllers/sim_card_providers_controller.rb47
-rw-r--r--app/controllers/sim_cards_controller.rb57
5 files changed, 218 insertions, 24 deletions
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index 58cced2..76fa633 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -282,28 +282,31 @@ class ConfigSnomController < ApplicationController
@softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"})
when 'conference'
@softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf <sip:#{softkey.number}@#{sip_account.host}>|f-ta-"})
- when 'call_parking'
- @softkeys.push({
- :context => sip_account_index,
- :function => softkey.softkey_function.name,
- :label => softkey.label,
- :softkey => softkey,
- :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
- :subscription => {
- :to => "park+#{@softkeys.softkeyable_id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :dial,
- :target => "f-tpark-#{@softkeys.softkeyable_id}",
- :when => 'on press',
- :states => 'connected,holding',
- },{
- :type => :dial,
- :target => "f-park-#{@softkeys.softkeyable_id}",
- :when => 'on press',
- }],
- })
+ when 'parking_stall'
+ parking_stall = softkey.softkeyable
+ if parking_stall.class == ParkingStall
+ @softkeys.push({
+ :context => sip_account_index,
+ :function => softkey.softkey_function.name,
+ :label => softkey.label,
+ :softkey => softkey,
+ :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
+ :subscription => {
+ :to => "sip:park+#{parking_stall.name}@#{sip_account.host}",
+ :for => "sip:park+#{parking_stall.name}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :dial,
+ :target => "f-cpa-#{parking_stall.name}",
+ :when => 'on press',
+ :states => 'connected,holding',
+ },{
+ :type => :dial,
+ :target => "f-cpa-#{parking_stall.name}",
+ :when => 'on press',
+ }],
+ })
+ end
when 'call_forwarding'
if softkey.softkeyable.class == CallForward then
@softkeys.push({
@@ -313,8 +316,8 @@ class ConfigSnomController < ApplicationController
:softkey => softkey,
:general_type => t("softkeys.functions.#{softkey.softkey_function.name}"),
:subscription => {
- :to => "f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
+ :to => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
+ :for => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}"
},
:actions => [{
:type => :url,
diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb
index eb34f2b..147e06d 100644
--- a/app/controllers/intruders_controller.rb
+++ b/app/controllers/intruders_controller.rb
@@ -1,18 +1,25 @@
class IntrudersController < ApplicationController
def index
@intruders = Intruder.all
+ spread_breadcrumbs
end
def show
@intruder = Intruder.find(params[:id])
+ if ! params[:whois].blank?
+ @whois = @intruder.whois(params[:whois])
+ end
+ spread_breadcrumbs
end
def new
@intruder = Intruder.new
+ spread_breadcrumbs
end
def create
@intruder = Intruder.new(params[:intruder])
+ spread_breadcrumbs
if @intruder.save
redirect_to @intruder, :notice => t('intruders.controller.successfuly_created')
else
@@ -22,10 +29,12 @@ class IntrudersController < ApplicationController
def edit
@intruder = Intruder.find(params[:id])
+ spread_breadcrumbs
end
def update
@intruder = Intruder.find(params[:id])
+ spread_breadcrumbs
if @intruder.update_attributes(params[:intruder])
redirect_to @intruder, :notice => t('intruders.controller.successfuly_updated')
else
@@ -35,7 +44,16 @@ class IntrudersController < ApplicationController
def destroy
@intruder = Intruder.find(params[:id])
+ spread_breadcrumbs
@intruder.destroy
redirect_to intruders_url, :notice => t('intruders.controller.successfuly_destroyed')
end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("intruders.index.page_title"), intruders_path
+ if @intruder && !@intruder.new_record?
+ add_breadcrumb @intruder, @intruder
+ end
+ end
end
diff --git a/app/controllers/parking_stalls_controller.rb b/app/controllers/parking_stalls_controller.rb
new file mode 100644
index 0000000..d1bc0c7
--- /dev/null
+++ b/app/controllers/parking_stalls_controller.rb
@@ -0,0 +1,69 @@
+class ParkingStallsController < ApplicationController
+
+ load_resource :tenant
+ load_resource :user
+ load_and_authorize_resource :parking_stall, :through => [:user, :tenant ]
+
+ before_filter :set_and_authorize_parent
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ @parking_stall.lot = 'default'
+ @parking_stall.name = ParkingStall.order(:name).last.try(:name).to_i + 1
+ end
+
+ def create
+ @parking_stall = @parent.parking_stalls.build(params[:parking_stall])
+ if @parking_stall.save
+ redirect_to [@parent, @parking_stall], :notice => t('parking_stalls.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @parking_stall.update_attributes(params[:parking_stall])
+ redirect_to [@parent, @parking_stall], :notice => t('parking_stalls.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @parking_stall.destroy
+ m = method( :"#{@parent.class.name.underscore}_parking_stalls_url" )
+ redirect_to m.(@parent), :notice => t('parking_stalls.controller.successfuly_destroyed')
+ end
+
+ private
+ def set_and_authorize_parent
+ @parent = @user || @tenant
+ authorize! :read, @parent
+ end
+
+ def spread_breadcrumbs
+ if @user
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user)
+ add_breadcrumb t("parking_stalls.index.page_title"), user_parking_stalls_path(@user)
+ if @parking_stall && !@parking_stall.new_record?
+ add_breadcrumb @parking_stall, user_parking_stall_path(@user, @parking_stall)
+ end
+ end
+ if @tenant
+ add_breadcrumb t("parking_stalls.index.page_title"), tenant_parking_stalls_path(@tenant)
+ if @parking_stall && !@parking_stall.new_record?
+ add_breadcrumb @parking_stall, tenant_parking_stall_path(@tenant, @parking_stall)
+ end
+ end
+ end
+end
diff --git a/app/controllers/sim_card_providers_controller.rb b/app/controllers/sim_card_providers_controller.rb
new file mode 100644
index 0000000..e9a019c
--- /dev/null
+++ b/app/controllers/sim_card_providers_controller.rb
@@ -0,0 +1,47 @@
+class SimCardProvidersController < ApplicationController
+ load_and_authorize_resource :sim_card_provider
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ if @sim_card_provider.save
+ redirect_to @sim_card_provider, :notice => t('sim_card_providers.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @sim_card_provider.update_attributes(params[:sim_card_provider])
+ redirect_to @sim_card_provider, :notice => t('sim_card_providers.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @sim_card_provider.destroy
+ redirect_to sim_card_providers_url, :notice => t('sim_card_providers.controller.successfuly_destroyed')
+ end
+
+ private
+
+ def spread_breadcrumbs
+ add_breadcrumb t("sim_card_providers.index.page_title"), sim_card_providers_path
+ if @sim_card_provider && !@sim_card_provider.new_record?
+ add_breadcrumb @sim_card_provider, sim_card_provider_path(@sim_card_provider)
+ end
+ end
+
+end
diff --git a/app/controllers/sim_cards_controller.rb b/app/controllers/sim_cards_controller.rb
new file mode 100644
index 0000000..ed46843
--- /dev/null
+++ b/app/controllers/sim_cards_controller.rb
@@ -0,0 +1,57 @@
+class SimCardsController < ApplicationController
+ load_and_authorize_resource :sim_card_provider
+ load_and_authorize_resource :sim_card, :through => [:sim_card_provider]
+
+ before_filter :set_parent
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ @sim_card = @sim_card_provider.sim_cards.build
+
+ @with_phones_connected_sip_account_ids = SipAccount.where(:id => PhoneSipAccount.pluck(:sip_account_id)).pluck(:id)
+ @with_sim_cards_connected_sip_account_ids = SimCard.pluck(:sip_account_id)
+ @available_sip_account_ids = SipAccount.pluck(:id) - (@with_phones_connected_sip_account_ids + @with_sim_cards_connected_sip_account_ids)
+
+ @available_sip_accounts = SipAccount.where(:id => @available_sip_account_ids)
+
+ if @available_sip_accounts.count == 0
+ redirect_to sim_card_provider_sim_cards_path(@sim_card_provider), :alert => t('sim_cards.controller.no_existing_sip_accounts_warning')
+ end
+
+ end
+
+ def create
+ @sim_card = @sim_card_provider.sim_cards.build(params[:sim_card])
+ if @sim_card.save
+ redirect_to [@sim_card_provider, @sim_card], :notice => t('sim_cards.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def destroy
+ @sim_card.destroy
+ redirect_to sim_card_provider_sim_cards_url(@sim_card_provider), :notice => t('sim_cards.controller.successfuly_destroyed')
+ end
+
+ private
+ def set_parent
+ @parent = @sim_card_provider
+ end
+
+ def spread_breadcrumbs
+ add_breadcrumb t("sim_card_providers.index.page_title"), sim_card_providers_path
+ add_breadcrumb @sim_card_provider, sim_card_provider_path(@sim_card_provider)
+ add_breadcrumb t("sim_cards.index.page_title"), sim_card_provider_sim_cards_path(@sim_card_provider)
+ if @sim_card && !@sim_card.new_record?
+ add_breadcrumb @sim_card, sim_card_provider_sim_card_path(@sim_card_provider, @sim_card)
+ end
+ end
+
+end