Move @redis.exists and .getrange outside .subscribe block. Otherwise
[arvados.git] / services / api / app / models / arvados_model.rb
index 09b61413b4dcceb7d4166838a83276cc6cf70aa3..136684d009d533791172f6969ea9e326836e0633 100644 (file)
@@ -22,6 +22,10 @@ class ArvadosModel < ActiveRecord::Base
     kind.match(/^arvados\#(.+?)(_list|List)?$/)[1].pluralize.classify.constantize rescue nil
   end
 
+  def href
+    "#{current_api_base}/#{self.class.to_s.pluralize.underscore}/#{self.uuid}"
+  end
+
   def eager_load_associations
     self.class.columns.each do |col|
       re = col.name.match /^(.*)_kind$/
@@ -58,11 +62,11 @@ class ArvadosModel < ActiveRecord::Base
       logger.warn "Inactive user #{current_user.uuid} tried to update #{self.class.to_s} #{self.uuid_was}"
       return false
     end
+    return true if current_user.is_admin
     if self.uuid_changed?
       logger.warn "User #{current_user.uuid} tried to change uuid of #{self.class.to_s} #{self.uuid_was} to #{self.uuid}"
       return false
     end
-    return true if current_user.is_admin
     if self.owner_uuid_changed?
       if current_user.uuid == self.owner_uuid or
           current_user.can? write: self.owner_uuid