summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/sim_card.rb11
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/sim_cards/_form_core.html.haml2
-rw-r--r--app/views/sim_cards/_index_core.html.haml2
-rw-r--r--app/views/users/show.html.haml6
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}