Files
nairobi/app/models/map_location.rb
Julian Herrero c5a7492128 add some improvements on budget headings
Show information about longitude and latitude in a budget heading
Show information about custom content in a budget heading
Fix render of map (zoom scrollable and points clickable)
Fix typo in app/models/map_location.rb
2019-01-02 10:46:46 +01:00

30 lines
726 B
Ruby

class MapLocation < ActiveRecord::Base
belongs_to :proposal, touch: true
belongs_to :investment, class_name: Budget::Investment, touch: true
validates :longitude, :latitude, :zoom, presence: true, numericality: true
def available?
latitude.present? && longitude.present? && zoom.present?
end
def json_data
{
investment_id: investment_id,
proposal_id: proposal_id,
lat: latitude,
long: longitude
}
end
def self.load_from_heading(heading)
map = new
map.zoom = Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM
map.latitude = heading.latitude.to_f if heading.latitude.present?
map.longitude = heading.longitude.to_f if heading.longitude.present?
map
end
end