An initial (incomplete) "proof of concept" integration of an OpenStreetBugs interface into the rails port
This is a (start of a) reimplementation of the api at http://github.com/emka/openstreetbugs/tree/master/api/0.1/ into rails The client side code is taken from http://wiki.openstreetmap.org/wiki/OpenStreetBugs/New_Client This is ment as a mockup to perhaps use as a basis to further discuss how best to integrate a map bug reporting system It currently uses (more or less) the openstreetbugs api specification. But this api feels rather inconsistent with the rest of the rails_port api, so depending on discussions might still need some significant changes.
This commit is contained in:
parent
bcf8574dde
commit
42822a8b89
9 changed files with 1127 additions and 2 deletions
32
app/models/map_bug.rb
Normal file
32
app/models/map_bug.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
class MapBug < ActiveRecord::Base
|
||||
include GeoRecord
|
||||
|
||||
set_table_name 'map_bugs'
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_uniqueness_of :id
|
||||
validates_numericality_of :latitude, :only_integer => true
|
||||
validates_numericality_of :longitude, :only_integer => true
|
||||
validates_presence_of :date_created
|
||||
validates_presence_of :last_changed
|
||||
validates_inclusion_of :status, :in => [ "open", "closed", "hidden" ]
|
||||
|
||||
|
||||
def self.create_bug(lat, lon, comment)
|
||||
bug = MapBug.new(:lat => lat, :lon => lon);
|
||||
raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
|
||||
bug.text = comment
|
||||
bug.date_created = Time.now.getutc
|
||||
bug.last_changed = Time.now.getutc
|
||||
bug.status = "open";
|
||||
bug.save;
|
||||
return bug;
|
||||
end
|
||||
|
||||
def close_bug
|
||||
self.status = "closed"
|
||||
self.last_changed = Time.now.getutc
|
||||
self.save;
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue