fix editable + serialized-hash attributes
[arvados.git] / apps / workbench / app / models / arvados_base.rb
index 2aa91f735eb67e3299b09c055531d231e569f82c..6b8278d0ec5bee1c787218a25106567534de897f 100644 (file)
@@ -112,7 +112,9 @@ class ArvadosBase < ActiveRecord::Base
     %w(uuid owner created_at
        modified_at modified_by_user modified_by_client
       ).each do |attr|
-      self.send(attr + '=', resp[attr.to_sym])
+      if self.respond_to? "#{attr}=".to_sym
+        self.send(attr + '=', resp[attr.to_sym])
+      end
     end
 
     self
@@ -212,7 +214,7 @@ class ArvadosBase < ActiveRecord::Base
   end
 
   def editable?
-    (current_user and
+    (current_user and current_user.is_active and
      (current_user.is_admin or
       current_user.uuid == self.owner))
   end
@@ -220,10 +222,12 @@ class ArvadosBase < ActiveRecord::Base
   def attribute_editable?(attr)
     if "created_at modified_at modified_by_user modified_by_client updated_at".index(attr.to_s)
       false
-    elsif "uuid owner".index(attr.to_s)
-      current_user and current_user.is_admin
+    elsif not (current_user.andand.is_active)
+      false
+    elsif "uuid owner".index(attr.to_s) or current_user.is_admin
+      current_user.is_admin
     else
-      current_user and current_user.uuid == owner
+      current_user.uuid == self.owner or current_user.uuid == self.uuid
     end
   end