summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/sim_card.rb11
-rw-r--r--app/models/user.rb4
2 files changed, 15 insertions, 0 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