summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
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