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