From 8e9b65b01bbd9d44d4077d94f2dc4ac375cf8e85 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 18 Nov 2013 15:44:54 -0800 Subject: Start of service level code, which will be tweaked * stores desired & effective service level * whenever desired level is changed, effective level will be updated * allows user to set their desired service level * allow admin to update desired & effective service level --- users/app/models/unauthenticated_user.rb | 2 ++ users/app/models/user.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'users/app/models') diff --git a/users/app/models/unauthenticated_user.rb b/users/app/models/unauthenticated_user.rb index 99a6874..0fc17d2 100644 --- a/users/app/models/unauthenticated_user.rb +++ b/users/app/models/unauthenticated_user.rb @@ -1,4 +1,6 @@ # The nil object for the user class class UnauthenticatedUser < Object + # will probably want something here to return service level as APP_CONFIG[:service_levels][0] but not sure how will be accessing. + end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index a14fcb5..35212a1 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -9,6 +9,12 @@ class User < CouchRest::Model::Base property :enabled, TrueClass, :default => true + # these will be null by default. should we set to APP_CONFIG[:default_service_level] by default, or have code assume that until these get set?: + property :desired_service_level, Integer, :accessible => true + property :effective_service_level, Integer, :accessible => true + + before_save :update_effective_service_level + validates :login, :password_salt, :password_verifier, :presence => true @@ -116,4 +122,10 @@ class User < CouchRest::Model::Base def serverside? true end + + def update_effective_service_level + if self.desired_service_level_changed? + self.effective_service_level = self.desired_service_level + end + end end -- cgit v1.2.3