From 1ca26f823692d1cccb220a07ac8e7841c14dced3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Feb 2013 13:05:59 +0000 Subject: parking_stall route added --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 05d09dc..2586e85 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Gemeinschaft42c::Application.routes.draw do + resources :parking_stalls + resources :intruders resources :backup_jobs, :except => [:edit, :update] -- cgit v1.2.3 From 902447a1baf7e9d8385c269a601361c8c3f2f14b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Feb 2013 13:07:05 +0000 Subject: parking_stall added --- app/controllers/parking_stalls_controller.rb | 41 +++++++++++++++ app/helpers/parking_stalls_helper.rb | 2 + app/models/parking_stall.rb | 3 ++ app/views/parking_stalls/_form.html.haml | 7 +++ app/views/parking_stalls/_form_core.html.haml | 6 +++ app/views/parking_stalls/_index_core.html.haml | 17 ++++++ app/views/parking_stalls/edit.html.haml | 3 ++ app/views/parking_stalls/index.html.haml | 6 +++ app/views/parking_stalls/new.html.haml | 3 ++ app/views/parking_stalls/show.html.haml | 19 +++++++ config/locales/views/parking_stalls/de.yml | 60 ++++++++++++++++++++++ config/locales/views/parking_stalls/en.yml | 60 ++++++++++++++++++++++ db/migrate/20130212120729_create_parking_stalls.rb | 16 ++++++ test/functional/parking_stalls_controller_test.rb | 49 ++++++++++++++++++ test/unit/parking_stall_test.rb | 7 +++ 15 files changed, 299 insertions(+) create mode 100644 app/controllers/parking_stalls_controller.rb create mode 100644 app/helpers/parking_stalls_helper.rb create mode 100644 app/models/parking_stall.rb create mode 100644 app/views/parking_stalls/_form.html.haml create mode 100644 app/views/parking_stalls/_form_core.html.haml create mode 100644 app/views/parking_stalls/_index_core.html.haml create mode 100644 app/views/parking_stalls/edit.html.haml create mode 100644 app/views/parking_stalls/index.html.haml create mode 100644 app/views/parking_stalls/new.html.haml create mode 100644 app/views/parking_stalls/show.html.haml create mode 100644 config/locales/views/parking_stalls/de.yml create mode 100644 config/locales/views/parking_stalls/en.yml create mode 100644 db/migrate/20130212120729_create_parking_stalls.rb create mode 100644 test/functional/parking_stalls_controller_test.rb create mode 100644 test/unit/parking_stall_test.rb diff --git a/app/controllers/parking_stalls_controller.rb b/app/controllers/parking_stalls_controller.rb new file mode 100644 index 0000000..42931ed --- /dev/null +++ b/app/controllers/parking_stalls_controller.rb @@ -0,0 +1,41 @@ +class ParkingStallsController < ApplicationController + def index + @parking_stalls = ParkingStall.all + end + + def show + @parking_stall = ParkingStall.find(params[:id]) + end + + def new + @parking_stall = ParkingStall.new + end + + def create + @parking_stall = ParkingStall.new(params[:parking_stall]) + if @parking_stall.save + redirect_to @parking_stall, :notice => t('parking_stalls.controller.successfuly_created') + else + render :new + end + end + + def edit + @parking_stall = ParkingStall.find(params[:id]) + end + + def update + @parking_stall = ParkingStall.find(params[:id]) + if @parking_stall.update_attributes(params[:parking_stall]) + redirect_to @parking_stall, :notice => t('parking_stalls.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @parking_stall = ParkingStall.find(params[:id]) + @parking_stall.destroy + redirect_to parking_stalls_url, :notice => t('parking_stalls.controller.successfuly_destroyed') + end +end diff --git a/app/helpers/parking_stalls_helper.rb b/app/helpers/parking_stalls_helper.rb new file mode 100644 index 0000000..135bfee --- /dev/null +++ b/app/helpers/parking_stalls_helper.rb @@ -0,0 +1,2 @@ +module ParkingStallsHelper +end diff --git a/app/models/parking_stall.rb b/app/models/parking_stall.rb new file mode 100644 index 0000000..52223a8 --- /dev/null +++ b/app/models/parking_stall.rb @@ -0,0 +1,3 @@ +class ParkingStall < ActiveRecord::Base + attr_accessible :name, :lot, :parking_stallable_id, :parking_stallable_type, :comment +end diff --git a/app/views/parking_stalls/_form.html.haml b/app/views/parking_stalls/_form.html.haml new file mode 100644 index 0000000..5b1523b --- /dev/null +++ b/app/views/parking_stalls/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@parking_stall) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('parking_stalls.form.submit') \ No newline at end of file diff --git a/app/views/parking_stalls/_form_core.html.haml b/app/views/parking_stalls/_form_core.html.haml new file mode 100644 index 0000000..db68f99 --- /dev/null +++ b/app/views/parking_stalls/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :name, :label => t('parking_stalls.form.name.label'), :hint => conditional_hint('parking_stalls.form.name.hint') + = f.input :lot, :label => t('parking_stalls.form.lot.label'), :hint => conditional_hint('parking_stalls.form.lot.hint') + = f.input :parking_stallable_id, :label => t('parking_stalls.form.parking_stallable_id.label'), :hint => conditional_hint('parking_stalls.form.parking_stallable_id.hint') + = f.input :parking_stallable_type, :label => t('parking_stalls.form.parking_stallable_type.label'), :hint => conditional_hint('parking_stalls.form.parking_stallable_type.hint') + = f.input :comment, :label => t('parking_stalls.form.comment.label'), :hint => conditional_hint('parking_stalls.form.comment.hint') diff --git a/app/views/parking_stalls/_index_core.html.haml b/app/views/parking_stalls/_index_core.html.haml new file mode 100644 index 0000000..fb317a0 --- /dev/null +++ b/app/views/parking_stalls/_index_core.html.haml @@ -0,0 +1,17 @@ +%table.table.table-striped + %tr + %th= t('parking_stalls.index.name') + %th= t('parking_stalls.index.lot') + %th= t('parking_stalls.index.parking_stallable_id') + %th= t('parking_stalls.index.parking_stallable_type') + %th= t('parking_stalls.index.comment') + + + - for parking_stall in parking_stalls + %tr + %td= parking_stall.name + %td= parking_stall.lot + %td= parking_stall.parking_stallable_id + %td= parking_stall.parking_stallable_type + %td= parking_stall.comment + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => parking_stall} \ No newline at end of file diff --git a/app/views/parking_stalls/edit.html.haml b/app/views/parking_stalls/edit.html.haml new file mode 100644 index 0000000..ec5d97f --- /dev/null +++ b/app/views/parking_stalls/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("parking_stalls.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/parking_stalls/index.html.haml b/app/views/parking_stalls/index.html.haml new file mode 100644 index 0000000..9472ff0 --- /dev/null +++ b/app/views/parking_stalls/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("parking_stalls.index.page_title") + +- if @parking_stalls && @parking_stalls.count > 0 + = render "index_core", :parking_stalls => @parking_stalls + += render :partial => 'shared/create_link', :locals => {:child_class => ParkingStall} \ No newline at end of file diff --git a/app/views/parking_stalls/new.html.haml b/app/views/parking_stalls/new.html.haml new file mode 100644 index 0000000..c068e52 --- /dev/null +++ b/app/views/parking_stalls/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("parking_stalls.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/parking_stalls/show.html.haml b/app/views/parking_stalls/show.html.haml new file mode 100644 index 0000000..a95c111 --- /dev/null +++ b/app/views/parking_stalls/show.html.haml @@ -0,0 +1,19 @@ +- content_for :title, t("parking_stalls.show.page_title") + +%p + %strong= t('parking_stalls.show.name') + ":" + = @parking_stall.name +%p + %strong= t('parking_stalls.show.lot') + ":" + = @parking_stall.lot +%p + %strong= t('parking_stalls.show.parking_stallable_id') + ":" + = @parking_stall.parking_stallable_id +%p + %strong= t('parking_stalls.show.parking_stallable_type') + ":" + = @parking_stall.parking_stallable_type +%p + %strong= t('parking_stalls.show.comment') + ":" + = @parking_stall.comment + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @parking_stall } \ No newline at end of file diff --git a/config/locales/views/parking_stalls/de.yml b/config/locales/views/parking_stalls/de.yml new file mode 100644 index 0000000..44e31c8 --- /dev/null +++ b/config/locales/views/parking_stalls/de.yml @@ -0,0 +1,60 @@ +de: + parking_stalls: + name: 'Parkingstall' + controller: + successfuly_created: 'Parkingstall wurde angelegt.' + successfuly_updated: 'Parkingstall wurde aktualisiert.' + successfuly_destroyed: 'Parkingstall wurde gelöscht.' + index: + page_title: 'Übersicht von Parkingstall' + name: 'Name' + lot: 'Lot' + parking_stallable_id: 'Parking stallable' + parking_stallable_type: 'Parking stallable type' + comment: 'Comment' + actions: + confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Parkingstall' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Parkingstall neu anlegen für %{resource}' + show: + page_title: 'Parkingstall bearbeiten' + name: 'Name' + lot: 'Lot' + parking_stallable_id: 'Parking stallable' + parking_stallable_type: 'Parking stallable type' + comment: 'Comment' + actions: + confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Parkingstall neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Parkingstall bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + name: + label: 'Name' + hint: '' + lot: + label: 'Lot' + hint: '' + parking_stallable_id: + label: 'Parking stallable' + hint: '' + parking_stallable_type: + label: 'Parking stallable type' + hint: '' + comment: + label: 'Comment' + hint: '' + submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/parking_stalls/en.yml b/config/locales/views/parking_stalls/en.yml new file mode 100644 index 0000000..6d30b87 --- /dev/null +++ b/config/locales/views/parking_stalls/en.yml @@ -0,0 +1,60 @@ +en: + parking_stalls: + name: 'Parkingstall' + controller: + successfuly_created: 'Successfully created Parkingstall.' + successfuly_updated: 'Successfully updated Parkingstall.' + successfuly_destroyed: 'Successfully destroyed Parkingstall.' + index: + page_title: 'Listing Parkingstall' + name: 'Name' + lot: 'Lot' + parking_stallable_id: 'Parking stallable' + parking_stallable_type: 'Parking stallable type' + comment: 'Comment' + actions: + confirm_destroy: 'Are you sure you want to delete this Parkingstall?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Parkingstall for %{resource}' + show: + page_title: 'Show Parkingstall' + name: 'Name' + lot: 'Lot' + parking_stallable_id: 'Parking stallable' + parking_stallable_type: 'Parking stallable type' + comment: 'Comment' + actions: + confirm_destroy: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Parkingstall' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Parkingstall' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + name: + label: 'Name' + hint: '' + lot: + label: 'Lot' + hint: '' + parking_stallable_id: + label: 'Parking stallable' + hint: '' + parking_stallable_type: + label: 'Parking stallable type' + hint: '' + comment: + label: 'Comment' + hint: '' + submit: 'Submit' \ No newline at end of file diff --git a/db/migrate/20130212120729_create_parking_stalls.rb b/db/migrate/20130212120729_create_parking_stalls.rb new file mode 100644 index 0000000..7620942 --- /dev/null +++ b/db/migrate/20130212120729_create_parking_stalls.rb @@ -0,0 +1,16 @@ +class CreateParkingStalls < ActiveRecord::Migration + def self.up + create_table :parking_stalls do |t| + t.string :name + t.string :lot + t.integer :parking_stallable_id + t.string :parking_stallable_type + t.string :comment + t.timestamps + end + end + + def self.down + drop_table :parking_stalls + end +end diff --git a/test/functional/parking_stalls_controller_test.rb b/test/functional/parking_stalls_controller_test.rb new file mode 100644 index 0000000..8596a48 --- /dev/null +++ b/test/functional/parking_stalls_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ParkingStallsControllerTest < ActionController::TestCase + setup do + @parking_stall = parking_stalls(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:parking_stalls) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create parking_stall" do + assert_difference('ParkingStall.count') do + post :create, parking_stall: @parking_stall.attributes + end + + assert_redirected_to parking_stall_path(assigns(:parking_stall)) + end + + test "should show parking_stall" do + get :show, id: @parking_stall.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @parking_stall.to_param + assert_response :success + end + + test "should update parking_stall" do + put :update, id: @parking_stall.to_param, parking_stall: @parking_stall.attributes + assert_redirected_to parking_stall_path(assigns(:parking_stall)) + end + + test "should destroy parking_stall" do + assert_difference('ParkingStall.count', -1) do + delete :destroy, id: @parking_stall.to_param + end + + assert_redirected_to parking_stalls_path + end +end diff --git a/test/unit/parking_stall_test.rb b/test/unit/parking_stall_test.rb new file mode 100644 index 0000000..db3bcf3 --- /dev/null +++ b/test/unit/parking_stall_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ParkingStallTest < ActiveSupport::TestCase + def test_should_be_valid + assert ParkingStall.new.valid? + end +end -- cgit v1.2.3 From 71ed94d7048b97dd804900fb6fba987b26d5a32a Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 14:10:08 +0100 Subject: call parking dialplan function added --- misc/freeswitch/scripts/dialplan/functions.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 4430be1..acfa336 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -111,8 +111,8 @@ function Functions.dialplan_function(self, caller, dialed_number) result = "+" .. tostring(parameters[3]); elseif fid == "hangup" then result = self:hangup(caller, parameters[3], parameters[4]); - elseif fid == "park" then - result = self:park(caller, parameters[3]); + elseif fid == "cpa" then + result = self:call_parking_inout(caller, parameters[3], parameters[4]); end return result; @@ -898,6 +898,7 @@ function Functions.acd_membership_toggle(self, caller, agent_id, phone_number) return { continue = false, code = 200, phrase = 'OK', no_cdr = true } end + function Functions.hangup(self, caller, code, phrase) require 'common.str' @@ -914,8 +915,20 @@ function Functions.hangup(self, caller, code, phrase) return { continue = false, code = code, phrase = phrase:gsub('_', ' '), no_cdr = true } end -function Functions.park(self, caller, lot) - self.log:info("FUNCTION_PARK lot: ", lot); - caller:execute("valet_park", 'valet_lot ' .. lot); + +function Functions.call_parking_inout(self, caller, stall_name, lot_name) + require 'dialplan.call_parking'; + local parking_stall = dialplan.call_parking.CallParking:new{ log = self.log, database = self.database, caller = caller }:find_by_name(stall_name); + + if not parking_stall then + return { continue = false, code = 404, phrase = 'Parking stall not found', no_cdr = true } + end + + if lot_name and parking_stall.lot ~= lot_name then + return { continue = false, code = 404, phrase = 'Parking lot not found', no_cdr = true } + end + + parking_stall:park_retrieve(); + return { continue = false, code = 200, phrase = 'OK', no_cdr = true } end -- cgit v1.2.3 From fbdb5dca9b3979010b87b16fcb3bf9410c453e91 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 14:10:26 +0100 Subject: call parking class added --- misc/freeswitch/scripts/dialplan/call_parking.lua | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 misc/freeswitch/scripts/dialplan/call_parking.lua diff --git a/misc/freeswitch/scripts/dialplan/call_parking.lua b/misc/freeswitch/scripts/dialplan/call_parking.lua new file mode 100644 index 0000000..cc2cf4b --- /dev/null +++ b/misc/freeswitch/scripts/dialplan/call_parking.lua @@ -0,0 +1,83 @@ +-- Gemeinschaft 5 module: call parking class +-- (c) AMOOMA GmbH 2013 +-- + +module(...,package.seeall) + +PARKING_STALL_FORMAT = '[0-9A-Z_%+%-]+'; +UUID_FORMAT = '[0-9a-f%-]+'; + +CallParking = {} + +-- create acd object +function CallParking.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.class = 'parkingstall'; + self.log = arg.log; + self.database = arg.database; + self.lot = arg.lot or 'default'; + self.caller = arg.caller; + return object; +end + + +function CallParking.find_by_name(self, name) + local sql_query = 'SELECT * FROM `parking_stalls` WHERE `name`= '.. self.database:escape(name, '"') .. ' LIMIT 1'; + local parking_stall = nil; + + self.database:query(sql_query, function(entry) + parking_stall = CallParking:new(self); + parking_stall.record = entry; + parking_stall.id = tonumber(entry.id); + parking_stall.name = entry.name; + end) + + return parking_stall; +end + + +function CallParking.list_occupied(self, lot) + lot = lot or self.lot; + + require 'common.fapi' + local valet_info = common.fapi.FApi:new{ log = self.log }:execute('valet_info', lot); + + local parking_stalls = {}; + tostring(valet_info):gsub('(' .. PARKING_STALL_FORMAT .. ')', function(channel_uuid, parking_stall) + parking_stalls[parking_stall] = channel_uuid; + end); + + return parking_stalls; +end + + +function CallParking.occupied(self) + local occupied_stalls = self:list_occupied(); + if occupied_stalls then + return occupied_stalls[self.name]; + end +end + + +function CallParking.park_retrieve(self) + self.caller:execute("valet_park", self.lot .. ' ' .. self.name); +end + + +function CallParking.park(self) + if self:occupied() then + return false; + end + self.caller:execute("valet_park", self.lot .. ' ' .. self.name); +end + + +function CallParking.retrieve(self) + if not self:occupied() then + return false; + end + self.caller:execute("valet_park", self.lot .. ' ' .. self.name); +end -- cgit v1.2.3 From 36d1a38594361dcd021c23ae9c5040a37d0918df Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 15:53:49 +0100 Subject: make parking stall child of user/tenant --- app/controllers/parking_stalls_controller.rb | 48 ++++++++++++++++++++------ app/models/parking_stall.rb | 14 ++++++++ app/models/tenant.rb | 2 ++ app/models/user.rb | 2 ++ app/views/parking_stalls/_form.html.haml | 2 +- app/views/parking_stalls/_form_core.html.haml | 2 -- app/views/parking_stalls/_index_core.html.haml | 6 +--- app/views/parking_stalls/index.html.haml | 2 +- app/views/parking_stalls/show.html.haml | 8 +---- config/routes.rb | 4 +-- 10 files changed, 62 insertions(+), 28 deletions(-) diff --git a/app/controllers/parking_stalls_controller.rb b/app/controllers/parking_stalls_controller.rb index 42931ed..d1bc0c7 100644 --- a/app/controllers/parking_stalls_controller.rb +++ b/app/controllers/parking_stalls_controller.rb @@ -1,41 +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 - @parking_stalls = ParkingStall.all end def show - @parking_stall = ParkingStall.find(params[:id]) end def new - @parking_stall = ParkingStall.new + @parking_stall.lot = 'default' + @parking_stall.name = ParkingStall.order(:name).last.try(:name).to_i + 1 end def create - @parking_stall = ParkingStall.new(params[:parking_stall]) + @parking_stall = @parent.parking_stalls.build(params[:parking_stall]) if @parking_stall.save - redirect_to @parking_stall, :notice => t('parking_stalls.controller.successfuly_created') + redirect_to [@parent, @parking_stall], :notice => t('parking_stalls.controller.successfuly_created') else render :new end end def edit - @parking_stall = ParkingStall.find(params[:id]) end def update - @parking_stall = ParkingStall.find(params[:id]) if @parking_stall.update_attributes(params[:parking_stall]) - redirect_to @parking_stall, :notice => t('parking_stalls.controller.successfuly_updated') + redirect_to [@parent, @parking_stall], :notice => t('parking_stalls.controller.successfuly_updated') else render :edit end end def destroy - @parking_stall = ParkingStall.find(params[:id]) @parking_stall.destroy - redirect_to parking_stalls_url, :notice => t('parking_stalls.controller.successfuly_destroyed') + 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/models/parking_stall.rb b/app/models/parking_stall.rb index 52223a8..6af1fcd 100644 --- a/app/models/parking_stall.rb +++ b/app/models/parking_stall.rb @@ -1,3 +1,17 @@ class ParkingStall < ActiveRecord::Base attr_accessible :name, :lot, :parking_stallable_id, :parking_stallable_type, :comment + + belongs_to :parking_stallable, :polymorphic => true, :touch => true + + validates :name, + :presence => true, + :uniqueness => true + + validates :lot, + :presence => true + + def to_s + name.to_s + end + end diff --git a/app/models/tenant.rb b/app/models/tenant.rb index 419ac3a..0622f52 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -39,6 +39,8 @@ class Tenant < ActiveRecord::Base has_many :automatic_call_distributors, :as => :automatic_call_distributorable, :dependent => :destroy has_many :acd_agents, :through => :automatic_call_distributors + has_many :parking_stalls, :as => :parking_stallable, :dependent => :destroy + # Phone numbers of the tenant. # has_many :phone_number_ranges_phone_numbers, :through => :phone_number_ranges, :source => :phone_numbers, :readonly => true diff --git a/app/models/user.rb b/app/models/user.rb index afb3f04..fdcd617 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -87,6 +87,8 @@ class User < ActiveRecord::Base validate :current_tenant_is_included_in_tenants, :if => Proc.new{ |user| user.current_tenant_id } belongs_to :gs_node + + has_many :parking_stalls, :as => :parking_stallable, :dependent => :destroy # Avatar like photo mount_uploader :image, ImageUploader diff --git a/app/views/parking_stalls/_form.html.haml b/app/views/parking_stalls/_form.html.haml index 5b1523b..60b60b7 100644 --- a/app/views/parking_stalls/_form.html.haml +++ b/app/views/parking_stalls/_form.html.haml @@ -1,4 +1,4 @@ -= simple_form_for(@parking_stall) do |f| += simple_form_for([@parent, @parking_stall]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/parking_stalls/_form_core.html.haml b/app/views/parking_stalls/_form_core.html.haml index db68f99..add5c53 100644 --- a/app/views/parking_stalls/_form_core.html.haml +++ b/app/views/parking_stalls/_form_core.html.haml @@ -1,6 +1,4 @@ .inputs = f.input :name, :label => t('parking_stalls.form.name.label'), :hint => conditional_hint('parking_stalls.form.name.hint') = f.input :lot, :label => t('parking_stalls.form.lot.label'), :hint => conditional_hint('parking_stalls.form.lot.hint') - = f.input :parking_stallable_id, :label => t('parking_stalls.form.parking_stallable_id.label'), :hint => conditional_hint('parking_stalls.form.parking_stallable_id.hint') - = f.input :parking_stallable_type, :label => t('parking_stalls.form.parking_stallable_type.label'), :hint => conditional_hint('parking_stalls.form.parking_stallable_type.hint') = f.input :comment, :label => t('parking_stalls.form.comment.label'), :hint => conditional_hint('parking_stalls.form.comment.hint') diff --git a/app/views/parking_stalls/_index_core.html.haml b/app/views/parking_stalls/_index_core.html.haml index fb317a0..9f25217 100644 --- a/app/views/parking_stalls/_index_core.html.haml +++ b/app/views/parking_stalls/_index_core.html.haml @@ -2,8 +2,6 @@ %tr %th= t('parking_stalls.index.name') %th= t('parking_stalls.index.lot') - %th= t('parking_stalls.index.parking_stallable_id') - %th= t('parking_stalls.index.parking_stallable_type') %th= t('parking_stalls.index.comment') @@ -11,7 +9,5 @@ %tr %td= parking_stall.name %td= parking_stall.lot - %td= parking_stall.parking_stallable_id - %td= parking_stall.parking_stallable_type %td= parking_stall.comment - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => parking_stall} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => parking_stall.parking_stallable, :child => parking_stall} \ No newline at end of file diff --git a/app/views/parking_stalls/index.html.haml b/app/views/parking_stalls/index.html.haml index 9472ff0..7f82bbe 100644 --- a/app/views/parking_stalls/index.html.haml +++ b/app/views/parking_stalls/index.html.haml @@ -3,4 +3,4 @@ - if @parking_stalls && @parking_stalls.count > 0 = render "index_core", :parking_stalls => @parking_stalls -= render :partial => 'shared/create_link', :locals => {:child_class => ParkingStall} \ No newline at end of file += render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => ParkingStall} \ No newline at end of file diff --git a/app/views/parking_stalls/show.html.haml b/app/views/parking_stalls/show.html.haml index a95c111..583a0ee 100644 --- a/app/views/parking_stalls/show.html.haml +++ b/app/views/parking_stalls/show.html.haml @@ -6,14 +6,8 @@ %p %strong= t('parking_stalls.show.lot') + ":" = @parking_stall.lot -%p - %strong= t('parking_stalls.show.parking_stallable_id') + ":" - = @parking_stall.parking_stallable_id -%p - %strong= t('parking_stalls.show.parking_stallable_type') + ":" - = @parking_stall.parking_stallable_type %p %strong= t('parking_stalls.show.comment') + ":" = @parking_stall.comment -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @parking_stall } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parking_stall.parking_stallable, :child => @parking_stall } diff --git a/config/routes.rb b/config/routes.rb index 8060f1c..db6c30f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,5 @@ Gemeinschaft42c::Application.routes.draw do - resources :parking_stalls - resources :intruders resources :backup_jobs, :except => [:edit, :update] @@ -199,6 +197,7 @@ Gemeinschaft42c::Application.routes.draw do resources :conferences resources :fax_accounts resources :system_messages, :except => [ :edit, :update, :destroy ] + resources :parking_stalls end resources :user_groups do @@ -226,6 +225,7 @@ Gemeinschaft42c::Application.routes.draw do end resources :hunt_groups resources :automatic_call_distributors + resources :parking_stalls end resources :callthroughs, :only => [] do -- cgit v1.2.3 From e7d1428b749024096b9a22b331d110bcf04f87d1 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 17:02:21 +0100 Subject: filter non-ascii characters --- app/models/intruder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/intruder.rb b/app/models/intruder.rb index db14bf8..8877c4c 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -18,10 +18,10 @@ class Intruder < ActiveRecord::Base before_validation :set_key_if_empty - def whois - if ! self.contact_ip.blank? + def whois(ip_address = self.contact_ip) + if ! ip_address.blank? begin - return Whois.whois(self.contact_ip) + return Whois.whois(ip_address).to_s.gsub(/[^A-Za-z0-9\:\_\-\ \+\.\,\n]/, '') rescue return nil end -- cgit v1.2.3 From 62f3f7373844185e763e1430926ebf880b0d5cb5 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 17:03:15 +0100 Subject: display whois information --- app/controllers/intruders_controller.rb | 6 ++++++ app/views/intruders/show.html.haml | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index eb34f2b..708e11a 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -5,6 +5,12 @@ class IntrudersController < ApplicationController def show @intruder = Intruder.find(params[:id]) + if ! params[:whois].blank? + @whois = @intruder.whois(params[:whois]) + if @whois.blank? + @whois = 'no information' + end + end end def new diff --git a/app/views/intruders/show.html.haml b/app/views/intruders/show.html.haml index 4941e89..325c5e3 100644 --- a/app/views/intruders/show.html.haml +++ b/app/views/intruders/show.html.haml @@ -21,6 +21,10 @@ %p %strong= t('intruders.show.contact_ip') + ":" = @intruder.contact_ip + - if ! @intruder.contact_ip.blank? && Object.const_defined?('Whois') + %a.btn.btn-small.btn-success{ :href => intruder_path(@intruder, :whois => @intruder.contact_ip) } + %i.icon-info-sign.icon-white + = 'Whois' %p %strong= t('intruders.show.contact_port') + ":" = @intruder.contact_port @@ -46,7 +50,8 @@ %strong= t('intruders.show.comment') + ":" = @intruder.comment -%p - %pre= @intruder.whois - = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @intruder } + +- if ! @whois.blank? + %p + %pre= @whois -- cgit v1.2.3 From 6891b0e62712c5c2772ef205b8393b7ed5e72495 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 23:29:55 +0100 Subject: breadcrumbs --- app/controllers/intruders_controller.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index 708e11a..147e06d 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -1,24 +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]) - if @whois.blank? - @whois = 'no information' - end 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 @@ -28,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 @@ -41,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 -- cgit v1.2.3 From 345c2b2b67cde33de7825a2cde32316900793fe9 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 23:30:50 +0100 Subject: remove non-ascii characters from whois reply --- app/models/intruder.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 8877c4c..249fffc 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -17,11 +17,14 @@ class Intruder < ActiveRecord::Base before_validation :set_key_if_empty + def to_s + key + end def whois(ip_address = self.contact_ip) if ! ip_address.blank? begin - return Whois.whois(ip_address).to_s.gsub(/[^A-Za-z0-9\:\_\-\ \+\.\,\n]/, '') + return Whois.whois(ip_address).to_s.gsub(/[^\u{0000}-\u{007F}]/, '') rescue return nil end -- cgit v1.2.3 From bc8ae7a653c7bc182bbdbff91498fa4504b7b9d9 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 23:31:23 +0100 Subject: intruder view --- app/views/intruders/show.html.haml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/intruders/show.html.haml b/app/views/intruders/show.html.haml index 325c5e3..df50872 100644 --- a/app/views/intruders/show.html.haml +++ b/app/views/intruders/show.html.haml @@ -21,10 +21,6 @@ %p %strong= t('intruders.show.contact_ip') + ":" = @intruder.contact_ip - - if ! @intruder.contact_ip.blank? && Object.const_defined?('Whois') - %a.btn.btn-small.btn-success{ :href => intruder_path(@intruder, :whois => @intruder.contact_ip) } - %i.icon-info-sign.icon-white - = 'Whois' %p %strong= t('intruders.show.contact_port') + ":" = @intruder.contact_port @@ -55,3 +51,8 @@ - if ! @whois.blank? %p %pre= @whois + +- elsif ! @intruder.contact_ip.blank? && Object.const_defined?('Whois') + %a.btn.btn-small.btn-success{ :href => intruder_path(@intruder, :whois => @intruder.contact_ip) } + %i.icon-info-sign.icon-white + = 'Whois' -- cgit v1.2.3 From 63963e63d8e211b15bedfd6719d67259440520a2 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 12 Feb 2013 23:54:20 +0100 Subject: index view --- app/views/intruders/_index_core.html.haml | 33 ++++++++++++++++--------------- config/locales/views/intruders/de.yml | 16 +++++++-------- config/locales/views/intruders/en.yml | 16 +++++++-------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/app/views/intruders/_index_core.html.haml b/app/views/intruders/_index_core.html.haml index 0070c4d..31bbd11 100644 --- a/app/views/intruders/_index_core.html.haml +++ b/app/views/intruders/_index_core.html.haml @@ -1,37 +1,38 @@ %table.table.table-striped %tr - %th= t('intruders.index.list_type') - %th= t('intruders.index.key') + %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_ip') - %th= t('intruders.index.contact_port') %th= t('intruders.index.contact_count') %th= t('intruders.index.contact_last') %th= t('intruders.index.contacts_per_second') - %th= t('intruders.index.contacts_per_second_max') %th= t('intruders.index.user_agent') %th= t('intruders.index.to_user') - %th= t('intruders.index.comment') - for intruder in intruders %tr - %td= intruder.list_type - %td= intruder.key - %td= intruder.points - %td= intruder.bans - %td= intruder.ban_last - %td= intruder.ban_end + %td= intruder.list_type.chars.first %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= intruder.contact_last + %td + - if intruder.contact_last + = l intruder.contact_last, :format => :short %td= intruder.contacts_per_second - %td= intruder.contacts_per_second_max %td= intruder.user_agent %td= intruder.to_user - %td= intruder.comment - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => intruder} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => intruder} diff --git a/config/locales/views/intruders/de.yml b/config/locales/views/intruders/de.yml index 42ece4b..5b67afe 100644 --- a/config/locales/views/intruders/de.yml +++ b/config/locales/views/intruders/de.yml @@ -11,16 +11,16 @@ de: key: 'Key' points: 'Points' bans: 'Bans' - ban_last: 'Ban last' + ban_last: 'Ban' ban_end: 'Ban end' - contact_ip: 'Contact ip' - contact_port: 'Contact port' - contact_count: 'Contact count' - contact_last: 'Contact last' - contacts_per_second: 'Contacts per second' - contacts_per_second_max: 'Contacts per second max' + contact_ip: 'IP' + contact_port: 'Port' + contact_count: 'Contact' + contact_last: 'Last' + contacts_per_second: 'Contacts/s' + contacts_per_second_max: 'max. Contacts/s' user_agent: 'User agent' - to_user: 'To user' + to_user: 'To' comment: 'Comment' actions: confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Intruder' diff --git a/config/locales/views/intruders/en.yml b/config/locales/views/intruders/en.yml index 99c2dcb..b9d65f4 100644 --- a/config/locales/views/intruders/en.yml +++ b/config/locales/views/intruders/en.yml @@ -11,16 +11,16 @@ en: key: 'Key' points: 'Points' bans: 'Bans' - ban_last: 'Ban last' + ban_last: 'Ban' ban_end: 'Ban end' - contact_ip: 'Contact ip' - contact_port: 'Contact port' - contact_count: 'Contact count' - contact_last: 'Contact last' - contacts_per_second: 'Contacts per second' - contacts_per_second_max: 'Contacts per second max' + contact_ip: 'IP' + contact_port: 'Port' + contact_count: 'Contact' + contact_last: 'Last' + contacts_per_second: 'Contacts/s' + contacts_per_second_max: 'max. Contacts/s' user_agent: 'User agent' - to_user: 'To user' + to_user: 'To' comment: 'Comment' actions: confirm_destroy: 'Are you sure you want to delete this Intruder?' -- cgit v1.2.3 From 6875af1a6f193ecc74653ad9372ab0ef2d0ef85e Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 13 Feb 2013 08:44:45 +0100 Subject: display softkeyable --- app/models/softkey.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 83c88ab..4b758e0 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -48,14 +48,14 @@ class Softkey < ActiveRecord::Base end def to_s - if (['call_forwarding'].include?(self.softkey_function.name)) - "#{self.softkeyable}" - else + if self.softkeyable.blank? if ['log_out', 'log_in'].include?(self.softkey_function.name) I18n.t("softkeys.functions.#{self.softkey_function.name}") else - "#{self.softkey_function.name} : #{self.number.to_s}" + "#{self.softkey_function.name} : #{self.number.to_s}" end + else + "#{self.softkeyable}" end end -- cgit v1.2.3 From 1b9b5327df5a81957b2042869213bb464c6e03ca Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 13 Feb 2013 08:47:26 +0100 Subject: dial action added --- app/views/config_snom/show.xml.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index 33204dc..1102ad1 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -176,7 +176,9 @@ %action - softkey[:actions].each do |action| - if action[:type] == :url - %url{:target => action[:target], :when => action[:when]} + %url{:target => action[:target], :when => action[:when], :states => action[:states]} + - elsif action[:type] == :dial + %dial{:target => action[:target], :when => action[:when], :states => action[:states], :request_uri => '$(remote_uri)'} %uploads - if @state_settings_url -- cgit v1.2.3 From 363963698b42ea19c1b7e30e2e04cdb5717b5d5a Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 13 Feb 2013 08:48:01 +0100 Subject: parking_stall softkey function --- app/controllers/config_snom_controller.rb | 47 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 58cced2..d36f990 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 |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 => "park+#{parking_stall.name}@#{sip_account.host}", + :for => "#{sip_account.auth_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({ -- cgit v1.2.3 From 79f0dfa8dda5062b66dfc22f07f42ea6604c8de2 Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 13 Feb 2013 01:49:43 -0600 Subject: Nav, user display size enforce and alignment. The avatar is now fixed to an acceptable size, which is enforced on the rendering level, rather than by the actual image. Also fixed the alignment issues. --- app/assets/stylesheets/gemeinschaft-generic.css.scss | 11 +++++++++++ app/views/layouts/_navbar.html.haml | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/gemeinschaft-generic.css.scss b/app/assets/stylesheets/gemeinschaft-generic.css.scss index e594d67..044b87b 100644 --- a/app/assets/stylesheets/gemeinschaft-generic.css.scss +++ b/app/assets/stylesheets/gemeinschaft-generic.css.scss @@ -6,6 +6,17 @@ body { padding-top: 60px; padding-bottom: 40px; } + +// Nav +li.display { + line-height: 40px; + img { + vertical-align: middle; + width: 26px; + margin-top: -2px; + } +} + @media (max-width: 979px) { body { padding-top: 0px; diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 7084090..8e09859 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -28,9 +28,9 @@ - if current_user %ul.nav.pull-right - %li + %li.display - if current_user.image? - =image_tag(current_user.image_url(:mini).to_s, :class => 'img-rounded') + = image_tag(current_user.image_url(:mini).to_s, :class => 'img-rounded') - else - if current_user.male? = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' @@ -39,15 +39,15 @@ - if current_page?(tenant_user_path(current_user.current_tenant, current_user)) %li.active - %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} + %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} = current_user - else %li - %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} + %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} = current_user - if single_sign_on_system? == false %li - %a.navbar-link{:href => log_out_path} + %a.navbar-link{:href => log_out_path} %i.icon-off.icon-white - + -- cgit v1.2.3 From 043967a309d9748c8d74d0d5eecdb90b4d433a8c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Feb 2013 09:06:28 +0000 Subject: language_code column added --- db/migrate/20130213082703_add_language_to_sip_account.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20130213082703_add_language_to_sip_account.rb diff --git a/db/migrate/20130213082703_add_language_to_sip_account.rb b/db/migrate/20130213082703_add_language_to_sip_account.rb new file mode 100644 index 0000000..24343ef --- /dev/null +++ b/db/migrate/20130213082703_add_language_to_sip_account.rb @@ -0,0 +1,5 @@ +class AddLanguageToSipAccount < ActiveRecord::Migration + def change + add_column :sip_accounts, :language_code, :string + end +end -- cgit v1.2.3 From 14b400d563b2d33706491a20e997a1062b9acc69 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 13 Feb 2013 10:08:01 +0100 Subject: language_code added to sip_account classes --- app/models/sip_account.rb | 4 +++- misc/freeswitch/scripts/common/sip_account.lua | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 9ba1f8b..7df8e3b 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -6,7 +6,7 @@ class SipAccount < ActiveRecord::Base attr_accessible :auth_name, :caller_name, :password, :voicemail_pin, :tenant_id, :call_waiting, :clir, :clip_no_screening, :clip, :description, :callforward_rules_act_per_sip_account, - :hotdeskable, :gs_node_id + :hotdeskable, :gs_node_id, :language_code # Associations: # @@ -31,6 +31,8 @@ class SipAccount < ActiveRecord::Base belongs_to :gs_node + belongs_to :language, :foreign_key => 'language_code', :primary_key => 'code' + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true diff --git a/misc/freeswitch/scripts/common/sip_account.lua b/misc/freeswitch/scripts/common/sip_account.lua index d023f20..5b1ea56 100644 --- a/misc/freeswitch/scripts/common/sip_account.lua +++ b/misc/freeswitch/scripts/common/sip_account.lua @@ -38,6 +38,7 @@ function SipAccount.find_by_sql(self, where) `a`.`sip_accountable_id`, \ `a`.`hotdeskable`, \ `a`.`gs_node_id`, \ + `a`.`language_code`, \ `b`.`host`, \ `c`.`sip_host`, \ `c`.`profile_name` \ -- cgit v1.2.3 From 964c81fc615b35c9ee909a47901f307be6ce2c3a Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 13 Feb 2013 04:10:53 -0600 Subject: Update simple_form to 2.1. The reason for this is that, after doing some research, it seems that TB is not completely supported out of the box by the older versions, making it hard for me to implement some needed things. --- Gemfile | 3 +-- Gemfile.lock | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index b390a28..c90adb5 100644 --- a/Gemfile +++ b/Gemfile @@ -49,8 +49,7 @@ group :test do end gem "haml" -gem "simple_form", '2.0.1' - +gem "simple_form", github: 'plataformatec/simple_form', branch: 'v2.1' # Image Upload gem 'carrierwave' gem "mini_magick" diff --git a/Gemfile.lock b/Gemfile.lock index 8491109..6f4888b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,12 @@ +GIT + remote: git://github.com/plataformatec/simple_form.git + revision: e3da7301dcf6feb9a1db275ff5cb3f85afce0e80 + branch: v2.1 + specs: + simple_form (2.1.0.dev) + actionpack (~> 3.0) + activemodel (~> 3.0) + GEM remote: http://rubygems.org/ specs: @@ -141,9 +150,6 @@ GEM sextant (0.2.3) activesupport (>= 3.2) rails (>= 3.2) - simple_form (2.0.1) - actionpack (~> 3.0) - activemodel (~> 3.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -214,7 +220,7 @@ DEPENDENCIES rails (= 3.2.11) sass-rails sextant - simple_form (= 2.0.1) + simple_form! sqlite3 state_machine strong_parameters -- cgit v1.2.3 From 7d507dcc1bbbf5244b8d75f40c7cb6bc15906b33 Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 13 Feb 2013 04:11:17 -0600 Subject: Implements Fixes to TB for simple_form --- app/assets/stylesheets/gemeinschaft-generic.css.scss | 10 ++++++++++ config/initializers/simple_form.rb | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/gemeinschaft-generic.css.scss b/app/assets/stylesheets/gemeinschaft-generic.css.scss index 044b87b..fbeaa1f 100644 --- a/app/assets/stylesheets/gemeinschaft-generic.css.scss +++ b/app/assets/stylesheets/gemeinschaft-generic.css.scss @@ -17,6 +17,16 @@ li.display { } } +// SimpleForm Inline Checkbox Fix +.simple-checkbox .checkbox { + text-align: left; + width: auto; + float: none; +} +input, textarea, .uneditable-input { + width: 500px; +} + @media (max-width: 979px) { body { padding-top: 0px; diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index 572d58f..062f823 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -82,6 +82,20 @@ SimpleForm.setup do |config| end end + config.wrappers :checkbox, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b| + b.use :html5 + b.use :placeholder + b.wrapper :tag => 'div', :class => 'controls' do |input| + input.wrapper :tag => 'div', :class => 'simple-checkbox' do |prepend| + prepend.use :label_input + end + input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' } + input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } + end + end + + config.wrapper_mappings = { :boolean => :checkbox } + # Wrappers for forms and inputs using the Twitter Bootstrap toolkit. # Check the Bootstrap docs (http://twitter.github.com/bootstrap) # to learn about the different styles for forms and inputs, @@ -95,7 +109,7 @@ SimpleForm.setup do |config| config.boolean_style = :nested # Default class for buttons - config.button_class = 'btn btn-primary' + config.button_class = 'btn' # Method used to tidy up errors. # config.error_method = :first @@ -136,7 +150,7 @@ SimpleForm.setup do |config| config.label_class = 'control-label' # You can define the class to use on all forms. Default is simple_form. - # config.form_class = :simple_form + config.form_class = 'simple_form form-horizontal' # You can define which elements should obtain additional classes # config.generate_additional_classes_for = [:wrapper, :label, :input] @@ -163,7 +177,7 @@ SimpleForm.setup do |config| # config.country_priority = nil # Default size for text inputs. - # config.default_input_size = 50 + config.default_input_size = 150 # When false, do not use translations for labels. # config.translate_labels = true -- cgit v1.2.3 From 8a496ffec7df055d31429076322cb767f1728c44 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 11:11:56 +0100 Subject: Added a cronjob for the auto-reboot of phones. #169 --- config/schedule.rb | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/config/schedule.rb b/config/schedule.rb index 0b5f0ca..94603f1 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,24 +1,13 @@ -# Use this file to easily define all of your cron jobs. +# Daily Backup # -# It's helpful, but not entirely necessary to understand cron before proceeding. -# http://en.wikipedia.org/wiki/Cron - -# Example: -# -# set :output, "/path/to/my/cron_log.log" -# -# every 2.hours do -# command "/usr/bin/some_great_command" -# runner "MyModel.some_method" -# rake "some:great:rake:task" -# end -# -# every 4.days do -# runner "AnotherModel.prune_old_records" -# end - every 1.day, :at => '4:00 am' do rake "backup:daily_backup" end +# Auto-Reboot of Phones which should be rebootet +# +every 1.day, :at => '2:30 am' do + command "/opt/GS5/script/logout_phones.sh" +end + # Learn more: http://github.com/javan/whenever -- cgit v1.2.3 From 7d5aa2333f61ea8a89d52f09f0719e8cd8973c7f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 11:58:17 +0100 Subject: Removed def to_s which was buggy. closes #171 --- app/models/fax_document.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index be689e2..16fdc70 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -48,10 +48,6 @@ class FaxDocument < ActiveRecord::Base end end - def to_s - name - end - def render_thumbnails directory = "/tmp/GS-#{GsParameter.get('GEMEINSCHAFT_VERSION')}/fax_thumbnails/#{self.id}" system('mkdir -p ' + directory) -- cgit v1.2.3 From 2fc71d2c420fcb328165f91806080367a9fa2928 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 13 Feb 2013 12:13:19 +0100 Subject: dialplan language handling --- .../20130213110000_add_sounds_to_parameters.rb | 10 +++ misc/freeswitch/conf/freeswitch.xml | 95 +++++++++++++++++++++- misc/freeswitch/scripts/common/conference.lua | 11 ++- misc/freeswitch/scripts/dialplan/dialplan.lua | 12 ++- 4 files changed, 116 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20130213110000_add_sounds_to_parameters.rb diff --git a/db/migrate/20130213110000_add_sounds_to_parameters.rb b/db/migrate/20130213110000_add_sounds_to_parameters.rb new file mode 100644 index 0000000..8c4cd94 --- /dev/null +++ b/db/migrate/20130213110000_add_sounds_to_parameters.rb @@ -0,0 +1,10 @@ +class AddSoundsToParameters < ActiveRecord::Migration + def up + GsParameter.create(:entity => 'dialplan', :section => 'sounds', :name => 'en', :value => '/opt/freeswitch/sounds/en/us/callie', :class_type => 'String') + GsParameter.create(:entity => 'dialplan', :section => 'sounds', :name => 'de', :value => '/opt/freeswitch/sounds/de/de/callie', :class_type => 'String') + end + + def down + GsParameter.where(:entity => 'dialplan', :section => 'sounds').destroy_all + end +end diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml index a5fe873..4969b07 100644 --- a/misc/freeswitch/conf/freeswitch.xml +++ b/misc/freeswitch/conf/freeswitch.xml @@ -1,8 +1,7 @@ -
- + @@ -462,11 +461,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -927,6 +971,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/misc/freeswitch/scripts/common/conference.lua b/misc/freeswitch/scripts/common/conference.lua index ca5fa62..f6a4d87 100644 --- a/misc/freeswitch/scripts/common/conference.lua +++ b/misc/freeswitch/scripts/common/conference.lua @@ -157,7 +157,7 @@ function Conference.enter(self, caller, domain) caller:answer(); caller:sleep(1000); - caller.session:streamFile('conference/conf-welcome.wav'); + caller.session:sayPhrase('conference_welcome'); if pin and pin ~= "" then local digits = ""; @@ -165,12 +165,12 @@ function Conference.enter(self, caller, domain) if digits == pin then break elseif digits ~= "" then - caller.session:streamFile('conference/conf-bad-pin.wav'); + caller.session:sayPhrase('conference_bad_pin'); end digits = caller.session:read(PIN_LENGTH_MIN, PIN_LENGTH_MAX, 'conference/conf-enter_conf_pin.wav', PIN_TIMEOUT, '#'); end if digits ~= pin then - caller.session:streamFile("conference/conf-goodbye.wav"); + caller.session:sayPhrase('conference_goodbye'); return "CALL_REJECTED"; end end @@ -192,8 +192,7 @@ function Conference.enter(self, caller, domain) if common.str.to_b(self.record.announce_new_member_by_name) or common.str.to_b(self.record.announce_left_member_by_name) then local uid = session:get_uuid(); name_file = "/tmp/conference_caller_name_" .. uid .. ".wav"; - caller.session:streamFile("voicemail/vm-record_name1.wav"); - caller.session:execute("playback", "tone_stream://%(1000,0,500)"); + caller.session:sayPhrase('conference_record_name'); session:recordFile(name_file, ANNOUNCEMENT_MAX_LEN, ANNOUNCEMENT_SILENCE_THRESHOLD, ANNOUNCEMENT_SILENCE_LEN); caller.session:streamFile(name_file); end @@ -209,7 +208,7 @@ function Conference.enter(self, caller, domain) local result = caller.session:execute('conference', self.record.id .. "@profile_" .. self.record.id .. "++flags{" .. table.concat(flags, '|') .. "}"); self.log:debug('exited conference - result: ' .. tostring(result)); - caller.session:streamFile("conference/conf-goodbye.wav") + caller.session:sayPhrase('conference_goodbye'); -- Play leaving caller's name if recorded if name_file then diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 72503e5..b27bb9d 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -270,7 +270,10 @@ function Dialplan.retrieve_caller_data(self) for index, caller_number in ipairs(self.caller.caller_phone_numbers) do self.caller.caller_phone_numbers_hash[caller_number] = true; end - self.log:info('CALLER_DATA - caller account: ', self.caller.account.class, '=', self.caller.account.id, '/', self.caller.account.uuid, ', phone_numbers: ', #self.caller.caller_phone_numbers); + if not common.str.blank(self.caller.account.record.language_code) then + self.caller.language = self.caller.account.record.language_code; + end + self.log:info('CALLER_DATA - caller account: ', self.caller.account.class, '=', self.caller.account.id, '/', self.caller.account.uuid, ', phone_numbers: ', #self.caller.caller_phone_numbers, ', language: ', self.caller.language); if self.caller.account.owner then self.log:info('CALLER_DATA - caller owner: ', self.caller.account.owner.class, '=', self.caller.account.owner.id, '/', self.caller.account.owner.uuid); else @@ -859,7 +862,6 @@ function Dialplan.run(self, destination) self.caller:set_variable('hangup_after_bridge', false); self.caller:set_variable('bridge_early_media', 'true'); - self.caller:set_variable('default_language', self.default_language); self.caller:set_variable('gs_save_cdr', true); self.caller:set_variable('gs_call_service', 'dial'); self.caller.session:setAutoHangup(false); @@ -876,6 +878,8 @@ function Dialplan.run(self, destination) self:retrieve_caller_data(); self.route_failover = common.configuration_table.get(self.database, 'call_route', 'failover'); + self.caller.language = self.caller.language or self.default_language; + if not destination or destination.type == 'unknown' then local route = nil; if self.caller.gateway then @@ -937,7 +941,9 @@ function Dialplan.run(self, destination) end end - self.log:info('DIALPLAN start - caller_id: ',self.caller.caller_id_number, ' "', self.caller.caller_id_name, '" , number: ', destination.number); + self.caller:set_variable('default_language', self.caller.language); + self.caller:set_variable('sound_prefix', common.str.try(self.config, 'sounds.' .. tostring(self.caller.language))); + self.log:info('DIALPLAN start - caller_id: ',self.caller.caller_id_number, ' "', self.caller.caller_id_name, '" , number: ', destination.number, ', language: ', self.caller.language); local result = { continue = false }; local loop = self.caller.loop_count; -- cgit v1.2.3 From 791bf973b02b626f876b7e5819e2037dcff90f84 Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 13 Feb 2013 05:39:21 -0600 Subject: Simple Form Fixes for Form Actions --- app/views/access_authorizations/_form.html.haml | 4 ++-- app/views/acd_agents/_form.html.haml | 4 ++-- app/views/addresses/_form.html.haml | 4 ++-- app/views/automatic_call_distributors/_form.html.haml | 4 ++-- app/views/backup_jobs/_form.html.haml | 4 ++-- app/views/call_forwards/_form.html.haml | 4 ++-- app/views/call_routes/_form.html.haml | 4 ++-- app/views/callthroughs/_form.html.haml | 2 +- app/views/conference_invitees/_form.html.haml | 4 ++-- app/views/conferences/_form.html.haml | 4 ++-- app/views/fax_accounts/_form.html.haml | 4 ++-- app/views/fax_documents/_form.html.haml | 4 ++-- app/views/gateway_parameters/_form.html.haml | 4 ++-- app/views/gateway_settings/_form.html.haml | 2 +- app/views/gateways/_form.html.haml | 4 ++-- app/views/gemeinschaft_setups/new.de.html.haml | 4 ++-- app/views/gemeinschaft_setups/new.html.haml | 4 ++-- app/views/gs_cluster_sync_log_entries/_form.html.haml | 4 ++-- app/views/gs_nodes/_form.html.haml | 4 ++-- app/views/gs_parameters/_form.html.haml | 4 ++-- app/views/gui_functions/_form.html.haml | 4 ++-- app/views/hunt_group_members/_form.html.haml | 4 ++-- app/views/hunt_groups/_form.html.haml | 4 ++-- app/views/intruders/_form.html.haml | 4 ++-- app/views/manufacturers/_form.html.haml | 4 ++-- app/views/parking_stalls/_form.html.haml | 4 ++-- app/views/phone_book_entries/_form.html.haml | 4 ++-- app/views/phone_books/_form.html.haml | 4 ++-- app/views/phone_models/_form.html.haml | 4 ++-- app/views/phone_number_ranges/_form.html.haml | 4 ++-- app/views/phone_numbers/_form.html.haml | 2 +- app/views/phone_sip_accounts/_form.html.haml | 4 ++-- app/views/phones/_form.html.haml | 4 ++-- app/views/ringtones/_form.html.haml | 4 ++-- app/views/route_elements/_form.html.haml | 4 ++-- app/views/sessions/new.html.haml | 2 +- app/views/sip_accounts/_form.html.haml | 4 ++-- app/views/sip_domains/_form.html.haml | 4 ++-- app/views/softkeys/_form.html.haml | 4 ++-- app/views/tenants/_form.html.haml | 4 ++-- app/views/tenants/_index_core.html.haml | 4 ++-- app/views/user_group_memberships/_form.html.haml | 4 ++-- app/views/user_groups/_form.html.haml | 4 ++-- app/views/users/_form.html.haml | 4 ++-- app/views/voicemail_messages/_index_core.html.haml | 6 +++--- app/views/voicemail_settings/_form.html.haml | 4 ++-- app/views/whitelists/_form.html.haml | 4 ++-- .../nifty/authentication/templates/views/haml/_form.html.haml | 2 +- .../nifty/authentication/templates/views/haml/login.html.haml | 4 ++-- lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml | 4 ++-- 50 files changed, 96 insertions(+), 96 deletions(-) diff --git a/app/views/access_authorizations/_form.html.haml b/app/views/access_authorizations/_form.html.haml index fa417d9..fba4297 100644 --- a/app/views/access_authorizations/_form.html.haml +++ b/app/views/access_authorizations/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('access_authorizations.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('access_authorizations.form.submit') diff --git a/app/views/acd_agents/_form.html.haml b/app/views/acd_agents/_form.html.haml index 3b78bac..df1c2ef 100644 --- a/app/views/acd_agents/_form.html.haml +++ b/app/views/acd_agents/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('acd_agents.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('acd_agents.form.submit') diff --git a/app/views/addresses/_form.html.haml b/app/views/addresses/_form.html.haml index eff9930..4c58009 100644 --- a/app/views/addresses/_form.html.haml +++ b/app/views/addresses/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('addresses.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('addresses.form.submit') diff --git a/app/views/automatic_call_distributors/_form.html.haml b/app/views/automatic_call_distributors/_form.html.haml index fcf133c..d4cf97c 100644 --- a/app/views/automatic_call_distributors/_form.html.haml +++ b/app/views/automatic_call_distributors/_form.html.haml @@ -4,5 +4,5 @@ = render "form_core", :f => f, :join_on => @join_on, :leave_on => @leave_on, :strategies => @strategies - .actions - = f.button :submit, conditional_t('automatic_call_distributors.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('automatic_call_distributors.form.submit') diff --git a/app/views/backup_jobs/_form.html.haml b/app/views/backup_jobs/_form.html.haml index e0adceb..41d0dc8 100644 --- a/app/views/backup_jobs/_form.html.haml +++ b/app/views/backup_jobs/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('backup_jobs.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('backup_jobs.form.submit') diff --git a/app/views/call_forwards/_form.html.haml b/app/views/call_forwards/_form.html.haml index 7310af3..58ffd78 100644 --- a/app/views/call_forwards/_form.html.haml +++ b/app/views/call_forwards/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('call_forwards.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('call_forwards.form.submit') diff --git a/app/views/call_routes/_form.html.haml b/app/views/call_routes/_form.html.haml index 1415852..0a96060 100644 --- a/app/views/call_routes/_form.html.haml +++ b/app/views/call_routes/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('call_routes.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('call_routes.form.submit') diff --git a/app/views/callthroughs/_form.html.haml b/app/views/callthroughs/_form.html.haml index 99f92d0..870d3f0 100644 --- a/app/views/callthroughs/_form.html.haml +++ b/app/views/callthroughs/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions + .form-actions = f.button :submit, conditional_t('callthroughs.form.submit') diff --git a/app/views/conference_invitees/_form.html.haml b/app/views/conference_invitees/_form.html.haml index 400580d..6ec987b 100644 --- a/app/views/conference_invitees/_form.html.haml +++ b/app/views/conference_invitees/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('conference_invitees.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('conference_invitees.form.submit') diff --git a/app/views/conferences/_form.html.haml b/app/views/conferences/_form.html.haml index 4bee1a4..0a88a00 100644 --- a/app/views/conferences/_form.html.haml +++ b/app/views/conferences/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('conferences.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('conferences.form.submit') diff --git a/app/views/fax_accounts/_form.html.haml b/app/views/fax_accounts/_form.html.haml index 0a5a4c0..de66709 100644 --- a/app/views/fax_accounts/_form.html.haml +++ b/app/views/fax_accounts/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('fax_accounts.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('fax_accounts.form.submit') diff --git a/app/views/fax_documents/_form.html.haml b/app/views/fax_documents/_form.html.haml index e240371..1b1c3be 100644 --- a/app/views/fax_documents/_form.html.haml +++ b/app/views/fax_documents/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('fax_documents.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('fax_documents.form.submit') diff --git a/app/views/gateway_parameters/_form.html.haml b/app/views/gateway_parameters/_form.html.haml index 79342d2..bb98ce0 100644 --- a/app/views/gateway_parameters/_form.html.haml +++ b/app/views/gateway_parameters/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gateway_parameters.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gateway_parameters.form.submit') diff --git a/app/views/gateway_settings/_form.html.haml b/app/views/gateway_settings/_form.html.haml index af26d2a..ad4b34b 100644 --- a/app/views/gateway_settings/_form.html.haml +++ b/app/views/gateway_settings/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions + .form-actions = f.button :submit, conditional_t('gateway_settings.form.submit') diff --git a/app/views/gateways/_form.html.haml b/app/views/gateways/_form.html.haml index 5f6d5dd..705d417 100644 --- a/app/views/gateways/_form.html.haml +++ b/app/views/gateways/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gateways.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gateways.form.submit') diff --git a/app/views/gemeinschaft_setups/new.de.html.haml b/app/views/gemeinschaft_setups/new.de.html.haml index f977291..3c215d1 100644 --- a/app/views/gemeinschaft_setups/new.de.html.haml +++ b/app/views/gemeinschaft_setups/new.de.html.haml @@ -26,5 +26,5 @@ = f.simple_fields_for :sip_domain, @sip_domain do |s| = render "sip_domains/form_core", :f => s - .actions - = f.button :submit, conditional_t('gemeinschaft_setups.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gemeinschaft_setups.form.submit') diff --git a/app/views/gemeinschaft_setups/new.html.haml b/app/views/gemeinschaft_setups/new.html.haml index 44d9c5b..deac19d 100644 --- a/app/views/gemeinschaft_setups/new.html.haml +++ b/app/views/gemeinschaft_setups/new.html.haml @@ -26,5 +26,5 @@ = f.simple_fields_for :sip_domain, @sip_domain do |s| = render "sip_domains/form_core", :f => s - .actions - = f.button :submit, conditional_t('gemeinschaft_setups.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gemeinschaft_setups.form.submit') diff --git a/app/views/gs_cluster_sync_log_entries/_form.html.haml b/app/views/gs_cluster_sync_log_entries/_form.html.haml index 2c47d88..28f1848 100644 --- a/app/views/gs_cluster_sync_log_entries/_form.html.haml +++ b/app/views/gs_cluster_sync_log_entries/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gs_cluster_sync_log_entries.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gs_cluster_sync_log_entries.form.submit') diff --git a/app/views/gs_nodes/_form.html.haml b/app/views/gs_nodes/_form.html.haml index 28a4e5d..5ff6d40 100644 --- a/app/views/gs_nodes/_form.html.haml +++ b/app/views/gs_nodes/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gs_nodes.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gs_nodes.form.submit') diff --git a/app/views/gs_parameters/_form.html.haml b/app/views/gs_parameters/_form.html.haml index ea69e95..eb578ff 100644 --- a/app/views/gs_parameters/_form.html.haml +++ b/app/views/gs_parameters/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gs_parameters.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gs_parameters.form.submit') diff --git a/app/views/gui_functions/_form.html.haml b/app/views/gui_functions/_form.html.haml index 0b2a201..b1b68f9 100644 --- a/app/views/gui_functions/_form.html.haml +++ b/app/views/gui_functions/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('gui_functions.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('gui_functions.form.submit') diff --git a/app/views/hunt_group_members/_form.html.haml b/app/views/hunt_group_members/_form.html.haml index 1ab7850..7cdef92 100644 --- a/app/views/hunt_group_members/_form.html.haml +++ b/app/views/hunt_group_members/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('hunt_group_members.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('hunt_group_members.form.submit') diff --git a/app/views/hunt_groups/_form.html.haml b/app/views/hunt_groups/_form.html.haml index bc2663b..86cd433 100644 --- a/app/views/hunt_groups/_form.html.haml +++ b/app/views/hunt_groups/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('hunt_groups.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('hunt_groups.form.submit') diff --git a/app/views/intruders/_form.html.haml b/app/views/intruders/_form.html.haml index 26aab1c..02647f0 100644 --- a/app/views/intruders/_form.html.haml +++ b/app/views/intruders/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('intruders.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('intruders.form.submit') diff --git a/app/views/manufacturers/_form.html.haml b/app/views/manufacturers/_form.html.haml index d89c603..ce4eea4 100644 --- a/app/views/manufacturers/_form.html.haml +++ b/app/views/manufacturers/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('manufacturers.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('manufacturers.form.submit') diff --git a/app/views/parking_stalls/_form.html.haml b/app/views/parking_stalls/_form.html.haml index 60b60b7..f72c190 100644 --- a/app/views/parking_stalls/_form.html.haml +++ b/app/views/parking_stalls/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('parking_stalls.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('parking_stalls.form.submit') diff --git a/app/views/phone_book_entries/_form.html.haml b/app/views/phone_book_entries/_form.html.haml index c73d10a..b579bf4 100644 --- a/app/views/phone_book_entries/_form.html.haml +++ b/app/views/phone_book_entries/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phone_book_entries.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phone_book_entries.form.submit') diff --git a/app/views/phone_books/_form.html.haml b/app/views/phone_books/_form.html.haml index 245426b..df5d060 100644 --- a/app/views/phone_books/_form.html.haml +++ b/app/views/phone_books/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phone_books.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phone_books.form.submit') diff --git a/app/views/phone_models/_form.html.haml b/app/views/phone_models/_form.html.haml index 45c176f..2b09f6d 100644 --- a/app/views/phone_models/_form.html.haml +++ b/app/views/phone_models/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phone_models.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phone_models.form.submit') diff --git a/app/views/phone_number_ranges/_form.html.haml b/app/views/phone_number_ranges/_form.html.haml index a86d45b..d624619 100644 --- a/app/views/phone_number_ranges/_form.html.haml +++ b/app/views/phone_number_ranges/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phone_number_ranges.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phone_number_ranges.form.submit') diff --git a/app/views/phone_numbers/_form.html.haml b/app/views/phone_numbers/_form.html.haml index 2812e21..8ef1e90 100644 --- a/app/views/phone_numbers/_form.html.haml +++ b/app/views/phone_numbers/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions + .form-actions = f.button :submit, conditional_t('phone_numbers.form.submit') diff --git a/app/views/phone_sip_accounts/_form.html.haml b/app/views/phone_sip_accounts/_form.html.haml index c2558b8..8b214de 100644 --- a/app/views/phone_sip_accounts/_form.html.haml +++ b/app/views/phone_sip_accounts/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phone_sip_accounts.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phone_sip_accounts.form.submit') diff --git a/app/views/phones/_form.html.haml b/app/views/phones/_form.html.haml index 9bfa226..3cb62e6 100644 --- a/app/views/phones/_form.html.haml +++ b/app/views/phones/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('phones.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('phones.form.submit') diff --git a/app/views/ringtones/_form.html.haml b/app/views/ringtones/_form.html.haml index 7dbfcb0..789362f 100644 --- a/app/views/ringtones/_form.html.haml +++ b/app/views/ringtones/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('ringtones.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('ringtones.form.submit') diff --git a/app/views/route_elements/_form.html.haml b/app/views/route_elements/_form.html.haml index 8feacaa..b59be36 100644 --- a/app/views/route_elements/_form.html.haml +++ b/app/views/route_elements/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('route_elements.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('route_elements.form.submit') diff --git a/app/views/sessions/new.html.haml b/app/views/sessions/new.html.haml index f386a5d..75dd3de 100644 --- a/app/views/sessions/new.html.haml +++ b/app/views/sessions/new.html.haml @@ -4,5 +4,5 @@ = t.input :login_data, :label => t('sessions.form.email'), :autofocus => true = t.input :password, :label => t('sessions.form.password'), :required => false = t.input :reset_password, :label => t('sessions.form.reset_password'), :as => :boolean - .actions + .form-actions = t.button :submit, :value => 'Login' diff --git a/app/views/sip_accounts/_form.html.haml b/app/views/sip_accounts/_form.html.haml index f209bf4..d40ce10 100644 --- a/app/views/sip_accounts/_form.html.haml +++ b/app/views/sip_accounts/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('sip_accounts.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('sip_accounts.form.submit') diff --git a/app/views/sip_domains/_form.html.haml b/app/views/sip_domains/_form.html.haml index 2d662af..83ba7ad 100644 --- a/app/views/sip_domains/_form.html.haml +++ b/app/views/sip_domains/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('sip_domains.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('sip_domains.form.submit') diff --git a/app/views/softkeys/_form.html.haml b/app/views/softkeys/_form.html.haml index 5b799b6..c029ead 100644 --- a/app/views/softkeys/_form.html.haml +++ b/app/views/softkeys/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('softkeys.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('softkeys.form.submit') diff --git a/app/views/tenants/_form.html.haml b/app/views/tenants/_form.html.haml index 1641e78..981293c 100644 --- a/app/views/tenants/_form.html.haml +++ b/app/views/tenants/_form.html.haml @@ -20,5 +20,5 @@ - if GsParameter.get('STRICT_DID_HANDLING') == true = f.input :did_list, :label => t('tenants.form.did_list.label'), :hint => conditional_hint('tenants.form.did_list.hint') - .actions - = f.button :submit, conditional_t('tenants.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('tenants.form.submit') diff --git a/app/views/tenants/_index_core.html.haml b/app/views/tenants/_index_core.html.haml index a220b1b..2430b67 100644 --- a/app/views/tenants/_index_core.html.haml +++ b/app/views/tenants/_index_core.html.haml @@ -13,6 +13,6 @@ - if current_user && current_user.current_tenant != tenant && current_user.tenants.include?(tenant) = simple_form_for([current_user.current_tenant, current_user]) do |f| = f.hidden_field :current_tenant_id, :value => tenant.id - .actions + .form-actions = f.button :submit, conditional_t('tenants.switch_to_tenant') - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => tenant} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => tenant} diff --git a/app/views/user_group_memberships/_form.html.haml b/app/views/user_group_memberships/_form.html.haml index 3c0fee1..e810597 100644 --- a/app/views/user_group_memberships/_form.html.haml +++ b/app/views/user_group_memberships/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('user_group_memberships.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('user_group_memberships.form.submit') diff --git a/app/views/user_groups/_form.html.haml b/app/views/user_groups/_form.html.haml index 3263fdd..5076e74 100644 --- a/app/views/user_groups/_form.html.haml +++ b/app/views/user_groups/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('user_groups.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('user_groups.form.submit') diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 9a75677..90d0e02 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -4,7 +4,7 @@ = render "form_core", :f => f - .actions + .form-actions = f.button :submit, conditional_t('users.form.submit') - else = simple_form_for(@user) do |f| @@ -12,5 +12,5 @@ = render "form_core", :f => f - .actions + .form-actions = f.button :submit, conditional_t('users.form.submit') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index f03002d..5e82761 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -24,18 +24,18 @@ %td - if ! voicemail_message.flags.blank? = t("voicemail_messages.index.flags.#{voicemail_message.flags}") - %td.actions + %td.form-actions - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) = link_to t('voicemail_messages.index.actions.download'), sip_account_voicemail_message_path(@sip_account, voicemail_message, :format => :wav), :method => :get %td.actions - if @sip_account.registration && can?(:call, voicemail_message) = link_to t('voicemail_messages.index.actions.call'), call_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put - %td.actions + %td.form-actions - if can?(:edit, voicemail_message) && voicemail_message.read_epoch > 0 = link_to t('voicemail_messages.index.actions.mark_unread'), mark_unread_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put - else = link_to t('voicemail_messages.index.actions.mark_read'), mark_read_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put - %td.actions + %td.form-actions - if can? :destroy, voicemail_message = link_to t('voicemail_messages.index.actions.destroy'), sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :delete diff --git a/app/views/voicemail_settings/_form.html.haml b/app/views/voicemail_settings/_form.html.haml index 6d5f845..cd43b2d 100644 --- a/app/views/voicemail_settings/_form.html.haml +++ b/app/views/voicemail_settings/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('voicemail_settings.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('voicemail_settings.form.submit') diff --git a/app/views/whitelists/_form.html.haml b/app/views/whitelists/_form.html.haml index c7f787a..71dbe6b 100644 --- a/app/views/whitelists/_form.html.haml +++ b/app/views/whitelists/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('whitelists.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('whitelists.form.submit') diff --git a/lib/generators/nifty/authentication/templates/views/haml/_form.html.haml b/lib/generators/nifty/authentication/templates/views/haml/_form.html.haml index 992ee9c..e740959 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/_form.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/_form.html.haml @@ -12,5 +12,5 @@ .field = f.label :password_confirmation, "Confirm Password" = f.password_field :password_confirmation - .actions + .form-actions = f.submit (@<%= user_singular_name %>.new_record? ? "Sign up" : "Update") diff --git a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml index 3aebb44..877d8f9 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml @@ -11,7 +11,7 @@ .field = f.label :password = f.password_field :password - .actions + .form-actions = f.submit "Log in" <%- else -%> - form_tag <%= session_plural_name %>_path do @@ -21,6 +21,6 @@ .field = label_tag :password = password_field_tag :password - .actions + .form-actions = submit_tag "Log in" <%- end -%> diff --git a/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml index 57cb828..b12f1cb 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml @@ -3,5 +3,5 @@ = render "form_core", :f => f - .actions - = f.button :submit, conditional_t('<%= plural_name %>.form.submit') \ No newline at end of file + .form-actions + = f.button :submit, conditional_t('<%= plural_name %>.form.submit') -- cgit v1.2.3 From d216accd6f00ec90e19f3171440ae7c5d7cdb53a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 14:13:04 +0100 Subject: Better UI for FaxDocument#show --- app/views/fax_documents/show.html.haml | 62 +++++++++++++++++++++------------- db/schema.rb | 13 ++++++- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index 41d3bff..de8c1cc 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -2,35 +2,49 @@ - child = @fax_document - parent = @fax_document.fax_account -%p - %strong= t('fax_documents.index.state') + ":" - = t("fax_documents.states.#{@fax_document.state}") - -%p - %strong= t('fax_documents.index.result_code') + ":" - = @fax_document.result_code - -%p - %strong= t('fax_documents.index.result_text') + ":" - = t("fax_documents.result_codes.code_#{@fax_document.result_code}") - -%p - %strong= t('fax_documents.show.document_transferred_pages') + ":" - = @fax_document.document_transferred_pages -%p - %strong= t('fax_documents.show.remote_station_id') + ":" - = @fax_document.remote_station_id -%p - %strong= t('fax_documents.show.fax_resolution') + ":" - = @fax_document.fax_resolution +%table.table.table-striped + %tr + %td + %strong= t('fax_documents.index.state') + ":" + %td + = t("fax_documents.states.#{@fax_document.state}") + %tr + %td + %strong= t('fax_documents.index.result_code') + ":" + %td + = @fax_document.result_code + %tr + %td + %strong= t('fax_documents.index.result_text') + ":" + %td + = t("fax_documents.result_codes.code_#{@fax_document.result_code}") + %tr + %td + %strong= t('fax_documents.show.document_transferred_pages') + ":" + %td + = @fax_document.document_transferred_pages + %tr + %td + %strong= t('fax_documents.show.remote_station_id') + ":" + %td + = @fax_document.remote_station_id + %tr + %td + %strong= t('fax_documents.show.fax_resolution') + ":" + %td + = @fax_document.fax_resolution - if @fax_document.fax_thumbnails.count > 0 - i = @fax_document.fax_thumbnails.count - i = 10 if i > 10 - - @fax_document.fax_thumbnails.limit(i).each do |fax_thumbnail| - =image_tag fax_thumbnail.thumbnail_url(:medium), :class => 'FaxThumbnail', :alt => "Thumbnail of page \##{fax_thumbnail.position}" + %p + - @fax_document.fax_thumbnails.limit(i).each do |fax_thumbnail| + =image_tag fax_thumbnail.thumbnail_url(:medium), :class => 'FaxThumbnail', :alt => "Thumbnail of page \##{fax_thumbnail.position}" - if @fax_document.document.path - = link_to t("fax_documents.index.actions.download_pdf"), "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}.pdf" + %p + %a{:href => "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}.pdf"} + %i{:class => 'icon-download'} + = t("fax_documents.index.actions.download_pdf") = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } diff --git a/db/schema.rb b/db/schema.rb index fc2b635..0637146 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130212071000) do +ActiveRecord::Schema.define(:version => 20130213110000) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -701,6 +701,16 @@ ActiveRecord::Schema.define(:version => 20130212071000) do t.datetime "updated_at", :null => false end + create_table "parking_stalls", :force => true do |t| + t.string "name" + t.string "lot" + t.integer "parking_stallable_id" + t.string "parking_stallable_type" + t.string "comment" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "phone_book_entries", :force => true do |t| t.integer "phone_book_id" t.string "first_name" @@ -899,6 +909,7 @@ ActiveRecord::Schema.define(:version => 20130212071000) do t.integer "gs_node_original_id" t.string "uuid" t.boolean "is_native" + t.string "language_code" end add_index "sip_accounts", ["uuid"], :name => "index_sip_accounts_on_uuid" -- cgit v1.2.3 From 24e085ddcc30b8d6acec7dde8b165e105da5f004 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 14:14:57 +0100 Subject: Updated Rails to 3.2.12 --- Gemfile | 2 +- Gemfile.lock | 59 ++++++++++++++++++++++++++++++----------------------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Gemfile b/Gemfile index c90adb5..ca49e69 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.2.11' +gem 'rails', '3.2.12' gem 'bcrypt-ruby' gem 'sqlite3' gem 'mysql2' diff --git a/Gemfile.lock b/Gemfile.lock index 6f4888b..d8531cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,31 +10,31 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.11) - actionpack (= 3.2.11) + actionmailer (3.2.12) + actionpack (= 3.2.12) mail (~> 2.4.4) - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + actionpack (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) - rack (~> 1.4.0) + rack (~> 1.4.5) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.11) - activesupport (= 3.2.11) + activemodel (3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + activerecord (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - activesupport (3.2.11) + activeresource (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) + activesupport (3.2.12) i18n (~> 0.6) multi_json (~> 1.0) acts_as_list (0.1.9) @@ -75,7 +75,7 @@ GEM dalli (2.6.2) delayed_job (3.0.5) activesupport (~> 3.0) - delayed_job_active_record (0.4.0) + delayed_job_active_record (0.4.1) activerecord (>= 2.1.0, < 4) delayed_job (~> 3.0) erubis (2.7.0) @@ -88,7 +88,8 @@ GEM factory_girl (~> 4.2.0) railties (>= 3.0.0) fssm (0.2.10) - haml (3.1.7) + haml (4.0.0) + tilt hike (1.2.1) hirb (0.7.1) http_accept_language (1.0.2) @@ -109,7 +110,7 @@ GEM mime-types (1.21) mini_magick (3.4) subexec (~> 0.2.1) - multi_json (1.5.1) + multi_json (1.6.0) mysql2 (0.3.11) nokogiri (1.5.6) open4 (1.3.0) @@ -123,17 +124,17 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.11) - actionmailer (= 3.2.11) - actionpack (= 3.2.11) - activerecord (= 3.2.11) - activeresource (= 3.2.11) - activesupport (= 3.2.11) + rails (3.2.12) + actionmailer (= 3.2.12) + actionpack (= 3.2.12) + activerecord (= 3.2.12) + activeresource (= 3.2.12) + activesupport (= 3.2.12) bundler (~> 1.0) - railties (= 3.2.11) - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) + railties (= 3.2.12) + railties (3.2.12) + actionpack (= 3.2.12) + activesupport (= 3.2.12) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -217,7 +218,7 @@ DEPENDENCIES mysql2 nokogiri quiet_assets - rails (= 3.2.11) + rails (= 3.2.12) sass-rails sextant simple_form! -- cgit v1.2.3 From 3db09ff394b92b5d168c32c355d4529fd3861d36 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 15:29:43 +0100 Subject: Improvements in the fax_document model and in FaxDocument#show. --- app/models/fax_document.rb | 24 +++++---- app/uploaders/thumbnail_uploader.rb | 18 +++---- app/views/fax_documents/show.html.haml | 97 +++++++++++++++++++--------------- 3 files changed, 75 insertions(+), 64 deletions(-) diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index 16fdc70..4db4980 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -47,19 +47,21 @@ class FaxDocument < ActiveRecord::Base transition [:new] => :inbound end end + + def to_s + "#{self.remote_station_id}-#{self.created_at}-#{self.id}".gsub(/[^a-zA-Z0-9]/,'') + end def render_thumbnails - directory = "/tmp/GS-#{GsParameter.get('GEMEINSCHAFT_VERSION')}/fax_thumbnails/#{self.id}" - system('mkdir -p ' + directory) - system("cd #{directory} && convert #{Rails.root.to_s}/public#{self.document.to_s}[0-100] -colorspace Gray PNG:'fax_page.png'") - number_of_thumbnails = Dir["#{directory}/fax_page-*.png"].count - (0..(number_of_thumbnails-1)).each do |i| + tmp_dir = "/tmp/fax_convertions/#{self.id}" + FileUtils.mkdir_p tmp_dir + system("cd #{tmp_dir} && convert #{self.document.path} -colorspace Gray PNG:'fax_page.png'") + Dir.glob("#{tmp_dir}/fax_page*.png").each do |thumbnail| fax_thumbnail = self.fax_thumbnails.build - fax_thumbnail.thumbnail = File.open("#{directory}/fax_page-#{i}.png") - fax_thumbnail.save! + fax_thumbnail.thumbnail = File.open(thumbnail) + fax_thumbnail.save end - system("rm -rf #{directory}") - self.update_attributes(:document_total_pages => number_of_thumbnails) if self.document_total_pages.nil? + FileUtils.rm_rf tmp_dir end private @@ -67,12 +69,12 @@ class FaxDocument < ActiveRecord::Base page_size_a4 = '595 842' 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" directory = "/tmp/GS-#{GsParameter.get('GEMEINSCHAFT_VERSION')}/faxes/#{self.id}" - system('mkdir -p ' + directory) + FileUtils.mkdir_p directory tiff_file_name = File.basename(self.document.to_s.downcase, ".pdf") + '.tiff' system "cd #{directory} && gs -q -r#{self.fax_resolution.resolution_value} -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=\"#{tiff_file_name}\" -c \"#{page_size_command}\" -- \"#{Rails.root.to_s}/public#{self.document.to_s}\"" self.tiff = File.open("#{directory}/#{tiff_file_name}") self.save - system("rm -rf #{directory}") + FileUtils.rm_rf directory end end diff --git a/app/uploaders/thumbnail_uploader.rb b/app/uploaders/thumbnail_uploader.rb index a401a91..4b4cc09 100644 --- a/app/uploaders/thumbnail_uploader.rb +++ b/app/uploaders/thumbnail_uploader.rb @@ -34,17 +34,17 @@ class ThumbnailUploader < CarrierWave::Uploader::Base process :resize_to_limit => [75, 75] end - version :thumb do - process :resize_to_limit => [150, 150] - end + # version :thumb do + # process :resize_to_limit => [150, 150] + # end - version :medium do - process :resize_to_limit => [400, 400] - end + # version :medium do + # process :resize_to_limit => [400, 400] + # end - version :big do - process :resize_to_limit => [800, 800] - end + # version :big do + # process :resize_to_limit => [800, 800] + # end # Add a white list of extensions which are allowed to be uploaded. diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index de8c1cc..3419d5c 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -2,49 +2,58 @@ - child = @fax_document - parent = @fax_document.fax_account -%table.table.table-striped - %tr - %td - %strong= t('fax_documents.index.state') + ":" - %td - = t("fax_documents.states.#{@fax_document.state}") - %tr - %td - %strong= t('fax_documents.index.result_code') + ":" - %td - = @fax_document.result_code - %tr - %td - %strong= t('fax_documents.index.result_text') + ":" - %td - = t("fax_documents.result_codes.code_#{@fax_document.result_code}") - %tr - %td - %strong= t('fax_documents.show.document_transferred_pages') + ":" - %td - = @fax_document.document_transferred_pages - %tr - %td - %strong= t('fax_documents.show.remote_station_id') + ":" - %td - = @fax_document.remote_station_id - %tr - %td - %strong= t('fax_documents.show.fax_resolution') + ":" - %td - = @fax_document.fax_resolution +.row + .span12 + %table.table.table-striped + %tr + %td + %strong= t('fax_documents.index.state') + ":" + %td + = t("fax_documents.states.#{@fax_document.state}") + %tr + %td + %strong= t('fax_documents.index.result_code') + ":" + %td + = @fax_document.result_code + %tr + %td + %strong= t('fax_documents.index.result_text') + ":" + %td + = t("fax_documents.result_codes.code_#{@fax_document.result_code}") + %tr + %td + %strong= t('fax_documents.show.document_transferred_pages') + ":" + %td + = @fax_document.document_transferred_pages + %tr + %td + %strong= t('fax_documents.show.remote_station_id') + ":" + %td + = @fax_document.remote_station_id + %tr + %td + %strong= t('fax_documents.show.fax_resolution') + ":" + %td + = @fax_document.fax_resolution -- if @fax_document.fax_thumbnails.count > 0 - - i = @fax_document.fax_thumbnails.count - - i = 10 if i > 10 - %p - - @fax_document.fax_thumbnails.limit(i).each do |fax_thumbnail| - =image_tag fax_thumbnail.thumbnail_url(:medium), :class => 'FaxThumbnail', :alt => "Thumbnail of page \##{fax_thumbnail.position}" + - if @fax_document.document? + %p + %a{:href => @fax_document.document.url} + %i{:class => 'icon-download'} + = t("fax_documents.index.actions.download_pdf") + " (#{number_to_human_size(@fax_document.document.size, :precision => 2)})" -- if @fax_document.document.path - %p - %a{:href => "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}.pdf"} - %i{:class => 'icon-download'} - = t("fax_documents.index.actions.download_pdf") - -= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } +.row + .span12 + - if @fax_document.fax_thumbnails.any? + %ul.thumbnails + - @fax_document.fax_thumbnails.each do |fax_thumbnail| + %li.span4 + %div.thumbnail + %a.thumbnail{:href => fax_thumbnail.thumbnail.url} + =image_tag(fax_thumbnail.thumbnail.url, :alt => "Page #{fax_thumbnail.position}") + %p + = "#{fax_thumbnail.position}/#{@fax_document.fax_thumbnails.count}" + +.row + .span12 + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } -- cgit v1.2.3 From 12a6b6ec57d67da3d4969378a0d930042bcc97bd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 17:19:47 +0100 Subject: UI improvments for FaxDocument#index and FaxDocument#show --- app/views/fax_documents/_index_core.html.haml | 51 +++++++++++++++++++-------- app/views/fax_documents/show.html.haml | 16 ++++++--- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/app/views/fax_documents/_index_core.html.haml b/app/views/fax_documents/_index_core.html.haml index 8559f1c..5355521 100644 --- a/app/views/fax_documents/_index_core.html.haml +++ b/app/views/fax_documents/_index_core.html.haml @@ -2,25 +2,34 @@ %thead %tr %th= t('fax_documents.index.sent_at') - %th= t('fax_documents.index.state') - %th= t('fax_documents.index.result') %th = t('fax_documents.index.phone_number') %br = t('fax_documents.index.remote_station_id') %th= t('fax_documents.index.thumbnails') + %th + %th %tbody - for fax_document in fax_documents - %tr{:id => "fax_document_#{fax_document.id}"} - - if fax_document.sent_at - %td - = "#{fax_document.inbound ? '⇨' : '⇦'}".html_safe - = l fax_document.sent_at, :format => :short - %td= t("fax_documents.states.#{fax_document.state}") - %td= t("fax_documents.result_codes.code_#{fax_document.result_code}") + " (#{fax_document.result_code})" + - case fax_document.state + - when 'unsuccessful' + - current_status = 'error' + - when 'sending' + - current_status = 'success' + - when 'queued_for_sending' + - current_status = 'warning' - else - %td{ :colspan => 3 }= t("fax_documents.states.#{fax_document.state}") + - current_status = '' + + %tr{:class => current_status} + %td + - case fax_document.state + - when 'successful' + = "#{fax_document.inbound ? '⇨' : '⇦'}".html_safe + = l fax_document.sent_at, :format => :short + - else + = t("fax_documents.states.#{fax_document.state}") %td - if fax_document.inbound = "#{fax_document.caller_id_number} #{fax_document.caller_id_name}" @@ -28,9 +37,21 @@ = fax_document.destination_phone_number %br = fax_document.remote_station_id - %td - - fax_document.fax_thumbnails.limit(5).each do |fax_thumbnail| - =image_tag fax_thumbnail.thumbnail_url(:mini), :class => 'FaxThumbnail', :alt => "Thumbnail of page \##{fax_thumbnail.position}" - - if can?(:show, fax_document) && !fax_document.document.blank? && File.readable?(fax_document.document.path) - = link_to t('fax_documents.index.actions.download'), fax_account_fax_document_path(@fax_account, fax_document, :format => :pdf), :method => :get + %td + %ul.thumbnails + - fax_document.fax_thumbnails.limit(3).each do |fax_thumbnail| + %li.span1 + %div.thumbnail + %a.thumbnail{:href => fax_thumbnail.thumbnail.url} + =image_tag(fax_thumbnail.thumbnail.url, :alt => "Page #{fax_thumbnail.position}") + %p + %small + = "#{fax_thumbnail.position}/#{fax_document.fax_thumbnails.count}" + + - if fax_document.document? + %p + %a{:href => fax_document.document.url} + %i{:class => 'icon-download'} + = t("fax_documents.index.actions.download_pdf") + " (#{number_to_human_size(fax_document.document.size, :precision => 2)})" + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => fax_document.fax_account, :child => fax_document} diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index 3419d5c..9925c2f 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -1,11 +1,19 @@ - content_for :title, t("fax_documents.show.page_title") -- child = @fax_document -- parent = @fax_document.fax_account .row .span12 %table.table.table-striped - %tr + - case @fax_document.state + - when 'unsuccessful' + - current_status = 'error' + - when 'sending' + - current_status = 'success' + - when 'queued_for_sending' + - current_status = 'warning' + - else + - current_status = '' + + %tr{:class => current_status} %td %strong= t('fax_documents.index.state') + ":" %td @@ -46,7 +54,7 @@ .span12 - if @fax_document.fax_thumbnails.any? %ul.thumbnails - - @fax_document.fax_thumbnails.each do |fax_thumbnail| + - @fax_document.fax_thumbnails.limit(50).each do |fax_thumbnail| %li.span4 %div.thumbnail %a.thumbnail{:href => fax_thumbnail.thumbnail.url} -- cgit v1.2.3 From ed8e0ac76bddab0d74095313f36bd836d30dcb84 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 17:33:32 +0100 Subject: The convertion of PDFs to fax thumbnails now gets done by a delayed_job. --- app/models/fax_document.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index 4db4980..564d3bb 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -18,8 +18,8 @@ class FaxDocument < ActiveRecord::Base has_many :fax_thumbnails, :order => :position, :dependent => :destroy - after_create :render_thumbnails after_create :convert_pdf_to_tiff + after_create :render_thumbnails # Scopes scope :inbound, where(:state => 'inbound') @@ -51,8 +51,12 @@ class FaxDocument < ActiveRecord::Base def to_s "#{self.remote_station_id}-#{self.created_at}-#{self.id}".gsub(/[^a-zA-Z0-9]/,'') end - + def render_thumbnails + self.delay.create_thumbnails_and_save_them + end + + def create_thumbnails_and_save_them tmp_dir = "/tmp/fax_convertions/#{self.id}" FileUtils.mkdir_p tmp_dir system("cd #{tmp_dir} && convert #{self.document.path} -colorspace Gray PNG:'fax_page.png'") -- cgit v1.2.3 From 012d68aec79e14b331d5a76bb6a058ebf280cdf0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 18:00:53 +0100 Subject: nothing --- Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index ca49e69..9a2851a 100644 --- a/Gemfile +++ b/Gemfile @@ -48,8 +48,9 @@ group :test do gem 'factory_girl_rails' end -gem "haml" -gem "simple_form", github: 'plataformatec/simple_form', branch: 'v2.1' +gem 'haml' +gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1' + # Image Upload gem 'carrierwave' gem "mini_magick" -- cgit v1.2.3 From 0240e6dd67bc87bc36f6fcdc964bd8e55895b52d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 18:04:10 +0100 Subject: Downgraded simple_form because of #175 --- Gemfile | 3 ++- Gemfile.lock | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 9a2851a..aa66bda 100644 --- a/Gemfile +++ b/Gemfile @@ -49,7 +49,8 @@ group :test do end gem 'haml' -gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1' +gem 'simple_form', '~> 2.0.1' +# gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1' # Image Upload gem 'carrierwave' diff --git a/Gemfile.lock b/Gemfile.lock index d8531cd..769b1bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,3 @@ -GIT - remote: git://github.com/plataformatec/simple_form.git - revision: e3da7301dcf6feb9a1db275ff5cb3f85afce0e80 - branch: v2.1 - specs: - simple_form (2.1.0.dev) - actionpack (~> 3.0) - activemodel (~> 3.0) - GEM remote: http://rubygems.org/ specs: @@ -151,6 +142,9 @@ GEM sextant (0.2.3) activesupport (>= 3.2) rails (>= 3.2) + simple_form (2.0.4) + actionpack (~> 3.0) + activemodel (~> 3.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -221,7 +215,7 @@ DEPENDENCIES rails (= 3.2.12) sass-rails sextant - simple_form! + simple_form (~> 2.0.1) sqlite3 state_machine strong_parameters -- cgit v1.2.3 From a9bf3a7e1fd802025824668e477a5ec14ce81d5a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 18:09:15 +0100 Subject: Encoding.default_external = Encoding::UTF_8 --- Gemfile | 9 +++++++-- Gemfile.lock | 14 ++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index aa66bda..e4e839f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,8 @@ +if RUBY_VERSION =~ /1.9/ + Encoding.default_external = Encoding::UTF_8 + Encoding.default_internal = Encoding::UTF_8 +end + source 'http://rubygems.org' gem 'rails', '3.2.12' @@ -49,8 +54,8 @@ group :test do end gem 'haml' -gem 'simple_form', '~> 2.0.1' -# gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1' +# gem 'simple_form', '~> 2.0.1' +gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1' # Image Upload gem 'carrierwave' diff --git a/Gemfile.lock b/Gemfile.lock index 769b1bf..d8531cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,12 @@ +GIT + remote: git://github.com/plataformatec/simple_form.git + revision: e3da7301dcf6feb9a1db275ff5cb3f85afce0e80 + branch: v2.1 + specs: + simple_form (2.1.0.dev) + actionpack (~> 3.0) + activemodel (~> 3.0) + GEM remote: http://rubygems.org/ specs: @@ -142,9 +151,6 @@ GEM sextant (0.2.3) activesupport (>= 3.2) rails (>= 3.2) - simple_form (2.0.4) - actionpack (~> 3.0) - activemodel (~> 3.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -215,7 +221,7 @@ DEPENDENCIES rails (= 3.2.12) sass-rails sextant - simple_form (~> 2.0.1) + simple_form! sqlite3 state_machine strong_parameters -- cgit v1.2.3 From a1aafe9eec98f91fd76d104964ad98fcafc94a80 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 14 Feb 2013 10:42:26 +0100 Subject: language added --- app/views/sip_accounts/_form_core.html.haml | 1 + config/locales/views/sip_accounts/de.yml | 5 ++++- config/locales/views/sip_accounts/en.yml | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index 1b96d27..1a8876a 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -15,3 +15,4 @@ = 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(:phone_number_id => @sip_account.phone_number_ids).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/config/locales/views/sip_accounts/de.yml b/config/locales/views/sip_accounts/de.yml index 8fe2300..7a7e540 100644 --- a/config/locales/views/sip_accounts/de.yml +++ b/config/locales/views/sip_accounts/de.yml @@ -81,4 +81,7 @@ de: callforward_rules_act_per_sip_account: label: 'Rufweiterleitungen gelten für das gesamte SIP-Account' hint: '' - submit: 'Absenden' \ No newline at end of file + language_code: + label: 'Sprache' + hint: '' + submit: 'Absenden' diff --git a/config/locales/views/sip_accounts/en.yml b/config/locales/views/sip_accounts/en.yml index aa934e9..35d5456 100644 --- a/config/locales/views/sip_accounts/en.yml +++ b/config/locales/views/sip_accounts/en.yml @@ -81,4 +81,7 @@ en: hotdeskable: label: 'Hotdeskable' hint: '' - submit: 'Submit' \ No newline at end of file + language_code: + label: 'Language' + hint: '' + submit: 'Submit' -- cgit v1.2.3 From 124a421b19e08447fa790b65cc969dadd7408539 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 14 Feb 2013 14:46:35 +0100 Subject: fixed subscriptions on newer phone firmware versions --- app/controllers/config_snom_controller.rb | 8 ++++---- app/views/config_snom/show.xml.haml | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index d36f990..76fa633 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -292,8 +292,8 @@ class ConfigSnomController < ApplicationController :softkey => softkey, :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"), :subscription => { - :to => "park+#{parking_stall.name}@#{sip_account.host}", - :for => "#{sip_account.auth_name}@#{sip_account.host}" + :to => "sip:park+#{parking_stall.name}@#{sip_account.host}", + :for => "sip:park+#{parking_stall.name}@#{sip_account.host}", }, :actions => [{ :type => :dial, @@ -316,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/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index 1102ad1..3d0edf1 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -90,6 +90,23 @@ %backlight_idle{:perm => 'RW'}= '0' %dim_timer{:perm => 'RW'}= '300' + / LED + %led_on{:perm => 'RW'}= 'ON BUSY IN_A_CALL CALLING IN_A_MEETING URGENT_INTERRUPTIONS_ONLY HOLDING DND ACTIVE INACTIVE BE_RIGHT_BACK AWAY UNAVAILABLE AVAILABLE PhoneHasCall CurrentIdentityHasVoiceMessages PhoneHasVoiceMessages' + %led_blink_slow{:perm => 'RW'}= 'PARKED HOLDING_BOSSADMIN Wrap-Up' + %led_blink_medium{:perm => 'RW'}= '' + %led_blink_fast{:perm => 'RW'}= 'RINGING PhoneHasCallInStateRinging' + %led_blink_short_off{:perm => 'RW'}= 'PhoneHasMissedCalls' + %led_red{:perm => 'RW'}= 'BUSY IN_A_CALL CALLING IN_A_MEETING URGENT_INTERRUPTIONS_ONLY HOLDING DND' + %led_green{:perm => 'RW'}= 'Wrap-Up' + %led_orange{:perm => 'RW'}= 'AWAY INACTIVE BE_RIGHT_BACK INACTIVE' + %led_blue{:perm => 'RW'}= '' + %led_red_green{:perm => 'RW'}= '' + %led_red_orange{:perm => 'RW'}= '' + %led_green_orange{:perm => 'RW'}= '' + %led_call_indicator_usage{:perm => 'RW'}= 'PhoneHasCallInStateRinging PhoneHasCall PhoneHasMissedCalls' + %led_message_usage{:perm => 'RW'}= 'CurrentIdentityHasVoiceMessages PhoneHasVoiceMessages' + + - if @phone.phone_model.name == 'Snom 870' / Snom 870 idle icons %idle_icon_01{:perm => 'RW'}= '9' @@ -165,9 +182,9 @@ - if softkey[:subscription] %subscription{:type => 'dialog', :to => softkey[:subscription][:to], :for => softkey[:subscription][:for]} %NotifyParsingRules{:type => 'applies'} - %level1{:translates_to => 'OK'}= "/dialog-info[@entity=\"sip:#{softkey[:subscription][:to]}\"]" + %level1{:translates_to => 'OK'}= "/dialog-info[@entity=\"#{softkey[:subscription][:to]}\"]" %NotifyParsingRules{:type => 'state'} - %level1{:translates_to => 'available'}= '/dialog-info/dialog/state[.="terminated"]' + %level1{:translates_to => 'unknown'}= '/dialog-info/dialog/state[.="terminated"]' %level2{:translates_to => 'ringing'}= '/dialog-info/dialog/state[.="early"]' %level3{:translates_to => 'active'}= '/dialog-info/dialog/state[.="confirmed"]' %level4{:fetch_content => 'true'}= '/dialog-info/dialog/state' -- cgit v1.2.3 From 3d11d0a3a047a12bfd40b61252e269cabac76225 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 15 Feb 2013 14:49:16 +0100 Subject: Basic structure for sim_cards and sim_card_providers. --- app/controllers/sim_card_providers_controller.rb | 47 +++++++++++++ app/controllers/sim_cards_controller.rb | 57 +++++++++++++++ app/helpers/sim_card_providers_helper.rb | 2 + app/helpers/sim_cards_helper.rb | 2 + app/models/ability.rb | 4 ++ app/models/sim_card.rb | 25 +++++++ app/models/sim_card_provider.rb | 28 ++++++++ app/views/sim_card_providers/_form.html.haml | 7 ++ app/views/sim_card_providers/_form_core.html.haml | 9 +++ app/views/sim_card_providers/_index_core.html.haml | 21 ++++++ app/views/sim_card_providers/edit.html.haml | 3 + app/views/sim_card_providers/index.html.haml | 6 ++ app/views/sim_card_providers/new.html.haml | 3 + app/views/sim_card_providers/show.html.haml | 72 +++++++++++++++++++ app/views/sim_cards/_form.html.haml | 7 ++ app/views/sim_cards/_form_core.html.haml | 3 + app/views/sim_cards/_index_core.html.haml | 16 +++++ app/views/sim_cards/edit.html.haml | 3 + app/views/sim_cards/index.html.haml | 6 ++ app/views/sim_cards/new.html.haml | 3 + app/views/sim_cards/show.html.haml | 32 +++++++++ app/views/tenants/_admin_area.de.html.haml | 3 + app/views/tenants/_admin_area.en.html.haml | 3 + .../tenants/_table_of_sim_card_providers.html.haml | 7 ++ app/views/users/show.html.haml | 3 + config/locales/views/sim_card_providers/de.yml | 80 ++++++++++++++++++++++ config/locales/views/sim_card_providers/en.yml | 80 ++++++++++++++++++++++ config/locales/views/sim_cards/de.yml | 70 +++++++++++++++++++ config/locales/views/sim_cards/en.yml | 70 +++++++++++++++++++ config/routes.rb | 4 ++ .../20130215111526_create_sim_card_providers.rb | 20 ++++++ db/migrate/20130215112028_create_sim_cards.rb | 18 +++++ .../20130215133749_add_sim_card_gs_parameter.rb | 9 +++ db/schema.rb | 28 +++++++- .../sim_card_providers_controller_test.rb | 49 +++++++++++++ test/functional/sim_cards_controller_test.rb | 49 +++++++++++++ test/unit/sim_card_provider_test.rb | 7 ++ test/unit/sim_card_test.rb | 7 ++ 38 files changed, 862 insertions(+), 1 deletion(-) create mode 100644 app/controllers/sim_card_providers_controller.rb create mode 100644 app/controllers/sim_cards_controller.rb create mode 100644 app/helpers/sim_card_providers_helper.rb create mode 100644 app/helpers/sim_cards_helper.rb create mode 100644 app/models/sim_card.rb create mode 100644 app/models/sim_card_provider.rb create mode 100644 app/views/sim_card_providers/_form.html.haml create mode 100644 app/views/sim_card_providers/_form_core.html.haml create mode 100644 app/views/sim_card_providers/_index_core.html.haml create mode 100644 app/views/sim_card_providers/edit.html.haml create mode 100644 app/views/sim_card_providers/index.html.haml create mode 100644 app/views/sim_card_providers/new.html.haml create mode 100644 app/views/sim_card_providers/show.html.haml create mode 100644 app/views/sim_cards/_form.html.haml create mode 100644 app/views/sim_cards/_form_core.html.haml create mode 100644 app/views/sim_cards/_index_core.html.haml create mode 100644 app/views/sim_cards/edit.html.haml create mode 100644 app/views/sim_cards/index.html.haml create mode 100644 app/views/sim_cards/new.html.haml create mode 100644 app/views/sim_cards/show.html.haml create mode 100644 app/views/tenants/_table_of_sim_card_providers.html.haml create mode 100644 config/locales/views/sim_card_providers/de.yml create mode 100644 config/locales/views/sim_card_providers/en.yml create mode 100644 config/locales/views/sim_cards/de.yml create mode 100644 config/locales/views/sim_cards/en.yml create mode 100644 db/migrate/20130215111526_create_sim_card_providers.rb create mode 100644 db/migrate/20130215112028_create_sim_cards.rb create mode 100644 db/migrate/20130215133749_add_sim_card_gs_parameter.rb create mode 100644 test/functional/sim_card_providers_controller_test.rb create mode 100644 test/functional/sim_cards_controller_test.rb create mode 100644 test/unit/sim_card_provider_test.rb create mode 100644 test/unit/sim_card_test.rb 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 diff --git a/app/helpers/sim_card_providers_helper.rb b/app/helpers/sim_card_providers_helper.rb new file mode 100644 index 0000000..306f589 --- /dev/null +++ b/app/helpers/sim_card_providers_helper.rb @@ -0,0 +1,2 @@ +module SimCardProvidersHelper +end diff --git a/app/helpers/sim_cards_helper.rb b/app/helpers/sim_cards_helper.rb new file mode 100644 index 0000000..c0df165 --- /dev/null +++ b/app/helpers/sim_cards_helper.rb @@ -0,0 +1,2 @@ +module SimCardsHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 4c0844c..d66577d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -86,6 +86,10 @@ class Ability # An admin can not destroy his/her account # cannot [:destroy], User, :id => user.id + + # SIM cards + # + cannot [:edit, :update], SimCard else # Any user can do the following stuff. # diff --git a/app/models/sim_card.rb b/app/models/sim_card.rb new file mode 100644 index 0000000..2cbf76b --- /dev/null +++ b/app/models/sim_card.rb @@ -0,0 +1,25 @@ +class SimCard < ActiveRecord::Base + attr_accessible :auto_order_card, :sip_account_id, :auth_key, :sim_number + + # Validations + # + validates :sim_card_provider_id, + :presence => true + + belongs_to :sim_card_provider, :touch => true + + validates :sim_card_provider, + :presence => true + + validates :sip_account_id, + :presence => true + + belongs_to :sip_account + + validates :sip_account, + :presence => true + + validates :sim_number, + :presence => true + +end diff --git a/app/models/sim_card_provider.rb b/app/models/sim_card_provider.rb new file mode 100644 index 0000000..854c61a --- /dev/null +++ b/app/models/sim_card_provider.rb @@ -0,0 +1,28 @@ +class SimCardProvider < ActiveRecord::Base + attr_accessible :name, :homepage_url, :docu_url, :api_server_url, :api_username, :api_password, :ref, :sip_server, :include_order_card_function + + # Validations + # + validates :name, + :presence => true, + :uniqueness => true + + validates :api_username, + :presence => true + + validates :api_password, + :presence => true + + validates :api_server_url, + :presence => true + + validates :sip_server, + :presence => true + + has_many :sim_cards, :dependent => :destroy + + def to_s + name.to_s + end + +end diff --git a/app/views/sim_card_providers/_form.html.haml b/app/views/sim_card_providers/_form.html.haml new file mode 100644 index 0000000..73953e0 --- /dev/null +++ b/app/views/sim_card_providers/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@sim_card_provider) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('sim_card_providers.form.submit') diff --git a/app/views/sim_card_providers/_form_core.html.haml b/app/views/sim_card_providers/_form_core.html.haml new file mode 100644 index 0000000..fc36579 --- /dev/null +++ b/app/views/sim_card_providers/_form_core.html.haml @@ -0,0 +1,9 @@ +.inputs + = f.input :name, :label => t('sim_card_providers.form.name.label'), :hint => conditional_hint('sim_card_providers.form.name.hint') + = f.input :homepage_url, :label => t('sim_card_providers.form.homepage_url.label'), :hint => conditional_hint('sim_card_providers.form.homepage_url.hint') + = f.input :docu_url, :label => t('sim_card_providers.form.docu_url.label'), :hint => conditional_hint('sim_card_providers.form.docu_url.hint') + = f.input :api_server_url, :label => t('sim_card_providers.form.api_server_url.label'), :hint => conditional_hint('sim_card_providers.form.api_server_url.hint') + = f.input :api_username, :label => t('sim_card_providers.form.api_username.label'), :hint => conditional_hint('sim_card_providers.form.api_username.hint') + = f.input :api_password, :label => t('sim_card_providers.form.api_password.label'), :hint => conditional_hint('sim_card_providers.form.api_password.hint') + = f.input :sip_server, :label => t('sim_card_providers.form.sip_server.label'), :hint => conditional_hint('sim_card_providers.form.sip_server.hint') + = f.input :include_order_card_function, :label => t('sim_card_providers.form.include_order_card_function.label'), :hint => conditional_hint('sim_card_providers.form.include_order_card_function.hint') diff --git a/app/views/sim_card_providers/_index_core.html.haml b/app/views/sim_card_providers/_index_core.html.haml new file mode 100644 index 0000000..6a24695 --- /dev/null +++ b/app/views/sim_card_providers/_index_core.html.haml @@ -0,0 +1,21 @@ +%table.table.table-striped + %tr + %th= t('sim_card_providers.index.name') + %th= t('sim_card_providers.index.api_server_url') + %th= t('sim_card_providers.index.api_username') + %th= t('sim_card_providers.index.api_password') + %th= t('sim_card_providers.index.sip_server') + %th + + - for sim_card_provider in sim_card_providers + %tr + %td + - if sim_card_provider.homepage_url.blank? + = sim_card_provider.name + - else + = link_to sim_card_provider.name, sim_card_provider.homepage_url + %td= sim_card_provider.api_server_url + %td= sim_card_provider.api_username + %td= sim_card_provider.api_password + %td= sim_card_provider.sip_server + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => sim_card_provider} \ No newline at end of file diff --git a/app/views/sim_card_providers/edit.html.haml b/app/views/sim_card_providers/edit.html.haml new file mode 100644 index 0000000..49b1f93 --- /dev/null +++ b/app/views/sim_card_providers/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("sim_card_providers.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/sim_card_providers/index.html.haml b/app/views/sim_card_providers/index.html.haml new file mode 100644 index 0000000..2264e53 --- /dev/null +++ b/app/views/sim_card_providers/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("sim_card_providers.index.page_title") + +- if @sim_card_providers && @sim_card_providers.count > 0 + = render "index_core", :sim_card_providers => @sim_card_providers + += render :partial => 'shared/create_link', :locals => {:child_class => SimCardProvider} \ No newline at end of file diff --git a/app/views/sim_card_providers/new.html.haml b/app/views/sim_card_providers/new.html.haml new file mode 100644 index 0000000..04c0445 --- /dev/null +++ b/app/views/sim_card_providers/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("sim_card_providers.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/sim_card_providers/show.html.haml b/app/views/sim_card_providers/show.html.haml new file mode 100644 index 0000000..37635d9 --- /dev/null +++ b/app/views/sim_card_providers/show.html.haml @@ -0,0 +1,72 @@ +- content_for :title, t("sim_card_providers.show.page_title") + +.row + .span6 + %table.table.table-striped + %tr + %td + %strong= t('sim_card_providers.show.name') + ":" + %td + = @sim_card_provider.name + %tr + %td + %strong= t('sim_card_providers.show.homepage_url') + ":" + %td + = @sim_card_provider.homepage_url + %tr + %td + %strong= t('sim_card_providers.show.docu_url') + ":" + %td + = @sim_card_provider.docu_url + %tr + %td + %strong= t('sim_card_providers.show.api_server_url') + ":" + %td + = @sim_card_provider.api_server_url + %tr + %td + %strong= t('sim_card_providers.show.api_username') + ":" + %td + = @sim_card_provider.api_username + %tr + %td + %strong= t('sim_card_providers.show.api_password') + ":" + %td + = @sim_card_provider.api_password + %tr + %td + %strong= t('sim_card_providers.show.ref') + ":" + %td + = @sim_card_provider.ref + %tr + %td + %strong= t('sim_card_providers.show.sip_server') + ":" + %td + = @sim_card_provider.sip_server + %tr + %td + %strong= t('sim_card_providers.show.include_order_card_function') + ":" + %td + = @sim_card_provider.include_order_card_function + + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @sim_card_provider } + +.row + .span12 + %h2= t("sim_cards.index.page_title") + + %table.table.table-striped + %tr + %th= t('sim_cards.index.sip_account_id') + %th= t('sim_cards.index.auth_key') + %th= t('sim_cards.index.state') + %th + + - for sim_card in @sim_card_provider.sim_cards + %tr + %td= sim_card.sip_account + %td= sim_card.auth_key + %td= sim_card.state + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @sim_card_provider, :child => sim_card} + + = render :partial => 'shared/create_link', :locals => {:parent => @sim_card_provider, :child_class => SimCard} \ No newline at end of file diff --git a/app/views/sim_cards/_form.html.haml b/app/views/sim_cards/_form.html.haml new file mode 100644 index 0000000..7d3cfbe --- /dev/null +++ b/app/views/sim_cards/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@sim_card_provider, @sim_card]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('sim_cards.form.submit') diff --git a/app/views/sim_cards/_form_core.html.haml b/app/views/sim_cards/_form_core.html.haml new file mode 100644 index 0000000..7cba4e9 --- /dev/null +++ b/app/views/sim_cards/_form_core.html.haml @@ -0,0 +1,3 @@ +.inputs + = f.input :sim_number, :label => t('sim_cards.form.sim_number.label'), :hint => conditional_hint('sim_cards.form.sim_number.hint') + = f.association :sip_account, :collection => @available_sip_accounts, :label => t('phone_sip_accounts.form.sip_account_id.label'), :hint => conditional_hint('phone_sip_accounts.form.sip_account_id.hint'), :include_blank => false \ No newline at end of file diff --git a/app/views/sim_cards/_index_core.html.haml b/app/views/sim_cards/_index_core.html.haml new file mode 100644 index 0000000..c36b22b --- /dev/null +++ b/app/views/sim_cards/_index_core.html.haml @@ -0,0 +1,16 @@ +%table.table.table-striped + %tr + %th= t('sim_cards.index.sip_account_id') + %th= t('sip_accounts.index.phone_numbers') + %th= t('sim_cards.index.auth_key') + %th= t('sim_cards.index.state') + %th + + - for sim_card in sim_cards + %tr + %td= sim_card.sip_account + %td + = render 'phone_numbers/listing', :phone_numbers => sim_card.sip_account.phone_numbers.order(:number) + %td= sim_card.auth_key + %td= sim_card.state + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @parent, :child => sim_card} \ No newline at end of file diff --git a/app/views/sim_cards/edit.html.haml b/app/views/sim_cards/edit.html.haml new file mode 100644 index 0000000..97ee10e --- /dev/null +++ b/app/views/sim_cards/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("sim_cards.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/sim_cards/index.html.haml b/app/views/sim_cards/index.html.haml new file mode 100644 index 0000000..803bd72 --- /dev/null +++ b/app/views/sim_cards/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("sim_cards.index.page_title") + +- if @sim_cards && @sim_cards.count > 0 + = render "index_core", :sim_cards => @sim_cards + += render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => SimCard} \ No newline at end of file diff --git a/app/views/sim_cards/new.html.haml b/app/views/sim_cards/new.html.haml new file mode 100644 index 0000000..1eef168 --- /dev/null +++ b/app/views/sim_cards/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("sim_cards.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/sim_cards/show.html.haml b/app/views/sim_cards/show.html.haml new file mode 100644 index 0000000..88822f1 --- /dev/null +++ b/app/views/sim_cards/show.html.haml @@ -0,0 +1,32 @@ +- content_for :title, t("sim_cards.show.page_title") + +.row + .span6 + %table.table.table-striped + %tr + %td + %strong= t('sim_cards.show.sip_account_id') + ":" + %td + = @sim_card.sip_account + %tr + %td + %strong= t('sip_accounts.index.phone_numbers') + %td + = render 'phone_numbers/listing', :phone_numbers => @sim_card.sip_account.phone_numbers.order(:number) + %tr + %td + %strong= t('sim_cards.show.auth_key') + ":" + %td + = @sim_card.auth_key + %tr + %td + %strong= t('sim_cards.show.state') + ":" + %td + = @sim_card.state + %tr + %td + %strong= t('sim_cards.show.log') + ":" + %td + = @sim_card.log + += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @parent, :child => @sim_card } \ No newline at end of file diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 2aed4e1..8acc95d 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -35,6 +35,9 @@ = succeed '.' do =link_to link_to Haml::Engine.new("%i.icon-list").render + ' ' + manufacturer, manufacturer_path(manufacturer) + - if GsParameter.get('SIM_CARDS') == true + = render :partial => 'tenants/table_of_sim_card_providers' + = render :partial => 'call_routes', :locals => {:tenant => tenant} = render :partial => 'gateways', :locals => {:tenant => tenant, :gateways => gateways} diff --git a/app/views/tenants/_admin_area.en.html.haml b/app/views/tenants/_admin_area.en.html.haml index 8e7bfea..c40e3ca 100644 --- a/app/views/tenants/_admin_area.en.html.haml +++ b/app/views/tenants/_admin_area.en.html.haml @@ -35,6 +35,9 @@ = succeed '.' do =link_to link_to Haml::Engine.new("%i.icon-list").render + ' ' + manufacturer, manufacturer_path(manufacturer) + - if GsParameter.get('SIM_CARDS') == true + = render :partial => 'tenants/table_of_sim_card_providers' + = render :partial => 'call_routes', :locals => {:tenant => tenant} = render :partial => 'gateways', :locals => {:tenant => tenant, :gateways => gateways} diff --git a/app/views/tenants/_table_of_sim_card_providers.html.haml b/app/views/tenants/_table_of_sim_card_providers.html.haml new file mode 100644 index 0000000..135bb65 --- /dev/null +++ b/app/views/tenants/_table_of_sim_card_providers.html.haml @@ -0,0 +1,7 @@ +- cache(['tenant_show_table_of_sim_card_providers', I18n.locale, SimCardProvider.count, SimCardProvider.reorder(:updated_at).last]) do + -# SIM card providers + -# + %h2= t('sim_card_providers.index.page_title') + - if SimCardProvider.any? + = render "sim_card_providers/index_core", :sim_card_providers => SimCardProvider.all + = render :partial => 'shared/create_link', :locals => {:child_class => SimCardProvider} diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c63c791..ba38547 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -67,6 +67,9 @@ - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do = render :partial => 'phones', :locals => {:user => @user} + / - cache(['user_show_sim_cards_overview', I18n.locale, @user, @user.phones]) do + / = render :partial => 'phones', :locals => {:user => @user} + - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do = render :partial => 'fax_accounts', :locals => {:user => @user} diff --git a/config/locales/views/sim_card_providers/de.yml b/config/locales/views/sim_card_providers/de.yml new file mode 100644 index 0000000..7cb19a5 --- /dev/null +++ b/config/locales/views/sim_card_providers/de.yml @@ -0,0 +1,80 @@ +de: + sim_card_providers: + name: 'SIM Karten Provider' + controller: + successfuly_created: 'SIM Karten Provider wurde angelegt.' + successfuly_updated: 'SIM Karten Provider wurde aktualisiert.' + successfuly_destroyed: 'SIM Karten Provider wurde gelöscht.' + index: + page_title: 'Liste SIM Karten Provider' + name: 'Name' + homepage_url: 'Homepage URL' + docu_url: 'Docu URL' + api_server_url: 'API server URL' + api_username: 'API username' + api_password: 'API password' + ref: 'Ref' + sip_server: 'SIP-Server' + include_order_card_function: 'Include order card function' + actions: + confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: SIM Karten Provider' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'SIM Karten Provider neu anlegen für %{resource}' + show: + page_title: 'SIM Karten Provider bearbeiten' + name: 'Name' + homepage_url: 'Homepage URL' + docu_url: 'Docu URL' + api_server_url: 'API server URL' + api_username: 'API username' + api_password: 'API password' + ref: 'Ref' + sip_server: 'SIP-Server' + include_order_card_function: 'Include order card function' + actions: + confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'SIM Karten Provider neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'SIM Karten Provider bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + name: + label: 'Name' + hint: '' + homepage_url: + label: 'Homepage URL' + hint: '' + docu_url: + label: 'Docu URL' + hint: '' + api_server_url: + label: 'API server URL' + hint: '' + api_username: + label: 'API username' + hint: '' + api_password: + label: 'API password' + hint: '' + ref: + label: 'Ref' + hint: '' + sip_server: + label: 'SIP-Server' + hint: '' + include_order_card_function: + label: 'Include order card function' + hint: '' + submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/sim_card_providers/en.yml b/config/locales/views/sim_card_providers/en.yml new file mode 100644 index 0000000..8b3843c --- /dev/null +++ b/config/locales/views/sim_card_providers/en.yml @@ -0,0 +1,80 @@ +en: + sim_card_providers: + name: 'Simcardprovider' + controller: + successfuly_created: 'Successfully created Simcardprovider.' + successfuly_updated: 'Successfully updated Simcardprovider.' + successfuly_destroyed: 'Successfully destroyed Simcardprovider.' + index: + page_title: 'Listing Simcardprovider' + name: 'Name' + homepage_url: 'Homepage url' + docu_url: 'Docu url' + api_server_url: 'Api server url' + api_username: 'Api username' + api_password: 'Api password' + ref: 'Ref' + sip_server: 'Sip server' + include_order_card_function: 'Include order card function' + actions: + confirm_destroy: 'Are you sure you want to delete this Simcardprovider?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Simcardprovider for %{resource}' + show: + page_title: 'Show Simcardprovider' + name: 'Name' + homepage_url: 'Homepage url' + docu_url: 'Docu url' + api_server_url: 'Api server url' + api_username: 'Api username' + api_password: 'Api password' + ref: 'Ref' + sip_server: 'Sip server' + include_order_card_function: 'Include order card function' + actions: + confirm_destroy: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Simcardprovider' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Simcardprovider' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + name: + label: 'Name' + hint: '' + homepage_url: + label: 'Homepage url' + hint: '' + docu_url: + label: 'Docu url' + hint: '' + api_server_url: + label: 'Api server url' + hint: '' + api_username: + label: 'Api username' + hint: '' + api_password: + label: 'Api password' + hint: '' + ref: + label: 'Ref' + hint: '' + sip_server: + label: 'Sip server' + hint: '' + include_order_card_function: + label: 'Include order card function' + hint: '' + submit: 'Submit' \ No newline at end of file diff --git a/config/locales/views/sim_cards/de.yml b/config/locales/views/sim_cards/de.yml new file mode 100644 index 0000000..4c2a5e4 --- /dev/null +++ b/config/locales/views/sim_cards/de.yml @@ -0,0 +1,70 @@ +de: + sim_cards: + name: 'SIM-Karte' + controller: + successfuly_created: 'SIM-Karte wurde angelegt.' + successfuly_updated: 'SIM-Karte wurde aktualisiert.' + successfuly_destroyed: 'SIM-Karte wurde gelöscht.' + no_existing_sip_accounts_warning: 'Es existiert kein freier SIP-Account zum Anlegen einer neuen SIM-Karte.' + index: + page_title: 'Liste SIM-Karten' + sim_card_provider_id: 'SIM-Karten Provider' + auto_order_card: 'Auto order card' + sip_account_id: 'SIP-Account' + auth_key: 'Auth key' + state: 'Status' + log: 'Log' + actions: + confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: SIM-Karte' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'SIM-Karte neu anlegen für %{resource}' + show: + page_title: 'SIM-Karte bearbeiten' + sim_card_provider_id: 'SIM-Karten Provider' + auto_order_card: 'Auto order card' + sip_account_id: 'SIP-Account' + auth_key: 'Auth key' + state: 'Status' + log: 'Log' + sim_number: 'SIM-No.' + actions: + confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'SIM-Karte neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'SIM-Karte bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + sim_card_provider_id: + label: 'SIM-Karten Provider' + hint: '' + sim_number: + label: 'SIM-Nr.' + hint: '' + auto_order_card: + label: 'Auto order card' + hint: '' + sip_account_id: + label: 'SIP-Account' + hint: '' + auth_key: + label: 'Auth key' + hint: '' + state: + label: 'Status' + hint: '' + log: + label: 'Log' + hint: '' + submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/sim_cards/en.yml b/config/locales/views/sim_cards/en.yml new file mode 100644 index 0000000..af82295 --- /dev/null +++ b/config/locales/views/sim_cards/en.yml @@ -0,0 +1,70 @@ +en: + sim_cards: + name: 'SIM card' + controller: + successfuly_created: 'Successfully created SIM card.' + successfuly_updated: 'Successfully updated SIM card.' + successfuly_destroyed: 'Successfully destroyed SIM card.' + no_existing_sip_accounts_warning: 'There is no available SIP account to create a new SIM card.' + index: + page_title: 'Listing SIM cards' + sim_card_provider_id: 'SIM card provider' + auto_order_card: 'Auto order card' + sip_account_id: 'Sip account' + auth_key: 'Auth key' + state: 'State' + log: 'Log' + actions: + confirm_destroy: 'Are you sure you want to delete this SIM card?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New SIM card for %{resource}' + show: + page_title: 'Show SIM card' + sim_card_provider_id: 'SIM card provider' + auto_order_card: 'Auto order card' + sip_account_id: 'Sip account' + auth_key: 'Auth key' + state: 'State' + log: 'Log' + sim_number: 'SIM-No.' + actions: + confirm_destroy: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New SIM card' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing SIM card' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + sim_card_provider_id: + label: 'SIM card provider' + hint: '' + sim_number: + label: 'SIM-Nr.' + hint: '' + auto_order_card: + label: 'Auto order card' + hint: '' + sip_account_id: + label: 'Sip account' + hint: '' + auth_key: + label: 'Auth key' + hint: '' + state: + label: 'State' + hint: '' + log: + label: 'Log' + hint: '' + submit: 'Submit' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index db6c30f..65a9ac2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Gemeinschaft42c::Application.routes.draw do + resources :sim_card_providers do + resources :sim_cards, :except => [:edit, :update] + end + resources :intruders resources :backup_jobs, :except => [:edit, :update] diff --git a/db/migrate/20130215111526_create_sim_card_providers.rb b/db/migrate/20130215111526_create_sim_card_providers.rb new file mode 100644 index 0000000..b4e0f0e --- /dev/null +++ b/db/migrate/20130215111526_create_sim_card_providers.rb @@ -0,0 +1,20 @@ +class CreateSimCardProviders < ActiveRecord::Migration + def self.up + create_table :sim_card_providers do |t| + t.string :name + t.string :homepage_url + t.string :docu_url + t.string :api_server_url + t.string :api_username + t.string :api_password + t.string :ref + t.string :sip_server + t.boolean :include_order_card_function + t.timestamps + end + end + + def self.down + drop_table :sim_card_providers + end +end diff --git a/db/migrate/20130215112028_create_sim_cards.rb b/db/migrate/20130215112028_create_sim_cards.rb new file mode 100644 index 0000000..8962a1f --- /dev/null +++ b/db/migrate/20130215112028_create_sim_cards.rb @@ -0,0 +1,18 @@ +class CreateSimCards < ActiveRecord::Migration + def self.up + create_table :sim_cards do |t| + t.integer :sim_card_provider_id + t.string :sim_number + t.boolean :auto_order_card + t.integer :sip_account_id + t.string :auth_key + t.string :state + t.text :log + t.timestamps + end + end + + def self.down + drop_table :sim_cards + end +end diff --git a/db/migrate/20130215133749_add_sim_card_gs_parameter.rb b/db/migrate/20130215133749_add_sim_card_gs_parameter.rb new file mode 100644 index 0000000..9b0bbba --- /dev/null +++ b/db/migrate/20130215133749_add_sim_card_gs_parameter.rb @@ -0,0 +1,9 @@ +class AddSimCardGsParameter < ActiveRecord::Migration + def up + GsParameter.create(:name => 'SIM_CARDS', :section => 'System defaults', :value => 'false', :class_type => 'Boolean', :description => 'Should it be possible to use SIM cards as SIP account users.') + end + + def down + GsParameter.where(:name => 'SIM_CARDS').destroy_all + end +end diff --git a/db/schema.rb b/db/schema.rb index 0637146..df55604 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130213110000) do +ActiveRecord::Schema.define(:version => 20130215133749) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -886,6 +886,32 @@ ActiveRecord::Schema.define(:version => 20130213110000) do add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" + create_table "sim_card_providers", :force => true do |t| + t.string "name" + t.string "homepage_url" + t.string "docu_url" + t.string "api_server_url" + t.string "api_username" + t.string "api_password" + t.string "ref" + t.string "sip_server" + t.boolean "include_order_card_function" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "sim_cards", :force => true do |t| + t.integer "sim_card_provider_id" + t.string "sim_number" + t.boolean "auto_order_card" + t.integer "sip_account_id" + t.string "auth_key" + t.string "state" + t.text "log" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "sip_accounts", :force => true do |t| t.string "sip_accountable_type" t.integer "sip_accountable_id" diff --git a/test/functional/sim_card_providers_controller_test.rb b/test/functional/sim_card_providers_controller_test.rb new file mode 100644 index 0000000..2dd9f3c --- /dev/null +++ b/test/functional/sim_card_providers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SimCardProvidersControllerTest < ActionController::TestCase + setup do + @sim_card_provider = sim_card_providers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sim_card_providers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create sim_card_provider" do + assert_difference('SimCardProvider.count') do + post :create, sim_card_provider: @sim_card_provider.attributes + end + + assert_redirected_to sim_card_provider_path(assigns(:sim_card_provider)) + end + + test "should show sim_card_provider" do + get :show, id: @sim_card_provider.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @sim_card_provider.to_param + assert_response :success + end + + test "should update sim_card_provider" do + put :update, id: @sim_card_provider.to_param, sim_card_provider: @sim_card_provider.attributes + assert_redirected_to sim_card_provider_path(assigns(:sim_card_provider)) + end + + test "should destroy sim_card_provider" do + assert_difference('SimCardProvider.count', -1) do + delete :destroy, id: @sim_card_provider.to_param + end + + assert_redirected_to sim_card_providers_path + end +end diff --git a/test/functional/sim_cards_controller_test.rb b/test/functional/sim_cards_controller_test.rb new file mode 100644 index 0000000..72436c9 --- /dev/null +++ b/test/functional/sim_cards_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SimCardsControllerTest < ActionController::TestCase + setup do + @sim_card = sim_cards(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sim_cards) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create sim_card" do + assert_difference('SimCard.count') do + post :create, sim_card: @sim_card.attributes + end + + assert_redirected_to sim_card_path(assigns(:sim_card)) + end + + test "should show sim_card" do + get :show, id: @sim_card.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @sim_card.to_param + assert_response :success + end + + test "should update sim_card" do + put :update, id: @sim_card.to_param, sim_card: @sim_card.attributes + assert_redirected_to sim_card_path(assigns(:sim_card)) + end + + test "should destroy sim_card" do + assert_difference('SimCard.count', -1) do + delete :destroy, id: @sim_card.to_param + end + + assert_redirected_to sim_cards_path + end +end diff --git a/test/unit/sim_card_provider_test.rb b/test/unit/sim_card_provider_test.rb new file mode 100644 index 0000000..c9ef142 --- /dev/null +++ b/test/unit/sim_card_provider_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SimCardProviderTest < ActiveSupport::TestCase + def test_should_be_valid + assert SimCardProvider.new.valid? + end +end diff --git a/test/unit/sim_card_test.rb b/test/unit/sim_card_test.rb new file mode 100644 index 0000000..2f9ba16 --- /dev/null +++ b/test/unit/sim_card_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SimCardTest < ActiveSupport::TestCase + def test_should_be_valid + assert SimCard.new.valid? + end +end -- cgit v1.2.3 From 14e8e9923666991703f747a4abfd6fbfb96d2dc1 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 15 Feb 2013 15:03:37 +0100 Subject: Show sim_cards of a user. Misc. --- app/models/sim_card.rb | 11 +++++++++++ app/models/user.rb | 4 ++++ app/views/sim_cards/_form_core.html.haml | 2 +- app/views/sim_cards/_index_core.html.haml | 2 +- app/views/users/show.html.haml | 6 ++++-- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/models/sim_card.rb b/app/models/sim_card.rb index 2cbf76b..806beab 100644 --- a/app/models/sim_card.rb +++ b/app/models/sim_card.rb @@ -22,4 +22,15 @@ class SimCard < ActiveRecord::Base validates :sim_number, :presence => true + after_initialize :set_defaults + + def to_s + self.sim_number.to_s + end + + private + def set_defaults + self.state ||= 'not activated' + end + end diff --git a/app/models/user.rb b/app/models/user.rb index fdcd617..6c67351 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -150,6 +150,10 @@ class User < ActiveRecord::Base self.user_groups.include?(UserGroup.find(2)) end + def sim_cards + SimCard.where(:sip_account_id => self.sip_account_ids) + end + private def hash_new_pin diff --git a/app/views/sim_cards/_form_core.html.haml b/app/views/sim_cards/_form_core.html.haml index 7cba4e9..7223294 100644 --- a/app/views/sim_cards/_form_core.html.haml +++ b/app/views/sim_cards/_form_core.html.haml @@ -1,3 +1,3 @@ .inputs - = f.input :sim_number, :label => t('sim_cards.form.sim_number.label'), :hint => conditional_hint('sim_cards.form.sim_number.hint') + = f.input :sim_number, :label => t('sim_cards.form.sim_number.label'), :hint => conditional_hint('sim_cards.form.sim_number.hint'), :autofocus => true = f.association :sip_account, :collection => @available_sip_accounts, :label => t('phone_sip_accounts.form.sip_account_id.label'), :hint => conditional_hint('phone_sip_accounts.form.sip_account_id.hint'), :include_blank => false \ No newline at end of file diff --git a/app/views/sim_cards/_index_core.html.haml b/app/views/sim_cards/_index_core.html.haml index c36b22b..460c8ba 100644 --- a/app/views/sim_cards/_index_core.html.haml +++ b/app/views/sim_cards/_index_core.html.haml @@ -13,4 +13,4 @@ = render 'phone_numbers/listing', :phone_numbers => sim_card.sip_account.phone_numbers.order(:number) %td= sim_card.auth_key %td= sim_card.state - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @parent, :child => sim_card} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => sim_card.sim_card_provider, :child => sim_card} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index ba38547..dca8cff 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -67,8 +67,10 @@ - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do = render :partial => 'phones', :locals => {:user => @user} - / - cache(['user_show_sim_cards_overview', I18n.locale, @user, @user.phones]) do - / = render :partial => 'phones', :locals => {:user => @user} + - if GsParameter.get('SIM_CARDS') == true + - 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 => @user.sim_cards.first.sim_card_provider, :sim_cards => @user.sim_cards} - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do = render :partial => 'fax_accounts', :locals => {:user => @user} -- cgit v1.2.3 From b1cbfe7a7bd5e966be14b71be4e201cc9e2b1aa6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 15 Feb 2013 15:56:16 +0100 Subject: Activate a new sim_card. --- app/models/sim_card.rb | 27 +++++++++++++++++++++++++++ app/views/sim_cards/_index_core.html.haml | 2 ++ app/views/sim_cards/show.html.haml | 5 +++++ 3 files changed, 34 insertions(+) diff --git a/app/models/sim_card.rb b/app/models/sim_card.rb index 806beab..2bf7304 100644 --- a/app/models/sim_card.rb +++ b/app/models/sim_card.rb @@ -24,6 +24,9 @@ class SimCard < ActiveRecord::Base after_initialize :set_defaults + before_validation :upcase_some_values + after_create :active_sim_card + def to_s self.sim_number.to_s end @@ -33,4 +36,28 @@ class SimCard < ActiveRecord::Base self.state ||= 'not activated' end + def upcase_some_values + self.sim_number = self.sim_number.to_s.upcase + end + + def active_sim_card + require 'open-uri' + + url = "#{self.sim_card_provider.api_server_url}/app/api/main?cmd=order&ref=#{self.sim_number}&s=#{self.sim_card_provider.sip_server}&u=#{self.sip_account.auth_name}&p=#{self.sip_account.password}&ordercard=0&apiuser=#{self.sim_card_provider.api_username}&apipass=#{self.sim_card_provider.api_password}" + + open(url, "User-Agent" => "Ruby/#{RUBY_VERSION}", + "From" => "admin@localhost", + "Referer" => "http://amooma.com/gemeinschaft/gs5") { |f| + # Save the response body + @response = f.read + } + + if @response.class == String && @response.split(/;/).first == 'OK' + self.state = 'activated' + self.auth_key = @response.split(/;/).last.chomp.split(/=/).last + self.save + end + + end + end diff --git a/app/views/sim_cards/_index_core.html.haml b/app/views/sim_cards/_index_core.html.haml index 460c8ba..16440ff 100644 --- a/app/views/sim_cards/_index_core.html.haml +++ b/app/views/sim_cards/_index_core.html.haml @@ -1,5 +1,6 @@ %table.table.table-striped %tr + %th= t('sim_cards.show.sim_number') %th= t('sim_cards.index.sip_account_id') %th= t('sip_accounts.index.phone_numbers') %th= t('sim_cards.index.auth_key') @@ -8,6 +9,7 @@ - for sim_card in sim_cards %tr + %td= sim_card.sim_number %td= sim_card.sip_account %td = render 'phone_numbers/listing', :phone_numbers => sim_card.sip_account.phone_numbers.order(:number) diff --git a/app/views/sim_cards/show.html.haml b/app/views/sim_cards/show.html.haml index 88822f1..4752aab 100644 --- a/app/views/sim_cards/show.html.haml +++ b/app/views/sim_cards/show.html.haml @@ -3,6 +3,11 @@ .row .span6 %table.table.table-striped + %tr + %td + %strong= t('sim_cards.show.sim_number') + ":" + %td + = @sim_card.sim_number %tr %td %strong= t('sim_cards.show.sip_account_id') + ":" -- cgit v1.2.3 From 8474fe8ce8fe660ae65a59ed4fcad31c2e5647a2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 15 Feb 2013 16:07:47 +0100 Subject: Bugfix --- app/views/users/show.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index dca8cff..0f6cc2c 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -70,7 +70,8 @@ - if GsParameter.get('SIM_CARDS') == true - 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 => @user.sim_cards.first.sim_card_provider, :sim_cards => @user.sim_cards} + = 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 = render :partial => 'fax_accounts', :locals => {:user => @user} -- cgit v1.2.3