diff options
-rw-r--r-- | app/controllers/gs_parameters_controller.rb | 83 | ||||
-rw-r--r-- | app/helpers/gs_parameters_helper.rb | 2 | ||||
-rw-r--r-- | app/models/gs_parameter.rb | 28 | ||||
-rw-r--r-- | app/views/gs_parameters/_form.html.erb | 14 | ||||
-rw-r--r-- | app/views/gs_parameters/edit.html.erb | 6 | ||||
-rw-r--r-- | app/views/gs_parameters/index.html.erb | 29 | ||||
-rw-r--r-- | app/views/gs_parameters/new.html.erb | 5 | ||||
-rw-r--r-- | app/views/gs_parameters/show.html.erb | 25 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | db/migrate/20130105093021_create_gs_parameters.rb | 12 | ||||
-rw-r--r-- | db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb | 103 | ||||
-rw-r--r-- | db/schema.rb | 11 | ||||
-rw-r--r-- | test/factories/gs_parameters.rb | 10 | ||||
-rw-r--r-- | test/functional/gs_parameters_controller_test.rb | 49 | ||||
-rw-r--r-- | test/unit/gs_parameter_test.rb | 7 | ||||
-rw-r--r-- | test/unit/helpers/gs_parameters_helper_test.rb | 4 |
16 files changed, 389 insertions, 1 deletions
diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb new file mode 100644 index 0000000..d6a92c6 --- /dev/null +++ b/app/controllers/gs_parameters_controller.rb @@ -0,0 +1,83 @@ +class GsParametersController < ApplicationController + # GET /gs_parameters + # GET /gs_parameters.json + def index + @gs_parameters = GsParameter.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @gs_parameters } + end + end + + # GET /gs_parameters/1 + # GET /gs_parameters/1.json + def show + @gs_parameter = GsParameter.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @gs_parameter } + end + end + + # GET /gs_parameters/new + # GET /gs_parameters/new.json + def new + @gs_parameter = GsParameter.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @gs_parameter } + end + end + + # GET /gs_parameters/1/edit + def edit + @gs_parameter = GsParameter.find(params[:id]) + end + + # POST /gs_parameters + # POST /gs_parameters.json + def create + @gs_parameter = GsParameter.new(params[:gs_parameter]) + + respond_to do |format| + if @gs_parameter.save + format.html { redirect_to @gs_parameter, notice: 'Gs parameter was successfully created.' } + format.json { render json: @gs_parameter, status: :created, location: @gs_parameter } + else + format.html { render action: "new" } + format.json { render json: @gs_parameter.errors, status: :unprocessable_entity } + end + end + end + + # PUT /gs_parameters/1 + # PUT /gs_parameters/1.json + def update + @gs_parameter = GsParameter.find(params[:id]) + + respond_to do |format| + if @gs_parameter.update_attributes(params[:gs_parameter]) + format.html { redirect_to @gs_parameter, notice: 'Gs parameter was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @gs_parameter.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /gs_parameters/1 + # DELETE /gs_parameters/1.json + def destroy + @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter.destroy + + respond_to do |format| + format.html { redirect_to gs_parameters_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/gs_parameters_helper.rb b/app/helpers/gs_parameters_helper.rb new file mode 100644 index 0000000..ec339ea --- /dev/null +++ b/app/helpers/gs_parameters_helper.rb @@ -0,0 +1,2 @@ +module GsParametersHelper +end diff --git a/app/models/gs_parameter.rb b/app/models/gs_parameter.rb new file mode 100644 index 0000000..d0cc37a --- /dev/null +++ b/app/models/gs_parameter.rb @@ -0,0 +1,28 @@ +class GsParameter < ActiveRecord::Base + validates :name, + :presence => true, + :uniqueness => true + + validates :value, + :presence => true + + validates :class_type, + :presence => true, + :inclusion => { :in => ['String', 'Integer', 'Boolean', 'YAML'] } + + def generate_contant + Kernel.const_set(self.name, self.value.to_i) if self.class_type == 'Integer' + Kernel.const_set(self.name, self.value.to_s) if self.class_type == 'String' + + if self.class_type == 'Boolean' + Kernel.const_set(self.name, true) if self.value == 'true' + Kernel.const_set(self.name, false) if self.value == 'false' + end + + Kernel.const_set(self.name, YAML.load(self.value)) if self.class_type == 'YAML' + end + + def to_s + name + end +end diff --git a/app/views/gs_parameters/_form.html.erb b/app/views/gs_parameters/_form.html.erb new file mode 100644 index 0000000..13ad26f --- /dev/null +++ b/app/views/gs_parameters/_form.html.erb @@ -0,0 +1,14 @@ +<%= simple_form_for(@gs_parameter) do |f| %> + <%= f.error_notification %> + + <div class="inputs"> + <%= f.input :name %> + <%= f.input :section %> + <%= f.input :value %> + <%= f.input :class_type %> + </div> + + <div class="actions"> + <%= f.button :submit %> + </div> +<% end %> diff --git a/app/views/gs_parameters/edit.html.erb b/app/views/gs_parameters/edit.html.erb new file mode 100644 index 0000000..6938a40 --- /dev/null +++ b/app/views/gs_parameters/edit.html.erb @@ -0,0 +1,6 @@ +<h1>Editing gs_parameter</h1> + +<%= render 'form' %> + +<%= link_to 'Show', @gs_parameter %> | +<%= link_to 'Back', gs_parameters_path %> diff --git a/app/views/gs_parameters/index.html.erb b/app/views/gs_parameters/index.html.erb new file mode 100644 index 0000000..dee6838 --- /dev/null +++ b/app/views/gs_parameters/index.html.erb @@ -0,0 +1,29 @@ +<h1>Listing gs_parameters</h1> + +<table> + <tr> + <th>Name</th> + <th>Section</th> + <th>Value</th> + <th>Class type</th> + <th></th> + <th></th> + <th></th> + </tr> + +<% @gs_parameters.each do |gs_parameter| %> + <tr> + <td><%= gs_parameter.name %></td> + <td><%= gs_parameter.section %></td> + <td><%= gs_parameter.value %></td> + <td><%= gs_parameter.class_type %></td> + <td><%= link_to 'Show', gs_parameter %></td> + <td><%= link_to 'Edit', edit_gs_parameter_path(gs_parameter) %></td> + <td><%= link_to 'Destroy', gs_parameter, confirm: 'Are you sure?', method: :delete %></td> + </tr> +<% end %> +</table> + +<br /> + +<%= link_to 'New Gs parameter', new_gs_parameter_path %> diff --git a/app/views/gs_parameters/new.html.erb b/app/views/gs_parameters/new.html.erb new file mode 100644 index 0000000..a357e2e --- /dev/null +++ b/app/views/gs_parameters/new.html.erb @@ -0,0 +1,5 @@ +<h1>New gs_parameter</h1> + +<%= render 'form' %> + +<%= link_to 'Back', gs_parameters_path %> diff --git a/app/views/gs_parameters/show.html.erb b/app/views/gs_parameters/show.html.erb new file mode 100644 index 0000000..1f03542 --- /dev/null +++ b/app/views/gs_parameters/show.html.erb @@ -0,0 +1,25 @@ +<p id="notice"><%= notice %></p> + +<p> + <b>Name:</b> + <%= @gs_parameter.name %> +</p> + +<p> + <b>Section:</b> + <%= @gs_parameter.section %> +</p> + +<p> + <b>Value:</b> + <%= @gs_parameter.value %> +</p> + +<p> + <b>Class type:</b> + <%= @gs_parameter.class_type %> +</p> + + +<%= link_to 'Edit', edit_gs_parameter_path(@gs_parameter) %> | +<%= link_to 'Back', gs_parameters_path %> diff --git a/config/routes.rb b/config/routes.rb index 33238dc..4137965 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Gemeinschaft42c::Application.routes.draw do + resources :gs_parameters + resources :automatic_call_distributors resources :gs_cluster_sync_log_entries diff --git a/db/migrate/20130105093021_create_gs_parameters.rb b/db/migrate/20130105093021_create_gs_parameters.rb new file mode 100644 index 0000000..e1ea2b2 --- /dev/null +++ b/db/migrate/20130105093021_create_gs_parameters.rb @@ -0,0 +1,12 @@ +class CreateGsParameters < ActiveRecord::Migration + def change + create_table :gs_parameters do |t| + t.string :name + t.string :section + t.string :value + t.string :class_type + + t.timestamps + end + end +end diff --git a/db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb b/db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb new file mode 100644 index 0000000..a4c9358 --- /dev/null +++ b/db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb @@ -0,0 +1,103 @@ +class PopulateGsParameterWithDefaults < ActiveRecord::Migration + def up + # Generic + # + GsParameter.create(:name => 'GEMEINSCHAFT_VERSION', :section => 'Generic', :value => '5.0.2-nightly-build', :class_type => 'String') + GsParameter.create(:name => 'SUPER_TENANT_NAME', :section => 'Generic', :value => 'Super-Tenant', :class_type => 'String') + + # System defaults + # + GsParameter.create(:name => 'MINIMUM_PIN_LENGTH', :section => 'System defaults', :value => '4', :class_type => 'Integer') + GsParameter.create(:name => 'MAXIMUM_PIN_LENGTH', :section => 'System defaults', :value => '10', :class_type => 'Integer') + + # GUI + # + GsParameter.create(:name => 'GUI_REDIRECT_HTTPS', :section => 'GUI', :value => 'false', :class_type => 'Boolean') + + # Phone numbers + # Only touch this if you know what you are doing! + # + GsParameter.create(:name => 'STRICT_INTERNAL_EXTENSION_HANDLING', :section => 'Phone numbers', :value => 'false', :class_type => 'Boolean') + GsParameter.create(:name => 'STRICT_DID_HANDLING', :section => 'Phone numbers', :value => 'false', :class_type => 'Boolean') + + # SIP defaults + # + GsParameter.create(:name => 'DEFAULT_LENGTH_SIP_AUTH_NAME', :section => 'SIP Defaults', :value => '10', :class_type => 'Integer') + GsParameter.create(:name => 'DEFAULT_LENGTH_SIP_PASSWORD', :section => 'SIP Defaults', :value => '15', :class_type => 'Integer') + GsParameter.create(:name => 'CALL_WAITING', :section => 'SIP Defaults', :value => 'false', :class_type => 'Boolean') + GsParameter.create(:name => 'DEFAULT_CLIR_SETTING', :section => 'SIP Defaults', :value => 'false', :class_type => 'Boolean') + GsParameter.create(:name => 'DEFAULT_CLIP_SETTING', :section => 'SIP Defaults', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:name => 'TO_S_MAX_CALLER_NAME_LENGTH', :section => 'SIP Defaults', :value => '25', :class_type => 'Integer') + GsParameter.create(:name => 'TO_S_MAX_LENGTH_OF_AUTH_NAME', :section => 'SIP Defaults', :value => '6', :class_type => 'Integer') + + # Pagination defaults + # + GsParameter.create(:name => 'DEFAULT_PAGINATION_ENTRIES_PER_PAGE', :section => 'Pagination defaults', :value => '50', :class_type => 'Integer') + + # Conference defaults + # + GsParameter.create(:name => 'MAXIMUM_NUMBER_OF_PEOPLE_IN_A_CONFERENCE', :section => 'Conference defaults', :value => '100', :class_type => 'Integer') + GsParameter.create(:name => 'DEFAULT_MAX_CONFERENCE_MEMBERS', :section => 'Conference defaults', :value => '10', :class_type => 'Integer') + + # Misc defaults + # + GsParameter.create(:name => 'MAX_EXTENSION_LENGTH', :section => 'Misc defaults', :value => '6', :class_type => 'Integer') + + # Fax defaults + # + GsParameter.create(:name => 'DEFAULT_NUMBER_OF_RETRIES', :section => 'Fax defaults', :value => '3', :class_type => 'Integer') + GsParameter.create(:name => 'DAYS_TILL_AUTO_DELETE', :section => 'Fax defaults', :value => '90', :class_type => 'Integer') + + # Names of PhoneNumberRanges + # + GsParameter.create(:name => 'INTERNAL_EXTENSIONS', :section => 'PhoneNumberRanges defaults', :value => 'internal_extensions', :class_type => 'String') + GsParameter.create(:name => 'SERVICE_NUMBERS', :section => 'PhoneNumberRanges defaults', :value => 'service_numbers', :class_type => 'String') + GsParameter.create(:name => 'DIRECT_INWARD_DIALING_NUMBERS', :section => 'PhoneNumberRanges defaults', :value => 'direct_inward_dialing_numbers', :class_type => 'String') + + # Callthrough defaults + # + GsParameter.create(:name => 'CALLTHROUGH_HAS_WHITELISTS', :section => 'Callthrough defaults', :value => 'true', :class_type => 'Boolean') + + # Huntgroup defaults + # + GsParameter.create(:name => 'HUNT_GROUP_STRATEGIES', :section => 'Huntgroup defaults', :value => ['ring_all', 'ring_recursively'].to_yaml, :class_type => 'YAML') + GsParameter.create(:name => 'VALID_SECONDS_BETWEEN_JUMPS_VALUES', :section => 'Huntgroup defaults', :value => (1 .. 60).to_a.map{|x| x * 2}.to_yaml, :class_type => 'YAML') + + # Callforward defaults + # + GsParameter.create(:name => 'DEFAULT_CALL_FORWARD_DEPTH', :section => 'Callforward defaults', :value => '1', :class_type => 'Integer') + GsParameter.create(:name => 'MAX_CALL_FORWARD_DEPTH', :section => 'Callforward defaults', :value => '40', :class_type => 'Integer') + GsParameter.create(:name => 'CALLFORWARD_DESTINATION_DEFAULT', :section => 'Callforward defaults', :value => '+49', :class_type => 'String') + GsParameter.create(:name => 'CALLFORWARD_RULES_ACT_PER_SIP_ACCOUNT_DEFAULT', :section => 'Callforward defaults', :value => 'true', :class_type => 'Boolean') + + # Phone + # + GsParameter.create(:name => 'PROVISIONING_AUTO_ADD_PHONE', :section => 'Phone', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:name => 'PROVISIONING_AUTO_ADD_SIP_ACCOUNT', :section => 'Phone', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:name => 'PROVISIONING_AUTO_TENANT_ID', :section => 'Phone', :value => '2', :class_type => 'Integer') + GsParameter.create(:name => 'PROVISIONING_AUTO_SIP_ACCOUNT_CALLER_PREFIX', :section => 'Phone', :value => 'Gemeinschaft ', :class_type => 'String') + GsParameter.create(:name => 'PROVISIONING_IEEE8021X_EAP_USERNAME', :section => 'Phone', :value => '', :class_type => 'String') + GsParameter.create(:name => 'PROVISIONING_IEEE8021X_EAP_PASSWORD', :section => 'Phone', :value => '', :class_type => 'String') + GsParameter.create(:name => 'NIGHTLY_REBOOT_OF_PHONES', :section => 'Phone', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:name => 'SIEMENS_HISTORY_RELOAD_TIMES', :section => 'Phone', :value => {0..6 => 600, 7..20 => 40, 21..24 => 300}.to_yaml, :class_type => 'YAML') + + # API configuration + # + GsParameter.create(:name => 'DEFAULT_API_TENANT_ID', :section => 'API configuration', :value => '2', :class_type => 'Integer') + GsParameter.create(:name => 'REMOTE_IP_ADDRESS_WHITELIST', :section => 'API configuration', :value => [].to_yaml, :class_type => 'YAML') # e.g. ['10.0.0.1'] + GsParameter.create(:name => 'IMPORT_CSV_FILE', :section => 'API configuration', :value => '/var/tmp/ExampleVoipCsvExport.csv', :class_type => 'String') + GsParameter.create(:name => 'DOUBLE_CHECK_POSITIVE_USERS_CSV', :section => 'API configuration', :value => '/var/tmp/ExampleDoubleCheckVoipCsvExport.csv', :class_type => 'String') + GsParameter.create(:name => 'IMPORT_CSV_ENCODING', :section => 'API configuration', :value => 'UTF-8', :class_type => 'String') + GsParameter.create(:name => 'USER_NAME_PREFIX', :section => 'API configuration', :value => 'dtc', :class_type => 'String') + GsParameter.create(:name => 'CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION', :section => 'API configuration', :value => 'Callthrough for employees', :class_type => 'String') + + # GS Cluster configuration + # + GsParameter.create(:name => 'WRITE_GS_CLUSTER_SYNC_LOG', :section => 'GS Cluster ', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:name => 'HOMEBASE_IP_ADDRESS', :section => 'GS Cluster ', :value => '0.0.0.0', :class_type => 'String') + end + + def down + GsParameter.destroy_all + end +end diff --git a/db/schema.rb b/db/schema.rb index 12114dc..2a5c267 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 => 20121230110747) do +ActiveRecord::Schema.define(:version => 20130105093128) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -526,6 +526,15 @@ ActiveRecord::Schema.define(:version => 20121230110747) do t.datetime "last_sync" end + create_table "gs_parameters", :force => true do |t| + t.string "name" + t.string "section" + t.string "value" + t.string "class_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "gui_function_memberships", :force => true do |t| t.integer "gui_function_id" t.integer "user_group_id" diff --git a/test/factories/gs_parameters.rb b/test/factories/gs_parameters.rb new file mode 100644 index 0000000..cc588e1 --- /dev/null +++ b/test/factories/gs_parameters.rb @@ -0,0 +1,10 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :gs_parameter do + name "MyString" + section "MyString" + value "MyString" + class_type "MyString" + end +end diff --git a/test/functional/gs_parameters_controller_test.rb b/test/functional/gs_parameters_controller_test.rb new file mode 100644 index 0000000..2436a69 --- /dev/null +++ b/test/functional/gs_parameters_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class GsParametersControllerTest < ActionController::TestCase + setup do + @gs_parameter = gs_parameters(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:gs_parameters) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create gs_parameter" do + assert_difference('GsParameter.count') do + post :create, gs_parameter: @gs_parameter.attributes + end + + assert_redirected_to gs_parameter_path(assigns(:gs_parameter)) + end + + test "should show gs_parameter" do + get :show, id: @gs_parameter + assert_response :success + end + + test "should get edit" do + get :edit, id: @gs_parameter + assert_response :success + end + + test "should update gs_parameter" do + put :update, id: @gs_parameter, gs_parameter: @gs_parameter.attributes + assert_redirected_to gs_parameter_path(assigns(:gs_parameter)) + end + + test "should destroy gs_parameter" do + assert_difference('GsParameter.count', -1) do + delete :destroy, id: @gs_parameter + end + + assert_redirected_to gs_parameters_path + end +end diff --git a/test/unit/gs_parameter_test.rb b/test/unit/gs_parameter_test.rb new file mode 100644 index 0000000..bc7768f --- /dev/null +++ b/test/unit/gs_parameter_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GsParameterTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/gs_parameters_helper_test.rb b/test/unit/helpers/gs_parameters_helper_test.rb new file mode 100644 index 0000000..d7653e0 --- /dev/null +++ b/test/unit/helpers/gs_parameters_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class GsParametersHelperTest < ActionView::TestCase +end |