X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/53817fa9e8d955df0891d156f21b7269b4ed08fc..ab4f96261fe043ba704616e8b6f7cf77e79817bf:/app/models/trace.rb diff --git a/app/models/trace.rb b/app/models/trace.rb index 818cc363b..3001d052c 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -2,11 +2,11 @@ # # Table name: gpx_files # -# id :bigint(8) not null, primary key -# user_id :bigint(8) not null +# id :bigint not null, primary key +# user_id :bigint not null # visible :boolean default(TRUE), not null # name :string default(""), not null -# size :bigint(8) +# size :bigint # latitude :float # longitude :float # timestamp :datetime not null @@ -38,6 +38,7 @@ class Trace < ApplicationRecord scope :visible_to, ->(u) { visible.where(:visibility => %w[public identifiable]).or(visible.where(:user => u)) } scope :visible_to_all, -> { where(:visibility => %w[public identifiable]) } scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) } + scope :imported, -> { where(:inserted => true) } has_one_attached :file, :service => Settings.trace_file_storage has_one_attached :image, :service => Settings.trace_image_storage @@ -80,16 +81,16 @@ class Trace < ApplicationRecord :content_type => content_type(attachable.path), :identify => false) else - super(attachable) + super end end def public? - visibility == "public" || visibility == "identifiable" + %w[public identifiable].include?(visibility) end def trackable? - visibility == "trackable" || visibility == "identifiable" + %w[trackable identifiable].include?(visibility) end def identifiable?