1 class MapBugsController < ApplicationController
3 before_filter :check_api_readable
4 before_filter :check_api_writable, :only => [:add_bug, :close_bug, :edit_bug]
5 after_filter :compress_output
6 around_filter :api_call_handle_error, :api_call_timeout
8 # Help methods for checking boundary sanity and area size
13 raise OSM::APIBadUserInput.new("No l was given") unless params['l']
14 raise OSM::APIBadUserInput.new("No r was given") unless params['r']
15 raise OSM::APIBadUserInput.new("No b was given") unless params['b']
16 raise OSM::APIBadUserInput.new("No t was given") unless params['t']
18 min_lon = params['l'].to_f
19 max_lon = params['r'].to_f
20 min_lat = params['b'].to_f
21 max_lat = params['t'].to_f
23 # check boundary is sane and area within defined
24 # see /config/application.yml
26 check_boundaries(min_lon, min_lat, max_lon, max_lat)
27 rescue Exception => err
28 report_error(err.message)
32 bugs = MapBug.find_by_area(min_lat, min_lon, max_lat, max_lon, :order => "last_changed DESC", :limit => 100, :conditions => "status != 'hidden'")
37 resp += "putAJAXMarker(" + bug.id.to_s + ", " + bug.lon.to_s + ", " + bug.lat.to_s + " , '" + bug.text + "'," + (bug.status=="open"?"0":"1") + ");\n"
40 render :text => resp, :content_type => "text/javascript"
44 raise OSM::APIBadUserInput.new("No lat was given") unless params['lat']
45 raise OSM::APIBadUserInput.new("No lon was given") unless params['lon']
46 raise OSM::APIBadUserInput.new("No text was given") unless params['text']
48 lon = params['lon'].to_f
49 lat = params['lat'].to_f
50 comment = params['text']
52 bug = MapBug.create_bug(lat, lon, comment)
58 raise OSM::APIBadUserInput.new("No id was given") unless params['id']
59 raise OSM::APIBadUserInput.new("No text was given") unless params['text']
61 id = params['id'].to_i
63 bug = MapBug.find_by_id(id);
64 bug.text += "<hr /> " + params['text']
65 bug.last_changed = Time.now.getutc;
72 raise OSM::APIBadUserInput.new("No id was given") unless params['id']
74 id = params['id'].to_i
76 bug = MapBug.find_by_id(id);
84 output_js = :true if params['format'] == "js"
87 render :text => "osbResponse();", :content_type => "text/javascript"
89 render :text => "ok\n", :content_type => "text/html"
95 ##TODO: needs to be implemented
99 ##TODO: needs to be implemented