diff options
37 files changed, 709 insertions, 226 deletions
@@ -1,10 +1,10 @@ source 'http://rubygems.org' -gem 'rails', '3.2.9' +gem 'rails', '3.2.11' gem 'bcrypt-ruby' gem 'sqlite3' gem 'mysql2' -gem 'cancan' +gem 'cancan', '1.6.7' gem 'state_machine' gem 'acts_as_list' gem 'dalli' # memcached diff --git a/Gemfile.lock b/Gemfile.lock index dd98f2d..e4deaeb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.9) - actionpack (= 3.2.9) + actionmailer (3.2.11) + actionpack (= 3.2.11) mail (~> 2.4.4) - actionpack (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) + actionpack (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -14,18 +14,18 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.9) - activesupport (= 3.2.9) + activemodel (3.2.11) + activesupport (= 3.2.11) builder (~> 3.0.0) - activerecord (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) + activerecord (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - activesupport (3.2.9) + activeresource (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) + activesupport (3.2.11) i18n (~> 0.6) multi_json (~> 1.0) acts_as_list (0.1.9) @@ -36,7 +36,7 @@ GEM builder (3.0.4) cache_digests (0.2.0) actionpack (>= 3.2) - cancan (1.6.8) + cancan (1.6.7) carrierwave (0.8.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -122,17 +122,17 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.9) - actionmailer (= 3.2.9) - actionpack (= 3.2.9) - activerecord (= 3.2.9) - activeresource (= 3.2.9) - activesupport (= 3.2.9) + rails (3.2.11) + actionmailer (= 3.2.11) + actionpack (= 3.2.11) + activerecord (= 3.2.11) + activeresource (= 3.2.11) + activesupport (= 3.2.11) bundler (~> 1.0) - railties (= 3.2.9) - railties (3.2.9) - actionpack (= 3.2.9) - activesupport (= 3.2.9) + railties (= 3.2.11) + railties (3.2.11) + actionpack (= 3.2.11) + activesupport (= 3.2.11) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -183,7 +183,7 @@ DEPENDENCIES bcrypt-ruby breadcrumbs_on_rails cache_digests - cancan + cancan (= 1.6.7) carrierwave coffee-rails (~> 3.2.1) compass-rails @@ -202,7 +202,7 @@ DEPENDENCIES mysql2 nokogiri private_pub - rails (= 3.2.9) + rails (= 3.2.11) sass-rails simple_form (= 2.0.1) sqlite3 diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb new file mode 100644 index 0000000..631339b --- /dev/null +++ b/app/controllers/call_routes_controller.rb @@ -0,0 +1,41 @@ +class CallRoutesController < ApplicationController + def index + @call_routes = CallRoute.all + end + + def show + @call_route = CallRoute.find(params[:id]) + end + + def new + @call_route = CallRoute.new + end + + def create + @call_route = CallRoute.new(params[:call_route]) + if @call_route.save + redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') + else + render :new + end + end + + def edit + @call_route = CallRoute.find(params[:id]) + end + + def update + @call_route = CallRoute.find(params[:id]) + if @call_route.update_attributes(params[:call_route]) + redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @call_route = CallRoute.find(params[:id]) + @call_route.destroy + redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') + end +end diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb new file mode 100644 index 0000000..595a20d --- /dev/null +++ b/app/controllers/route_elements_controller.rb @@ -0,0 +1,41 @@ +class RouteElementsController < ApplicationController + def index + @route_elements = RouteElement.all + end + + def show + @route_element = RouteElement.find(params[:id]) + end + + def new + @route_element = RouteElement.new + end + + def create + @route_element = RouteElement.new(params[:route_element]) + if @route_element.save + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_created') + else + render :new + end + end + + def edit + @route_element = RouteElement.find(params[:id]) + end + + def update + @route_element = RouteElement.find(params[:id]) + if @route_element.update_attributes(params[:route_element]) + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @route_element = RouteElement.find(params[:id]) + @route_element.destroy + redirect_to route_elements_url, :notice => t('route_elements.controller.successfuly_destroyed') + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 454c26b..7af8e68 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController end def show - @phone_books = PhoneBook.accessible_by( Ability.new( @user ) ).all + @phone_books = PhoneBook.accessible_by( Ability.new( @user ), :read ) end def new diff --git a/app/helpers/call_routes_helper.rb b/app/helpers/call_routes_helper.rb new file mode 100644 index 0000000..dfe87dd --- /dev/null +++ b/app/helpers/call_routes_helper.rb @@ -0,0 +1,2 @@ +module CallRoutesHelper +end diff --git a/app/helpers/route_elements_helper.rb b/app/helpers/route_elements_helper.rb new file mode 100644 index 0000000..4262a50 --- /dev/null +++ b/app/helpers/route_elements_helper.rb @@ -0,0 +1,2 @@ +module RouteElementsHelper +end diff --git a/app/models/call_route.rb b/app/models/call_route.rb new file mode 100644 index 0000000..eba247c --- /dev/null +++ b/app/models/call_route.rb @@ -0,0 +1,5 @@ +class CallRoute < ActiveRecord::Base + attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position + + has_many :route_elements, :dependent => :destroy +end diff --git a/app/models/route_element.rb b/app/models/route_element.rb new file mode 100644 index 0000000..e845f24 --- /dev/null +++ b/app/models/route_element.rb @@ -0,0 +1,5 @@ +class RouteElement < ActiveRecord::Base + attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position + + belongs_to :call_route +end diff --git a/app/views/call_routes/_form.html.haml b/app/views/call_routes/_form.html.haml new file mode 100644 index 0000000..1415852 --- /dev/null +++ b/app/views/call_routes/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@call_route) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('call_routes.form.submit')
\ No newline at end of file diff --git a/app/views/call_routes/_form_core.html.haml b/app/views/call_routes/_form_core.html.haml new file mode 100644 index 0000000..4b97434 --- /dev/null +++ b/app/views/call_routes/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :table, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint') + = f.input :name, :label => t('call_routes.form.name.label'), :hint => conditional_hint('call_routes.form.name.hint') + = f.input :endpoint_type, :label => t('call_routes.form.endpoint_type.label'), :hint => conditional_hint('call_routes.form.endpoint_type.hint') + = f.input :endpoint_id, :label => t('call_routes.form.endpoint_id.label'), :hint => conditional_hint('call_routes.form.endpoint_id.hint') + = f.input :position, :label => t('call_routes.form.position.label'), :hint => conditional_hint('call_routes.form.position.hint') diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml new file mode 100644 index 0000000..6ea3af7 --- /dev/null +++ b/app/views/call_routes/_index_core.html.haml @@ -0,0 +1,17 @@ +%table + %tr + %th= t('call_routes.index.table') + %th= t('call_routes.index.name') + %th= t('call_routes.index.endpoint_type') + %th= t('call_routes.index.endpoint_id') + %th= t('call_routes.index.position') + + - reset_cycle + - for call_route in call_routes + %tr{:class => cycle('odd', 'even')} + %td= call_route.table + %td= call_route.name + %td= call_route.endpoint_type + %td= call_route.endpoint_id + %td= call_route.position + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route}
\ No newline at end of file diff --git a/app/views/call_routes/edit.html.haml b/app/views/call_routes/edit.html.haml new file mode 100644 index 0000000..0ad46c5 --- /dev/null +++ b/app/views/call_routes/edit.html.haml @@ -0,0 +1,3 @@ +- title t("call_routes.edit.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml new file mode 100644 index 0000000..687a9dc --- /dev/null +++ b/app/views/call_routes/index.html.haml @@ -0,0 +1,6 @@ +- title t("call_routes.index.page_title") + +- if @call_routes && @call_routes.count > 0 + = render "index_core", :call_routes => @call_routes + += render :partial => 'shared/create_link', :locals => {:child_class => CallRoute}
\ No newline at end of file diff --git a/app/views/call_routes/new.html.haml b/app/views/call_routes/new.html.haml new file mode 100644 index 0000000..0796d7f --- /dev/null +++ b/app/views/call_routes/new.html.haml @@ -0,0 +1,3 @@ +- title t("call_routes.new.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml new file mode 100644 index 0000000..31c3cb0 --- /dev/null +++ b/app/views/call_routes/show.html.haml @@ -0,0 +1,19 @@ +- title t("call_routes.show.page_title") + +%p + %strong= t('call_routes.show.table') + ":" + = @call_route.table +%p + %strong= t('call_routes.show.name') + ":" + = @call_route.name +%p + %strong= t('call_routes.show.endpoint_type') + ":" + = @call_route.endpoint_type +%p + %strong= t('call_routes.show.endpoint_id') + ":" + = @call_route.endpoint_id +%p + %strong= t('call_routes.show.position') + ":" + = @call_route.position + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route }
\ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c1a56f2..a2afbf8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,8 +3,7 @@ <!--[if IE 7]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if gt IE 8]><!--> -%html.no-js{ :lang => "en" } - ~#OPTIMIZE Make html lang attribute reflect the actual language. +%html.no-js{ :lang => I18n.locale.to_s } <!--<![endif]--> %header %meta{ :charset => "utf-8" }/ @@ -19,7 +18,8 @@ %body #container - = render :partial => "shared/header" + - cache(['application_header', I18n.locale, current_user]) do + = render :partial => "shared/header" = render :partial => "shared/flash", :locals => { :flash => flash} #content{:role => 'main'} @@ -30,18 +30,19 @@ %h1= yield(:title) = yield - %footer#main - %ul - %li - %a{:href => "http://amooma.de/gemeinschaft/gs5"} Gemeinschaft #{GsParameter.get('GEMEINSCHAFT_VERSION')} - - if GuiFunction.display?('amooma_commercial_support_link_in_footer', current_user) + - cache(['application_footer', I18n.locale]) do + %footer#main + %ul %li - %a{:href => "http://amooma.de"} Kommerzieller Support und Consulting - - if GuiFunction.display?('gemeinschaft_mailinglist_link_in_footer', current_user) - %li - %a{:href => "https://groups.google.com/group/gs5-users/"} Kostenlose Mailingliste + %a{:href => "http://amooma.de/gemeinschaft/gs5"} Gemeinschaft #{GsParameter.get('GEMEINSCHAFT_VERSION')} + - if GuiFunction.display?('amooma_commercial_support_link_in_footer', current_user) + %li + %a{:href => "http://amooma.de"} Kommerzieller Support und Consulting + - if GuiFunction.display?('gemeinschaft_mailinglist_link_in_footer', current_user) + %li + %a{:href => "https://groups.google.com/group/gs5-users/"} Kostenlose Mailingliste - .amooma-logo - %span brought to you by - %a{ :target => '_blank', :href => "http://amooma.de/" } Amooma + .amooma-logo + %span brought to you by + %a{ :target => '_blank', :href => "http://amooma.de/" } Amooma diff --git a/app/views/route_elements/_form.html.haml b/app/views/route_elements/_form.html.haml new file mode 100644 index 0000000..cfa4c6b --- /dev/null +++ b/app/views/route_elements/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@route_element) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('route_elements.form.submit')
\ No newline at end of file diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml new file mode 100644 index 0000000..7697cb0 --- /dev/null +++ b/app/views/route_elements/_form_core.html.haml @@ -0,0 +1,9 @@ +.inputs + = f.input :call_route_id, :label => t('route_elements.form.call_route_id.label'), :hint => conditional_hint('route_elements.form.call_route_id.hint') + = f.input :var_in, :label => t('route_elements.form.var_in.label'), :hint => conditional_hint('route_elements.form.var_in.hint') + = f.input :var_out, :label => t('route_elements.form.var_out.label'), :hint => conditional_hint('route_elements.form.var_out.hint') + = f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint') + = f.input :replacement, :label => t('route_elements.form.replacement.label'), :hint => conditional_hint('route_elements.form.replacement.hint') + = f.input :action, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint') + = f.input :mandatory, :label => t('route_elements.form.mandatory.label'), :hint => conditional_hint('route_elements.form.mandatory.hint') + = f.input :position, :label => t('route_elements.form.position.label'), :hint => conditional_hint('route_elements.form.position.hint') diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml new file mode 100644 index 0000000..63665fd --- /dev/null +++ b/app/views/route_elements/_index_core.html.haml @@ -0,0 +1,23 @@ +%table + %tr + %th= t('route_elements.index.call_route_id') + %th= t('route_elements.index.var_in') + %th= t('route_elements.index.var_out') + %th= t('route_elements.index.pattern') + %th= t('route_elements.index.replacement') + %th= t('route_elements.index.action') + %th= t('route_elements.index.mandatory') + %th= t('route_elements.index.position') + + - reset_cycle + - for route_element in route_elements + %tr{:class => cycle('odd', 'even')} + %td= route_element.call_route_id + %td= route_element.var_in + %td= route_element.var_out + %td= route_element.pattern + %td= route_element.replacement + %td= route_element.action + %td= route_element.mandatory + %td= route_element.position + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => route_element}
\ No newline at end of file diff --git a/app/views/route_elements/edit.html.haml b/app/views/route_elements/edit.html.haml new file mode 100644 index 0000000..770eb6c --- /dev/null +++ b/app/views/route_elements/edit.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.edit.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/route_elements/index.html.haml b/app/views/route_elements/index.html.haml new file mode 100644 index 0000000..b05236b --- /dev/null +++ b/app/views/route_elements/index.html.haml @@ -0,0 +1,6 @@ +- title t("route_elements.index.page_title") + +- if @route_elements && @route_elements.count > 0 + = render "index_core", :route_elements => @route_elements + += render :partial => 'shared/create_link', :locals => {:child_class => RouteElement}
\ No newline at end of file diff --git a/app/views/route_elements/new.html.haml b/app/views/route_elements/new.html.haml new file mode 100644 index 0000000..903e808 --- /dev/null +++ b/app/views/route_elements/new.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.new.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/route_elements/show.html.haml b/app/views/route_elements/show.html.haml new file mode 100644 index 0000000..a439353 --- /dev/null +++ b/app/views/route_elements/show.html.haml @@ -0,0 +1,28 @@ +- title t("route_elements.show.page_title") + +%p + %strong= t('route_elements.show.call_route_id') + ":" + = @route_element.call_route_id +%p + %strong= t('route_elements.show.var_in') + ":" + = @route_element.var_in +%p + %strong= t('route_elements.show.var_out') + ":" + = @route_element.var_out +%p + %strong= t('route_elements.show.pattern') + ":" + = @route_element.pattern +%p + %strong= t('route_elements.show.replacement') + ":" + = @route_element.replacement +%p + %strong= t('route_elements.show.action') + ":" + = @route_element.action +%p + %strong= t('route_elements.show.mandatory') + ":" + = @route_element.mandatory +%p + %strong= t('route_elements.show.position') + ":" + = @route_element.position + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @route_element }
\ No newline at end of file diff --git a/config/locales/views/call_routes/de.yml b/config/locales/views/call_routes/de.yml new file mode 100644 index 0000000..34af575 --- /dev/null +++ b/config/locales/views/call_routes/de.yml @@ -0,0 +1,60 @@ +de: + call_routes: + name: 'Call route' + controller: + successfuly_created: 'Call route wurde angelegt.' + successfuly_updated: 'Call route wurde aktualisiert.' + successfuly_destroyed: 'Call route wurde gelöscht.' + index: + page_title: 'Übersicht von Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Call route' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Call route neu anlegen für %{resource}' + show: + page_title: 'Call route bearbeiten' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Call route neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Call route bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + table: + label: 'Table' + hint: '' + name: + label: 'Name' + hint: '' + endpoint_type: + label: 'Endpoint type' + hint: '' + endpoint_id: + label: 'Endpoint' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Absenden'
\ No newline at end of file diff --git a/config/locales/views/call_routes/en.yml b/config/locales/views/call_routes/en.yml new file mode 100644 index 0000000..251f76e --- /dev/null +++ b/config/locales/views/call_routes/en.yml @@ -0,0 +1,60 @@ +en: + call_routes: + name: 'Call route' + controller: + successfuly_created: 'Successfully created Call route.' + successfuly_updated: 'Successfully updated Call route.' + successfuly_destroyed: 'Successfully destroyed Call route.' + index: + page_title: 'Listing Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this Call route?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Call route for %{resource}' + show: + page_title: 'Show Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Call route' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Call route' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + table: + label: 'Table' + hint: '' + name: + label: 'Name' + hint: '' + endpoint_type: + label: 'Endpoint type' + hint: '' + endpoint_id: + label: 'Endpoint' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Submit'
\ No newline at end of file diff --git a/config/locales/views/route_elements/de.yml b/config/locales/views/route_elements/de.yml new file mode 100644 index 0000000..d2c6c39 --- /dev/null +++ b/config/locales/views/route_elements/de.yml @@ -0,0 +1,75 @@ +de: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Route element wurde angelegt.' + successfuly_updated: 'Route element wurde aktualisiert.' + successfuly_destroyed: 'Route element wurde gelöscht.' + index: + page_title: 'Übersicht von Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Route element' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Route element neu anlegen für %{resource}' + show: + page_title: 'Route element bearbeiten' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Route element neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Route element bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Absenden'
\ No newline at end of file diff --git a/config/locales/views/route_elements/en.yml b/config/locales/views/route_elements/en.yml new file mode 100644 index 0000000..1340309 --- /dev/null +++ b/config/locales/views/route_elements/en.yml @@ -0,0 +1,75 @@ +en: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Successfully created Route element.' + successfuly_updated: 'Successfully updated Route element.' + successfuly_destroyed: 'Successfully destroyed Route element.' + index: + page_title: 'Listing Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this Route element?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Route element for %{resource}' + show: + page_title: 'Show Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Route element' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Route element' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Submit'
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4e812c0..3874170 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Gemeinschaft42c::Application.routes.draw do + resources :route_elements + + resources :call_routes + resources :gateways do resources :gateway_settings resources :gateway_parameters diff --git a/db/migrate/20130116133243_create_call_routes.rb b/db/migrate/20130116133243_create_call_routes.rb new file mode 100644 index 0000000..c2d3f45 --- /dev/null +++ b/db/migrate/20130116133243_create_call_routes.rb @@ -0,0 +1,16 @@ +class CreateCallRoutes < ActiveRecord::Migration + def self.up + create_table :call_routes do |t| + t.string :table + t.string :name + t.string :endpoint_type + t.integer :endpoint_id + t.integer :position + t.timestamps + end + end + + def self.down + drop_table :call_routes + end +end diff --git a/db/migrate/20130116133433_create_route_elements.rb b/db/migrate/20130116133433_create_route_elements.rb new file mode 100644 index 0000000..72f6894 --- /dev/null +++ b/db/migrate/20130116133433_create_route_elements.rb @@ -0,0 +1,19 @@ +class CreateRouteElements < ActiveRecord::Migration + def self.up + create_table :route_elements do |t| + t.integer :call_route_id + t.string :var_in + t.string :var_out + t.string :pattern + t.string :replacement + t.string :action + t.boolean :mandatory + t.integer :position + t.timestamps + end + end + + def self.down + drop_table :route_elements + end +end diff --git a/lib/tasks/heater.rake b/lib/tasks/heater.rake new file mode 100644 index 0000000..7d026d9 --- /dev/null +++ b/lib/tasks/heater.rake @@ -0,0 +1,6 @@ +namespace :heater do + desc "Warm up the cache." + task :preheat => :environment do + + end +end
\ No newline at end of file diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua deleted file mode 100644 index 2071288..0000000 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ /dev/null @@ -1,181 +0,0 @@ --- Gemeinschaft 5 module: call router class --- (c) AMOOMA GmbH 2013 --- - -module(...,package.seeall) - -Router = {} - --- create route object -function Router.new(self, arg) - arg = arg or {} - object = arg.object or {} - setmetatable(object, self); - self.__index = self; - self.class = 'router'; - self.log = arg.log; - self.database = arg.database; - self.routes = arg.routes or {}; - self.caller = arg.caller; - self.variables = arg.variables or {}; - return object; -end - - -function Router.read_table(self, table_name) - local routing_table = {}; - - local sql_query = 'SELECT * \ - FROM `call_routes` `a` \ - JOIN `route_elements` `b` ON `a`.`id` = `b`.`call_route_id`\ - WHERE `a`.`table` = "' .. table_name .. '" \ - ORDER BY `a`.`position`, `b`.`position`'; - - local last_id = 0; - self.database:query(sql_query, function(route) - if last_id ~= tonumber(route.call_route_id) then - last_id = tonumber(route.call_route_id); - table.insert(routing_table, {id = route.call_route_id, name = route.name, endpoint_type = route.endpoint_type , endpoint_id = route.endpoint_id, elements = {} }); - end - - table.insert(routing_table[#routing_table].elements, { - var_in = route.var_in, - var_out = route.var_out, - pattern = route.pattern, - replacement = route.replacement, - action = route.action, - mandatory = common.str.to_b(route.mandatory), - }); - end); - - return routing_table; -end - - -function Router.expand_variables(self, line) - return (line:gsub('{([%a%d_]+)}', function(captured) - return variables[captured] or ''; - end)) -end - - -function Router.set_parameter(self, action, name, value) - if action == 'set_session_var' then - self.log:debug('ROUTER_SET_SESSION_VARIABLE - ', name, ' = ', value); - self.caller[name] = value; - elseif action == 'set_channel_var' then - self.log:debug('ROUTER_SET_VARIABLE - ', name, ' = ', value); - self.caller:set_variable(name, value); - elseif action == 'export_channel_var' then - self.log:debug('ROUTER_EXPORT_VARIABLE - ', name, ' = ', value); - self.caller:export_variable(name, value); - elseif action == 'set_header' then - self.log:debug('ROUTER_SIP_HEADER - ', name, ': ', value); - self.caller:export_variable('sip_h_' .. name, value); - else - self.log:error('ROUTER_SET_PARAMERER - unknown action: ', action, ', ', name, ' = ', value); - end -end - - -function Router.element_match(self, pattern, search_string, replacement) - local variables_list = {}; - local success, result = pcall(string.find, search_string, pattern); - - if not success then - self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); - elseif result then - return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list)); - end - - return false; -end - - -function Router.route_match(self, route) - local destination = { - gateway = 'gateway' .. route.endpoint_id, - ['type'] = route.endpoint_type, - id = route.endpoint_id, - actions = {} - }; - - local route_matches = false; - - for index=1, #route.elements do - local result = false; - local replacement = nil; - - local element = route.elements[index]; - if element.var_in == 'group' then - local groups = common.str.try(self.caller, 'auth_account.owner.groups'); - if not groups or type(groups) ~= 'table' then - if element.mandatory then - return false; - end - end - - for group_name, value in pairs(groups) do - result, replacement = self:element_match(tostring(element.pattern), tostring(group_name), tostring(element.replacement)); - if result then - break; - end - end - - else - local search_string = tostring(common.str.try(self.caller, element.var_in)) - result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); - end - - if element.action == 'not_match' then - result = not result; - end - - if not result then - if element.mandatory then - return false; - end - elseif element.action ~= 'match' and element.action ~= 'not_match' then - if element.action == 'set_route_var' then - destination[element.var_out] = replacement; - else - table.insert(destination.actions, {action = element.action, name = element.var_out, value = replacement}); - end - end - - if result then - route_matches = true; - end - end - - if route_matches then - return destination; - end; - - return nil; -end - - -function Router.route_run(self, table_name, phone_number, find_first) - local routing_table = self:read_table(table_name); - local routes = {}; - - if type(routing_table) == 'table' then - for index=1, #routing_table do - local route = self:route_match(routing_table[index], phone_number); - if route then - table.insert(routes, route); - self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id); - if find_first then - return route; - end - else - self.log:debug('ROUTE_NO_MATCH - ', table_name, '=', routing_table[index].id, '/', routing_table[index].name); - end - end - end - - if not find_first then - return routes; - end -end diff --git a/test/functional/call_routes_controller_test.rb b/test/functional/call_routes_controller_test.rb new file mode 100644 index 0000000..77c0b2a --- /dev/null +++ b/test/functional/call_routes_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class CallRoutesControllerTest < ActionController::TestCase + setup do + @call_route = call_routes(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:call_routes) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create call_route" do + assert_difference('CallRoute.count') do + post :create, call_route: @call_route.attributes + end + + assert_redirected_to call_route_path(assigns(:call_route)) + end + + test "should show call_route" do + get :show, id: @call_route.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @call_route.to_param + assert_response :success + end + + test "should update call_route" do + put :update, id: @call_route.to_param, call_route: @call_route.attributes + assert_redirected_to call_route_path(assigns(:call_route)) + end + + test "should destroy call_route" do + assert_difference('CallRoute.count', -1) do + delete :destroy, id: @call_route.to_param + end + + assert_redirected_to call_routes_path + end +end diff --git a/test/functional/route_elements_controller_test.rb b/test/functional/route_elements_controller_test.rb new file mode 100644 index 0000000..3d7afaa --- /dev/null +++ b/test/functional/route_elements_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class RouteElementsControllerTest < ActionController::TestCase + setup do + @route_element = route_elements(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:route_elements) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create route_element" do + assert_difference('RouteElement.count') do + post :create, route_element: @route_element.attributes + end + + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should show route_element" do + get :show, id: @route_element.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @route_element.to_param + assert_response :success + end + + test "should update route_element" do + put :update, id: @route_element.to_param, route_element: @route_element.attributes + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should destroy route_element" do + assert_difference('RouteElement.count', -1) do + delete :destroy, id: @route_element.to_param + end + + assert_redirected_to route_elements_path + end +end diff --git a/test/unit/call_route_test.rb b/test/unit/call_route_test.rb new file mode 100644 index 0000000..5eb2e50 --- /dev/null +++ b/test/unit/call_route_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CallRouteTest < ActiveSupport::TestCase + def test_should_be_valid + assert CallRoute.new.valid? + end +end diff --git a/test/unit/route_element_test.rb b/test/unit/route_element_test.rb new file mode 100644 index 0000000..807a4ca --- /dev/null +++ b/test/unit/route_element_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RouteElementTest < ActiveSupport::TestCase + def test_should_be_valid + assert RouteElement.new.valid? + end +end |