diff options
Diffstat (limited to 'helper.rb')
-rw-r--r-- | helper.rb | 43 |
1 files changed, 9 insertions, 34 deletions
@@ -1,35 +1,5 @@ helpers do - def login(username, password) - logout - session[:subjectid] = OpenTox::Authorization.authenticate(username, password) - #LOGGER.debug "ToxCreate login user #{username} with subjectid: " + session[:subjectid].to_s - if session[:subjectid] != nil - session[:username] = username - return true - else - session[:username] = "" - return false - end - end - - def logout - if session[:subjectid] != nil - session[:subjectid] = nil - session[:username] = "" - return true - end - return false - end - - def logged_in() - return true if !AA_SERVER - if session[:subjectid] != nil - return OpenTox::Authorization.is_token_valid(session[:subjectid]) - end - return false - end - def is_authorized(uri, action) if OpenTox::Authorization.server && session[:subjectid] != nil return OpenTox::Authorization.authorized?(uri, action, session[:subjectid]) @@ -54,10 +24,15 @@ helpers do def sort(descriptors,value_map) features = {:activating => [], :deactivating => []} descriptors.each do |d| - if d[OT.effect] =~ TRUE_REGEXP - features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} - elsif d[OT.effect] =~ FALSE_REGEXP - features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} + if !value_map.empty? + features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 2 + features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 1 + else + if d[OT.effect] =~ TRUE_REGEXP + features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} + elsif d[OT.effect] =~ FALSE_REGEXP + features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} + end end end features |