summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-15 14:49:16 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-15 14:49:16 +0100
commit3d11d0a3a047a12bfd40b61252e269cabac76225 (patch)
treec16baf628633205b2e664f86f2e0038f3ee3b097 /app/models
parent124a421b19e08447fa790b65cc969dadd7408539 (diff)
Basic structure for sim_cards and sim_card_providers.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ability.rb4
-rw-r--r--app/models/sim_card.rb25
-rw-r--r--app/models/sim_card_provider.rb28
3 files changed, 57 insertions, 0 deletions
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