4523: omit text type columns from searchable columns.
[arvados.git] / services / api / app / models / arvados_model.rb
index 376df0cef3cd9aea812bcdf1a92fff92b76f8952..8e98382bf070c53a8835eada595010421865a372 100644 (file)
@@ -36,6 +36,12 @@ class ArvadosModel < ActiveRecord::Base
     end
   end
 
+  class AlreadyLockedError < StandardError
+    def http_status
+      403
+    end
+  end
+
   class UnauthorizedError < StandardError
     def http_status
       401
@@ -54,8 +60,14 @@ class ArvadosModel < ActiveRecord::Base
     textonly_operator = !operator.match(/[<=>]/)
     self.columns.select do |col|
       case col.type
-      when :string, :text
+      when :string
         true
+      when :text
+        if operator == 'ilike'
+          false
+        else
+          true
+        end
       when :datetime, :integer, :boolean
         !textonly_operator
       else
@@ -104,7 +116,8 @@ class ArvadosModel < ActiveRecord::Base
     unless (owner_uuid == current_user.uuid or
             current_user.is_admin or
             (current_user.groups_i_can(:manage) & [uuid, owner_uuid]).any?)
-      if current_user.groups_i_can(:write).index(uuid)
+      if ((current_user.groups_i_can(:write) + [current_user.uuid]) &
+          [uuid, owner_uuid]).any?
         return [owner_uuid, current_user.uuid]
       else
         return [owner_uuid]
@@ -520,7 +533,6 @@ class ArvadosModel < ActiveRecord::Base
     log = Log.new(event_type: event_type).fill_object(self)
     yield log
     log.save!
-    connection.execute "NOTIFY logs, '#{log.id}'"
     log_start_state
   end