From: Tom Hughes Date: Mon, 8 Apr 2013 21:34:37 +0000 (+0100) Subject: Merge branch 'master' into notes X-Git-Tag: live~5104^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7f598ab412674ce5a78da98c54aa2fe2e4a05792?hp=-c Merge branch 'master' into notes Conflicts: Gemfile.lock app/views/diary_entry/list.html.erb --- 7f598ab412674ce5a78da98c54aa2fe2e4a05792 diff --combined Gemfile.lock index 7679a6ccb,c9bd6607c..5a7a2bba8 --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -67,11 -67,6 +67,11 @@@ GE railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.7.7) + jsonify (0.3.1) + multi_json (~> 1.0) + jsonify-rails (0.3.2) + actionpack + jsonify (< 0.4.0) jwt (0.1.8) multi_json (>= 1.5) libv8 (3.3.10.4) @@@ -81,7 -76,7 +81,7 @@@ mime-types (~> 1.16) treetop (~> 1.4.8) memcached (1.5.0) - mime-types (1.21) + mime-types (1.22) minitest (4.7.0) multi_json (1.7.2) multi_xml (0.5.3) @@@ -159,7 -154,7 +159,7 @@@ tilt (~> 1.1, != 1.3.0) therubyracer (0.10.2) libv8 (~> 3.3.10) - thor (0.18.0) + thor (0.18.1) tilt (1.3.6) timecop (0.6.1) treetop (1.4.12) @@@ -188,7 -183,6 +188,7 @@@ DEPENDENCIE i18n-js (>= 3.0.0.rc2) iconv (= 0.1) jquery-rails + jsonify-rails libxml-ruby (>= 2.0.5) memcached (>= 1.4.1) minitest diff --combined app/controllers/application_controller.rb index 3c7dba984,e5a2b3540..067fc6a51 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@@ -55,10 -55,6 +55,10 @@@ class ApplicationController < ActionCon end end + def require_oauth + @oauth = @user.access_token(OAUTH_KEY) if @user and defined? OAUTH_KEY + end + ## # requires the user to be logged in by the token or HTTP methods, or have an # OAuth token with the right capability. this method is a bit of a pain to call @@@ -116,9 -112,6 +116,9 @@@ def require_allow_write_gpx require_capability(:allow_write_gpx) end + def require_allow_write_notes + require_capability(:allow_write_notes) + end ## # require that the user is a moderator, or fill out a helpful error message @@@ -213,20 -206,49 +213,49 @@@ end def check_api_readable - if STATUS == :database_offline or STATUS == :api_offline + if api_status == :offline report_error "Database offline for maintenance", :service_unavailable return false end end def check_api_writable - if STATUS == :database_offline or STATUS == :database_readonly or - STATUS == :api_offline or STATUS == :api_readonly + unless api_status == :online report_error "Database offline for maintenance", :service_unavailable return false end end + def database_status + if STATUS == :database_offline + :offline + elsif STATUS == :database_readonly + :readonly + else + :online + end + end + + def api_status + status = database_status + if status == :online + if STATUS == :api_offline + status = :offline + elsif STATUS == :api_readonly + status = :readonly + end + end + return status + end + + def gpx_status + status = database_status + if status == :online + status = :offline if STATUS == :gpx_offline + end + return status + end + def require_public_data unless @user.data_public? report_error "You must make your edits public to upload new data", :forbidden