Fix some rubocop rails style issues
This commit is contained in:
parent
2d22ab10f7
commit
dbe165bbb3
61 changed files with 336 additions and 348 deletions
|
@ -38,8 +38,8 @@
|
|||
class AmfController < ApplicationController
|
||||
include Potlatch
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :check_api_writable
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :check_api_writable
|
||||
|
||||
# Main AMF handlers: process the raw AMF string (using AMF library) and
|
||||
# calls each action (private method) accordingly.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class ApiController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :check_api_readable, :except => [:capabilities]
|
||||
before_filter :setup_user_auth, :only => [:permissions]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :check_api_readable, :except => [:capabilities]
|
||||
before_action :setup_user_auth, :only => [:permissions]
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
|
||||
# Get an XML response containing a list of tracepoints that have been uploaded
|
||||
# within the specified bounding box, and in the specified page.
|
||||
|
|
|
@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
protect_from_forgery
|
||||
|
||||
before_filter :fetch_body
|
||||
before_action :fetch_body
|
||||
|
||||
def authorize_web
|
||||
if session[:user]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
class BrowseController < ApplicationController
|
||||
layout :map_layout
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :except => [:query] { |c| c.check_database_readable(true) }
|
||||
before_filter :require_oauth
|
||||
around_filter :web_timeout
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :except => [:query] { |c| c.check_database_readable(true) }
|
||||
before_action :require_oauth
|
||||
around_action :web_timeout
|
||||
|
||||
def relation
|
||||
@type = "relation"
|
||||
|
|
|
@ -4,19 +4,19 @@ class ChangesetController < ApplicationController
|
|||
layout "site"
|
||||
require "xml/libxml"
|
||||
|
||||
skip_before_filter :verify_authenticity_token, :except => [:list]
|
||||
before_filter :authorize_web, :only => [:list, :feed, :comments_feed]
|
||||
before_filter :set_locale, :only => [:list, :feed, :comments_feed]
|
||||
before_filter :authorize, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_filter :require_moderator, :only => [:hide_comment, :unhide_comment]
|
||||
before_filter :require_allow_write_api, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_filter :require_public_data, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe]
|
||||
before_filter :check_api_writable, :only => [:create, :update, :delete, :upload, :include, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_filter :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query, :list, :feed, :comment, :subscribe, :unsubscribe, :comments_feed]
|
||||
before_filter(:only => [:list, :feed, :comments_feed]) { |c| c.check_database_readable(true) }
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :except => [:list, :feed, :comments_feed]
|
||||
around_filter :web_timeout, :only => [:list, :feed, :comments_feed]
|
||||
skip_before_action :verify_authenticity_token, :except => [:list]
|
||||
before_action :authorize_web, :only => [:list, :feed, :comments_feed]
|
||||
before_action :set_locale, :only => [:list, :feed, :comments_feed]
|
||||
before_action :authorize, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_action :require_moderator, :only => [:hide_comment, :unhide_comment]
|
||||
before_action :require_allow_write_api, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_action :require_public_data, :only => [:create, :update, :delete, :upload, :include, :close, :comment, :subscribe, :unsubscribe]
|
||||
before_action :check_api_writable, :only => [:create, :update, :delete, :upload, :include, :comment, :subscribe, :unsubscribe, :hide_comment, :unhide_comment]
|
||||
before_action :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query, :list, :feed, :comment, :subscribe, :unsubscribe, :comments_feed]
|
||||
before_action(:only => [:list, :feed, :comments_feed]) { |c| c.check_database_readable(true) }
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :except => [:list, :feed, :comments_feed]
|
||||
around_action :web_timeout, :only => [:list, :feed, :comments_feed]
|
||||
|
||||
# Helper methods for checking consistency
|
||||
include ConsistencyValidations
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class DiaryEntryController < ApplicationController
|
||||
layout "site", :except => :rss
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user, :only => [:new, :edit, :comment, :hide, :hidecomment]
|
||||
before_filter :lookup_this_user, :only => [:view, :comments]
|
||||
before_filter :check_database_readable
|
||||
before_filter :check_database_writable, :only => [:new, :edit]
|
||||
before_filter :require_administrator, :only => [:hide, :hidecomment]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user, :only => [:new, :edit, :comment, :hide, :hidecomment]
|
||||
before_action :lookup_this_user, :only => [:view, :comments]
|
||||
before_action :check_database_readable
|
||||
before_action :check_database_writable, :only => [:new, :edit]
|
||||
before_action :require_administrator, :only => [:hide, :hidecomment]
|
||||
|
||||
def new
|
||||
@title = t "diary_entry.new.title"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class DirectionsController < ApplicationController
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_oauth, :only => [:search]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_oauth, :only => [:search]
|
||||
|
||||
def search
|
||||
render :layout => map_layout
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class ExportController < ApplicationController
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
|
||||
caches_page :embed
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ class GeocoderController < ApplicationController
|
|||
require "net/http"
|
||||
require "rexml/document"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_oauth, :only => [:search]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_oauth, :only => [:search]
|
||||
|
||||
def search
|
||||
normalize_params
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
class MessageController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user
|
||||
before_filter :lookup_this_user, :only => [:new]
|
||||
before_filter :check_database_readable
|
||||
before_filter :check_database_writable, :only => [:new, :reply, :mark]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user
|
||||
before_action :lookup_this_user, :only => [:new]
|
||||
before_action :check_database_readable
|
||||
before_action :check_database_writable, :only => [:new, :reply, :mark]
|
||||
|
||||
# Allow the user to write a new message to another user. This action also
|
||||
# deals with the sending of that message to the other user when the user
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
class NodeController < ApplicationController
|
||||
require "xml/libxml"
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :authorize, :only => [:create, :update, :delete]
|
||||
before_filter :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_filter :require_public_data, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :authorize, :only => [:create, :update, :delete]
|
||||
before_action :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_action :require_public_data, :only => [:create, :update, :delete]
|
||||
before_action :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_action :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
|
||||
# Create a node from XML.
|
||||
def create
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class NotesController < ApplicationController
|
||||
layout "site", :only => [:mine]
|
||||
|
||||
before_filter :check_api_readable
|
||||
before_filter :authorize_web, :only => [:mine]
|
||||
before_filter :setup_user_auth, :only => [:create, :comment]
|
||||
before_filter :authorize, :only => [:close, :reopen, :destroy]
|
||||
before_filter :require_moderator, :only => [:destroy]
|
||||
before_filter :check_api_writable, :only => [:create, :comment, :close, :reopen, :destroy]
|
||||
before_filter :require_allow_write_notes, :only => [:create, :comment, :close, :reopen, :destroy]
|
||||
before_filter :set_locale
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
before_action :check_api_readable
|
||||
before_action :authorize_web, :only => [:mine]
|
||||
before_action :setup_user_auth, :only => [:create, :comment]
|
||||
before_action :authorize, :only => [:close, :reopen, :destroy]
|
||||
before_action :require_moderator, :only => [:destroy]
|
||||
before_action :check_api_writable, :only => [:create, :comment, :close, :reopen, :destroy]
|
||||
before_action :require_allow_write_notes, :only => [:create, :comment, :close, :reopen, :destroy]
|
||||
before_action :set_locale
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
|
||||
##
|
||||
# Return a list of notes in a given area
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class OauthClientsController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user
|
||||
|
||||
def index
|
||||
@client_applications = @user.client_applications
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
class OldController < ApplicationController
|
||||
require "xml/libxml"
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :setup_user_auth, :only => [:history, :version]
|
||||
before_filter :authorize, :only => [:redact]
|
||||
before_filter :authorize_moderator, :only => [:redact]
|
||||
before_filter :require_allow_write_api, :only => [:redact]
|
||||
before_filter :check_api_readable
|
||||
before_filter :check_api_writable, :only => [:redact]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
before_filter :lookup_old_element, :except => [:history]
|
||||
before_filter :lookup_old_element_versions, :only => [:history]
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :setup_user_auth, :only => [:history, :version]
|
||||
before_action :authorize, :only => [:redact]
|
||||
before_action :authorize_moderator, :only => [:redact]
|
||||
before_action :require_allow_write_api, :only => [:redact]
|
||||
before_action :check_api_readable
|
||||
before_action :check_api_writable, :only => [:redact]
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
before_action :lookup_old_element, :except => [:history]
|
||||
before_action :lookup_old_element_versions, :only => [:history]
|
||||
|
||||
def history
|
||||
# the .where() method used in the lookup_old_element_versions
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class RedactionsController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user, :only => [:new, :create, :edit, :update, :destroy]
|
||||
before_filter :require_moderator, :only => [:new, :create, :edit, :update, :destroy]
|
||||
before_filter :lookup_redaction, :only => [:show, :edit, :update, :destroy]
|
||||
before_filter :check_database_readable
|
||||
before_filter :check_database_writable, :only => [:create, :update, :destroy]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user, :only => [:new, :create, :edit, :update, :destroy]
|
||||
before_action :require_moderator, :only => [:new, :create, :edit, :update, :destroy]
|
||||
before_action :lookup_redaction, :only => [:show, :edit, :update, :destroy]
|
||||
before_action :check_database_readable
|
||||
before_action :check_database_writable, :only => [:create, :update, :destroy]
|
||||
|
||||
def index
|
||||
@redactions = Redaction.order(:id)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class RelationController < ApplicationController
|
||||
require "xml/libxml"
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :authorize, :only => [:create, :update, :delete]
|
||||
before_filter :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_filter :require_public_data, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :authorize, :only => [:create, :update, :delete]
|
||||
before_action :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_action :require_public_data, :only => [:create, :update, :delete]
|
||||
before_action :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_action :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
|
||||
def create
|
||||
assert_method :put
|
||||
|
|
|
@ -2,8 +2,8 @@ class SearchController < ApplicationController
|
|||
# Support searching for nodes, ways, or all
|
||||
# Can search by tag k, v, or both (type->k,value->v)
|
||||
# Can search by name (k=name,v=....)
|
||||
skip_before_filter :verify_authenticity_token
|
||||
after_filter :compress_output
|
||||
skip_before_action :verify_authenticity_token
|
||||
after_action :compress_output
|
||||
|
||||
def search_all
|
||||
do_search(true, true, true)
|
||||
|
|
|
@ -2,12 +2,12 @@ class SiteController < ApplicationController
|
|||
layout "site"
|
||||
layout :map_layout, :only => [:index, :export]
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :redirect_browse_params, :only => :index
|
||||
before_filter :redirect_map_params, :only => [:index, :edit, :export]
|
||||
before_filter :require_user, :only => [:welcome]
|
||||
before_filter :require_oauth, :only => [:index]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :redirect_browse_params, :only => :index
|
||||
before_action :redirect_map_params, :only => [:index, :edit, :export]
|
||||
before_action :require_user, :only => [:welcome]
|
||||
before_action :require_oauth, :only => [:index]
|
||||
|
||||
def index
|
||||
unless STATUS == :database_readonly || STATUS == :database_offline
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class SwfController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :check_api_readable
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :check_api_readable
|
||||
|
||||
# to log:
|
||||
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
class TraceController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
skip_before_filter :verify_authenticity_token, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user, :only => [:mine, :create, :edit, :delete]
|
||||
before_filter :authorize, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
before_filter :check_database_readable, :except => [:api_read, :api_data]
|
||||
before_filter :check_database_writable, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
|
||||
before_filter :check_api_readable, :only => [:api_read, :api_data]
|
||||
before_filter :check_api_writable, :only => [:api_create, :api_update, :api_delete]
|
||||
before_filter :require_allow_read_gpx, :only => [:api_read, :api_data]
|
||||
before_filter :require_allow_write_gpx, :only => [:api_create, :api_update, :api_delete]
|
||||
before_filter :offline_warning, :only => [:mine, :view]
|
||||
before_filter :offline_redirect, :only => [:create, :edit, :delete, :data, :api_create, :api_delete, :api_data]
|
||||
around_filter :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
skip_before_action :verify_authenticity_token, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user, :only => [:mine, :create, :edit, :delete]
|
||||
before_action :authorize, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
before_action :check_database_readable, :except => [:api_read, :api_data]
|
||||
before_action :check_database_writable, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
|
||||
before_action :check_api_readable, :only => [:api_read, :api_data]
|
||||
before_action :check_api_writable, :only => [:api_create, :api_update, :api_delete]
|
||||
before_action :require_allow_read_gpx, :only => [:api_read, :api_data]
|
||||
before_action :require_allow_write_gpx, :only => [:api_create, :api_update, :api_delete]
|
||||
before_action :offline_warning, :only => [:mine, :view]
|
||||
before_action :offline_redirect, :only => [:create, :edit, :delete, :data, :api_create, :api_delete, :api_data]
|
||||
around_action :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
|
||||
|
||||
# Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
|
||||
# target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
class UserBlocksController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter :require_user, :only => [:new, :create, :edit, :update, :revoke]
|
||||
before_filter :require_moderator, :only => [:new, :create, :edit, :update, :revoke]
|
||||
before_filter :lookup_this_user, :only => [:new, :create, :blocks_on, :blocks_by]
|
||||
before_filter :lookup_user_block, :only => [:show, :edit, :update, :revoke]
|
||||
before_filter :require_valid_params, :only => [:create, :update]
|
||||
before_filter :check_database_readable
|
||||
before_filter :check_database_writable, :only => [:create, :update, :revoke]
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :require_user, :only => [:new, :create, :edit, :update, :revoke]
|
||||
before_action :require_moderator, :only => [:new, :create, :edit, :update, :revoke]
|
||||
before_action :lookup_this_user, :only => [:new, :create, :blocks_on, :blocks_by]
|
||||
before_action :lookup_user_block, :only => [:show, :edit, :update, :revoke]
|
||||
before_action :require_valid_params, :only => [:create, :update]
|
||||
before_action :check_database_readable
|
||||
before_action :check_database_writable, :only => [:create, :update, :revoke]
|
||||
|
||||
def index
|
||||
@user_blocks_pages, @user_blocks = paginate(:user_blocks,
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
class UserController < ApplicationController
|
||||
layout "site", :except => [:api_details]
|
||||
|
||||
skip_before_filter :verify_authenticity_token, :only => [:api_read, :api_details, :api_gpx_files, :auth_success]
|
||||
before_filter :disable_terms_redirect, :only => [:terms, :save, :logout, :api_details]
|
||||
before_filter :authorize, :only => [:api_details, :api_gpx_files]
|
||||
before_filter :authorize_web, :except => [:api_read, :api_details, :api_gpx_files]
|
||||
before_filter :set_locale, :except => [:api_read, :api_details, :api_gpx_files]
|
||||
before_filter :require_user, :only => [:account, :go_public, :make_friend, :remove_friend]
|
||||
before_filter :require_self, :only => [:account]
|
||||
before_filter :check_database_readable, :except => [:login, :api_read, :api_details, :api_gpx_files]
|
||||
before_filter :check_database_writable, :only => [:new, :account, :confirm, :confirm_email, :lost_password, :reset_password, :go_public, :make_friend, :remove_friend]
|
||||
before_filter :check_api_readable, :only => [:api_read, :api_details, :api_gpx_files]
|
||||
before_filter :require_allow_read_prefs, :only => [:api_details]
|
||||
before_filter :require_allow_read_gpx, :only => [:api_gpx_files]
|
||||
before_filter :require_cookies, :only => [:new, :login, :confirm]
|
||||
before_filter :require_administrator, :only => [:set_status, :delete, :list]
|
||||
around_filter :api_call_handle_error, :only => [:api_read, :api_details, :api_gpx_files]
|
||||
before_filter :lookup_user_by_id, :only => [:api_read]
|
||||
before_filter :lookup_user_by_name, :only => [:set_status, :delete]
|
||||
skip_before_action :verify_authenticity_token, :only => [:api_read, :api_details, :api_gpx_files, :auth_success]
|
||||
before_action :disable_terms_redirect, :only => [:terms, :save, :logout, :api_details]
|
||||
before_action :authorize, :only => [:api_details, :api_gpx_files]
|
||||
before_action :authorize_web, :except => [:api_read, :api_details, :api_gpx_files]
|
||||
before_action :set_locale, :except => [:api_read, :api_details, :api_gpx_files]
|
||||
before_action :require_user, :only => [:account, :go_public, :make_friend, :remove_friend]
|
||||
before_action :require_self, :only => [:account]
|
||||
before_action :check_database_readable, :except => [:login, :api_read, :api_details, :api_gpx_files]
|
||||
before_action :check_database_writable, :only => [:new, :account, :confirm, :confirm_email, :lost_password, :reset_password, :go_public, :make_friend, :remove_friend]
|
||||
before_action :check_api_readable, :only => [:api_read, :api_details, :api_gpx_files]
|
||||
before_action :require_allow_read_prefs, :only => [:api_details]
|
||||
before_action :require_allow_read_gpx, :only => [:api_gpx_files]
|
||||
before_action :require_cookies, :only => [:new, :login, :confirm]
|
||||
before_action :require_administrator, :only => [:set_status, :delete, :list]
|
||||
around_action :api_call_handle_error, :only => [:api_read, :api_details, :api_gpx_files]
|
||||
before_action :lookup_user_by_id, :only => [:api_read]
|
||||
before_action :lookup_user_by_name, :only => [:set_status, :delete]
|
||||
|
||||
def terms
|
||||
@legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || DEFAULT_LEGALE
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Update and read user preferences, which are arbitrayr key/val pairs
|
||||
class UserPreferenceController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :authorize
|
||||
before_filter :require_allow_read_prefs, :only => [:read_one, :read]
|
||||
before_filter :require_allow_write_prefs, :except => [:read_one, :read]
|
||||
around_filter :api_call_handle_error
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :authorize
|
||||
before_action :require_allow_read_prefs, :only => [:read_one, :read]
|
||||
before_action :require_allow_write_prefs, :except => [:read_one, :read]
|
||||
around_action :api_call_handle_error
|
||||
|
||||
##
|
||||
# return all the preferences as an XML document
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class UserRolesController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :require_user
|
||||
before_filter :lookup_this_user
|
||||
before_filter :require_administrator
|
||||
before_filter :require_valid_role
|
||||
before_filter :not_in_role, :only => [:grant]
|
||||
before_filter :in_role, :only => [:revoke]
|
||||
before_action :authorize_web
|
||||
before_action :require_user
|
||||
before_action :lookup_this_user
|
||||
before_action :require_administrator
|
||||
before_action :require_valid_role
|
||||
before_action :not_in_role, :only => [:grant]
|
||||
before_action :in_role, :only => [:revoke]
|
||||
|
||||
def grant
|
||||
@this_user.roles.create(:role => @role, :granter_id => @user.id)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class WayController < ApplicationController
|
||||
require "xml/libxml"
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_filter :authorize, :only => [:create, :update, :delete]
|
||||
before_filter :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_filter :require_public_data, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_filter :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error, :api_call_timeout
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :authorize, :only => [:create, :update, :delete]
|
||||
before_action :require_allow_write_api, :only => [:create, :update, :delete]
|
||||
before_action :require_public_data, :only => [:create, :update, :delete]
|
||||
before_action :check_api_writable, :only => [:create, :update, :delete]
|
||||
before_action :check_api_readable, :except => [:create, :update, :delete]
|
||||
after_action :compress_output
|
||||
around_action :api_call_handle_error, :api_call_timeout
|
||||
|
||||
def create
|
||||
assert_method :put
|
||||
|
|
|
@ -4,7 +4,7 @@ class AccessToken < OauthToken
|
|||
|
||||
scope :valid, -> { where(:invalidated_at => nil) }
|
||||
|
||||
validates_presence_of :user, :secret
|
||||
validates :user, :secret, :presence => true
|
||||
|
||||
before_create :set_authorized_at
|
||||
|
||||
|
|
|
@ -15,13 +15,16 @@ class Changeset < ActiveRecord::Base
|
|||
has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "ChangesetComment"
|
||||
has_and_belongs_to_many :subscribers, :class_name => "User", :join_table => "changesets_subscribers", :association_foreign_key => "subscriber_id"
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_presence_of :user_id, :created_at, :closed_at, :num_changes
|
||||
validates_uniqueness_of :id
|
||||
validates_numericality_of :id, :on => :update, :integer_only => true
|
||||
validates_numericality_of :min_lat, :max_lat, :min_lon, :max_lat, :allow_nil => true, :integer_only => true
|
||||
validates_numericality_of :user_id, :integer_only => true
|
||||
validates_numericality_of :num_changes, :integer_only => true, :greater_than_or_equal_to => 0
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :user_id, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :num_changes, :presence => true,
|
||||
:numericality => { :integer_only => true,
|
||||
:greater_than_or_equal_to => 0 }
|
||||
validates :created_at, :closed_at, :presence => true
|
||||
validates :min_lat, :max_lat, :min_lon, :max_lat, :allow_nil => true,
|
||||
:numericality => { :integer_only => true }
|
||||
|
||||
before_save :update_closed_at
|
||||
|
||||
|
|
|
@ -2,16 +2,14 @@ class ChangesetComment < ActiveRecord::Base
|
|||
belongs_to :changeset
|
||||
belongs_to :author, :class_name => "User"
|
||||
|
||||
validates_presence_of :id, :on => :update # is it necessary?
|
||||
validates_uniqueness_of :id
|
||||
validates_presence_of :changeset
|
||||
validates_associated :changeset
|
||||
validates_presence_of :author
|
||||
validates_associated :author
|
||||
validates :visible, :inclusion => { :in => [true, false] }
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :changeset, :presence => true, :associated => true
|
||||
validates :author, :presence => true, :associated => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
# Return the comment text
|
||||
def body
|
||||
RichText.new("text", read_attribute(:body))
|
||||
RichText.new("text", self[:body])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,7 @@ class ChangesetTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :changeset
|
||||
|
||||
validates_presence_of :changeset
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => :changeset_id
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :changeset, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => :changeset_id }
|
||||
end
|
||||
|
|
|
@ -7,11 +7,10 @@ class ClientApplication < ActiveRecord::Base
|
|||
has_many :oauth2_verifiers
|
||||
has_many :oauth_tokens
|
||||
|
||||
validates_presence_of :name, :url, :key, :secret
|
||||
validates_uniqueness_of :key
|
||||
validates_format_of :url, :with => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
|
||||
validates_format_of :support_url, :with => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i, :allow_blank => true
|
||||
validates_format_of :callback_url, :with => %r{\A[a-z][a-z0-9.+-]*://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i, :allow_blank => true
|
||||
validates :key, :presence => true, :uniqueness => true
|
||||
validates :name, :url, :secret, :presence => true
|
||||
validates :url, :format => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
|
||||
validates :support_url, :callback_url, :allow_blank => true, :format => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
|
||||
|
||||
before_validation :generate_keys, :on => :create
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ class DiaryComment < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :diary_entry
|
||||
|
||||
validates_presence_of :body
|
||||
validates_associated :diary_entry
|
||||
validates :body, :presence => true
|
||||
validates :diary_entry, :user, :associated => true
|
||||
|
||||
after_save :spam_check
|
||||
|
||||
def body
|
||||
RichText.new(read_attribute(:body_format), read_attribute(:body))
|
||||
RichText.new(self[:body_format], self[:body])
|
||||
end
|
||||
|
||||
def digest
|
||||
|
|
|
@ -7,19 +7,20 @@ class DiaryEntry < ActiveRecord::Base
|
|||
|
||||
scope :visible, -> { where(:visible => true) }
|
||||
|
||||
validates_presence_of :title, :body
|
||||
validates_length_of :title, :within => 1..255
|
||||
# validates_length_of :language, :within => 2..5, :allow_nil => false
|
||||
validates_numericality_of :latitude, :allow_nil => true,
|
||||
:greater_than_or_equal_to => -90, :less_than_or_equal_to => 90
|
||||
validates_numericality_of :longitude, :allow_nil => true,
|
||||
:greater_than_or_equal_to => -180, :less_than_or_equal_to => 180
|
||||
validates_associated :language
|
||||
validates :title, :body, :presence => true
|
||||
validates :title, :length => 1..255
|
||||
validates :latitude, :allow_nil => true,
|
||||
:numericality => { :greater_than_or_equal_to => -90,
|
||||
:less_than_or_equal_to => 90 }
|
||||
validates :longitude, :allow_nil => true,
|
||||
:numericality => { :greater_than_or_equal_to => -180,
|
||||
:less_than_or_equal_to => 180 }
|
||||
validates :language, :user, :associated => true
|
||||
|
||||
after_save :spam_check
|
||||
|
||||
def body
|
||||
RichText.new(read_attribute(:body_format), read_attribute(:body))
|
||||
RichText.new(self[:body_format], self[:body])
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -4,10 +4,8 @@ class Message < ActiveRecord::Base
|
|||
belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id
|
||||
belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
|
||||
|
||||
validates_presence_of :title, :body, :sent_on, :sender, :recipient
|
||||
validates_length_of :title, :within => 1..255
|
||||
validates_inclusion_of :message_read, :in => [true, false]
|
||||
validates_as_utf8 :title
|
||||
validates :title, :presence => true, :utf8 => true, :length => 1..255
|
||||
validates :body, :sent_on, :sender, :recipient, :presence => true
|
||||
|
||||
def self.from_mail(mail, from, to)
|
||||
if mail.multipart?
|
||||
|
@ -33,7 +31,7 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def body
|
||||
RichText.new(read_attribute(:body_format), read_attribute(:body))
|
||||
RichText.new(self[:body_format], self[:body])
|
||||
end
|
||||
|
||||
def digest
|
||||
|
|
|
@ -23,14 +23,21 @@ class Node < ActiveRecord::Base
|
|||
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
|
||||
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_presence_of :timestamp, :version, :changeset_id
|
||||
validates_uniqueness_of :id
|
||||
validates_inclusion_of :visible, :in => [true, false]
|
||||
validates_numericality_of :latitude, :longitude, :changeset_id, :version, :integer_only => true
|
||||
validates_numericality_of :id, :on => :update, :integer_only => true
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :version, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :changeset_id, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :latitude, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :longitude, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :timestamp, :presence => true
|
||||
validates :changeset, :associated => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
validate :validate_position
|
||||
validates_associated :changeset
|
||||
|
||||
scope :visible, -> { where(:visible => true) }
|
||||
scope :invisible, -> { where(:visible => false) }
|
||||
|
|
|
@ -4,8 +4,7 @@ class NodeTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :node
|
||||
|
||||
validates_presence_of :node
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => :node_id
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :node, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => :node_id }
|
||||
end
|
||||
|
|
|
@ -3,12 +3,12 @@ class Note < ActiveRecord::Base
|
|||
|
||||
has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
|
||||
|
||||
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 :closed_at if :status == "closed"
|
||||
validates_inclusion_of :status, :in => %w(open closed hidden)
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :latitude, :longitude, :numericality => { :only_integer => true }
|
||||
validates :closed_at, :presence => true, :if => proc { :status == "closed" }
|
||||
validates :status, :inclusion => %w(open closed hidden)
|
||||
|
||||
validate :validate_position
|
||||
|
||||
scope :visible, -> { where("status != 'hidden'") }
|
||||
|
|
|
@ -2,17 +2,16 @@ class NoteComment < ActiveRecord::Base
|
|||
belongs_to :note, :foreign_key => :note_id, :touch => true
|
||||
belongs_to :author, :class_name => "User", :foreign_key => :author_id
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_uniqueness_of :id
|
||||
validates_presence_of :note_id
|
||||
validates_associated :note
|
||||
validates_presence_of :visible
|
||||
validates_associated :author
|
||||
validates_inclusion_of :event, :in => %w(opened closed reopened commented hidden)
|
||||
validates_format_of :body, :with => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :note, :presence => true, :associated => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
validates :author, :associated => true
|
||||
validates :event, :inclusion => %w(opened closed reopened commented hidden)
|
||||
validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
|
||||
|
||||
# Return the comment text
|
||||
def body
|
||||
RichText.new("text", read_attribute(:body))
|
||||
RichText.new("text", self[:body])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Oauth2Verifier < OauthToken
|
||||
validates_presence_of :user
|
||||
validates :user, :presence => true, :associated => true
|
||||
|
||||
attr_accessor :state
|
||||
|
||||
def exchange!(_params = {})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
|
||||
# Thus you can use the same nonce with a different timestamp and viceversa.
|
||||
class OauthNonce < ActiveRecord::Base
|
||||
validates_presence_of :nonce, :timestamp
|
||||
validates_uniqueness_of :nonce, :scope => :timestamp
|
||||
validates :timestamp, :presence => true
|
||||
validates :nonce, :presence => true, :uniqueness => { :scope => :timestamp }
|
||||
|
||||
# Remembers a nonce and it's associated timestamp. It returns false if it has already been used
|
||||
def self.remember(nonce, timestamp)
|
||||
|
|
|
@ -4,8 +4,9 @@ class OauthToken < ActiveRecord::Base
|
|||
|
||||
scope :authorized, -> { where("authorized_at IS NOT NULL and invalidated_at IS NULL") }
|
||||
|
||||
validates_uniqueness_of :token
|
||||
validates_presence_of :client_application, :token
|
||||
validates :token, :presence => true, :uniqueness => true
|
||||
validates :user, :associated => true
|
||||
validates :client_application, :presence => true
|
||||
|
||||
before_validation :generate_keys, :on => :create
|
||||
|
||||
|
|
|
@ -10,11 +10,15 @@ class OldNode < ActiveRecord::Base
|
|||
# the queries generated by Redactable will use the wrong table name.
|
||||
include Redactable
|
||||
|
||||
validates_presence_of :changeset_id, :timestamp
|
||||
validates_inclusion_of :visible, :in => [true, false]
|
||||
validates_numericality_of :latitude, :longitude
|
||||
validates :changeset, :presence => true, :associated => true
|
||||
validates :latitude, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :longitude, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :timestamp, :presence => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
validate :validate_position
|
||||
validates_associated :changeset
|
||||
|
||||
belongs_to :changeset
|
||||
belongs_to :redaction
|
||||
|
|
|
@ -4,8 +4,7 @@ class OldNodeTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :old_node, :foreign_key => [:node_id, :version]
|
||||
|
||||
validates_presence_of :old_node
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => [:node_id, :version]
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :old_node, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => [:node_id, :version] }
|
||||
end
|
||||
|
|
|
@ -16,7 +16,9 @@ class OldRelation < ActiveRecord::Base
|
|||
has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version]
|
||||
has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version]
|
||||
|
||||
validates_associated :changeset
|
||||
validates :changeset, :presence => true, :associated => true
|
||||
validates :timestamp, :presence => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
def self.from_relation(relation)
|
||||
old_relation = OldRelation.new
|
||||
|
|
|
@ -4,8 +4,7 @@ class OldRelationTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :old_relation, :foreign_key => [:relation_id, :version]
|
||||
|
||||
validates_presence_of :old_relation
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => [:relation_id, :version]
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :old_relation, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => [:relation_id, :version] }
|
||||
end
|
||||
|
|
|
@ -16,7 +16,9 @@ class OldWay < ActiveRecord::Base
|
|||
has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version]
|
||||
has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version]
|
||||
|
||||
validates_associated :changeset
|
||||
validates :changeset, :presence => true, :associated => true
|
||||
validates :timestamp, :presence => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
def self.from_way(way)
|
||||
old_way = OldWay.new
|
||||
|
|
|
@ -4,8 +4,7 @@ class OldWayTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :old_way, :foreign_key => [:way_id, :version]
|
||||
|
||||
validates_presence_of :old_way
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => [:way_id, :version]
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :old_way, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => [:way_id, :version] }
|
||||
end
|
||||
|
|
|
@ -17,6 +17,6 @@ class Redaction < ActiveRecord::Base
|
|||
# this method overrides the AR default to provide the rich
|
||||
# text object for the description field.
|
||||
def description
|
||||
RichText.new(read_attribute(:description_format), read_attribute(:description))
|
||||
RichText.new(self[:description_format], self[:description])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,13 +17,15 @@ class Relation < ActiveRecord::Base
|
|||
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
|
||||
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_presence_of :timestamp, :version, :changeset_id
|
||||
validates_uniqueness_of :id
|
||||
validates_inclusion_of :visible, :in => [true, false]
|
||||
validates_numericality_of :id, :on => :update, :integer_only => true
|
||||
validates_numericality_of :changeset_id, :version, :integer_only => true
|
||||
validates_associated :changeset
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :version, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :changeset_id, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :timestamp, :presence => true
|
||||
validates :changeset, :associated => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
scope :visible, -> { where(:visible => true) }
|
||||
scope :invisible, -> { where(:visible => false) }
|
||||
|
|
|
@ -4,8 +4,7 @@ class RelationTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :relation
|
||||
|
||||
validates_presence_of :relation
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => :relation_id
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :relation, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => :relation_id }
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ class RequestToken < OauthToken
|
|||
params = { :user => user, :client_application => client_application }
|
||||
# copy the permissions from the authorised request token to the access token
|
||||
client_application.permissions.each do |p|
|
||||
params[p] = read_attribute(p)
|
||||
params[p] = self[p]
|
||||
end
|
||||
|
||||
access_token = AccessToken.create(params)
|
||||
|
|
|
@ -10,13 +10,11 @@ class Trace < ActiveRecord::Base
|
|||
scope :visible_to_all, -> { where(:visibility => %w(public identifiable)) }
|
||||
scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
|
||||
|
||||
validates_presence_of :user_id, :name, :timestamp
|
||||
validates_presence_of :description, :on => :create
|
||||
validates_length_of :name, :maximum => 255
|
||||
validates_length_of :description, :maximum => 255
|
||||
# validates_numericality_of :latitude, :longitude
|
||||
validates_inclusion_of :inserted, :in => [true, false]
|
||||
validates_inclusion_of :visibility, :in => %w(private public trackable identifiable)
|
||||
validates :user, :presence => true, :associated => true
|
||||
validates :name, :presence => true, :length => 1..255
|
||||
validates :description, :presence => { :on => :create }, :length => 1..255
|
||||
validates :timestamp, :presence => true
|
||||
validates :visibility, :inclusion => %w(private public trackable identifiable)
|
||||
|
||||
def destroy
|
||||
super
|
||||
|
|
|
@ -3,11 +3,10 @@ class Tracepoint < ActiveRecord::Base
|
|||
|
||||
self.table_name = "gps_points"
|
||||
|
||||
validates_numericality_of :trackid, :only_integer => true
|
||||
validates_numericality_of :latitude, :only_integer => true
|
||||
validates_numericality_of :longitude, :only_integer => true
|
||||
validates_associated :trace
|
||||
validates_presence_of :timestamp
|
||||
validates :trackid, :numericality => { :only_integer => true }
|
||||
validates :latitude, :longitude, :numericality => { :only_integer => true }
|
||||
validates :trace, :associated => true
|
||||
validates :timestamp, :presence => true
|
||||
|
||||
belongs_to :trace, :foreign_key => "gpx_id"
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class Tracetag < ActiveRecord::Base
|
||||
self.table_name = "gpx_file_tags"
|
||||
|
||||
validates_format_of :tag, :with => /\A[^\/;.,?]*\z/
|
||||
validates_length_of :tag, :within => 1..255
|
||||
|
||||
belongs_to :trace, :foreign_key => "gpx_id"
|
||||
|
||||
validates :trace, :presence => true, :associated => true
|
||||
validates :tag, :length => 1..255, :format => /\A[^\/;.,?]*\z/
|
||||
end
|
||||
|
|
|
@ -34,24 +34,27 @@ class User < ActiveRecord::Base
|
|||
:default_url => "/assets/:class/:attachment/:style.png",
|
||||
:styles => { :large => "100x100>", :small => "50x50>" }
|
||||
|
||||
validates_presence_of :email, :display_name
|
||||
validates_confirmation_of :email # , :message => ' addresses must match'
|
||||
validates_confirmation_of :pass_crypt # , :message => ' must match the confirmation password'
|
||||
validates_uniqueness_of :display_name, :allow_nil => true, :case_sensitive => false, :if => proc { |u| u.display_name_changed? }
|
||||
validates_uniqueness_of :email, :case_sensitive => false, :if => proc { |u| u.email_changed? }
|
||||
validates_length_of :pass_crypt, :within => 8..255
|
||||
validates_length_of :display_name, :within => 3..255, :allow_nil => true
|
||||
validates :display_name, :presence => true, :allow_nil => true, :length => 3..255,
|
||||
:exclusion => %w(new terms save confirm confirm-email go_public reset-password forgot-password suspended)
|
||||
validates :display_name, :if => proc { |u| u.display_name_changed? },
|
||||
:uniqueness => { :case_sensitive => false }
|
||||
validates :display_name, :if => proc { |u| u.display_name_changed? },
|
||||
:format => { :with => /\A[^\x00-\x1f\x7f\ufffe\uffff\/;.,?%#]*\z/ }
|
||||
validates :display_name, :if => proc { |u| u.display_name_changed? },
|
||||
:format => { :with => /\A\S/, :message => "has leading whitespace" }
|
||||
validates :display_name, :if => proc { |u| u.display_name_changed? },
|
||||
:format => { :with => /\S\z/, :message => "has trailing whitespace" }
|
||||
validates :email, :presence => true, :confirmation => true
|
||||
validates :email, :if => proc { |u| u.email_changed? },
|
||||
:uniqueness => { :case_sensitive => false }
|
||||
validates :pass_crypt, :confirmation => true, :length => 8..255
|
||||
validates :home_lat, :home_lon, :allow_nil => true, :numericality => true
|
||||
validates :home_zoom, :allow_nil => true, :numericality => { :only_integer => true }
|
||||
validates :preferred_editor, :inclusion => Editors::ALL_EDITORS, :allow_nil => true
|
||||
validates :image, :attachment_content_type => { :content_type => /\Aimage\/.*\Z/ }
|
||||
|
||||
validates_email_format_of :email, :if => proc { |u| u.email_changed? }
|
||||
validates_email_format_of :new_email, :allow_blank => true, :if => proc { |u| u.new_email_changed? }
|
||||
validates_format_of :display_name, :with => /\A[^\x00-\x1f\x7f\ufffe\uffff\/;.,?%#]*\z/, :if => proc { |u| u.display_name_changed? }
|
||||
validates_format_of :display_name, :with => /\A\S/, :message => "has leading whitespace", :if => proc { |u| u.display_name_changed? }
|
||||
validates_format_of :display_name, :with => /\S\z/, :message => "has trailing whitespace", :if => proc { |u| u.display_name_changed? }
|
||||
validates_exclusion_of :display_name, :in => %w(new terms save confirm confirm-email go_public reset-password forgot-password suspended)
|
||||
validates_numericality_of :home_lat, :allow_nil => true
|
||||
validates_numericality_of :home_lon, :allow_nil => true
|
||||
validates_numericality_of :home_zoom, :only_integer => true, :allow_nil => true
|
||||
validates_inclusion_of :preferred_editor, :in => Editors::ALL_EDITORS, :allow_nil => true
|
||||
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
|
||||
|
||||
after_initialize :set_defaults
|
||||
before_save :encrypt_password
|
||||
|
@ -113,15 +116,15 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def description
|
||||
RichText.new(read_attribute(:description_format), read_attribute(:description))
|
||||
RichText.new(self[:description_format], self[:description])
|
||||
end
|
||||
|
||||
def languages
|
||||
attribute_present?(:languages) ? read_attribute(:languages).split(/ *, */) : []
|
||||
attribute_present?(:languages) ? self[:languages].split(/ *, */) : []
|
||||
end
|
||||
|
||||
def languages=(languages)
|
||||
write_attribute(:languages, languages.join(","))
|
||||
self[:languages] = languages.join(",")
|
||||
end
|
||||
|
||||
def preferred_language
|
||||
|
|
|
@ -16,7 +16,7 @@ class UserBlock < ActiveRecord::Base
|
|||
##
|
||||
# return a renderable version of the reason text.
|
||||
def reason
|
||||
RichText.new(read_attribute(:reason_format), read_attribute(:reason))
|
||||
RichText.new(self[:reason_format], self[:reason])
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -3,8 +3,8 @@ class UserPreference < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
|
||||
validates_length_of :k, :within => 1..255
|
||||
validates_length_of :v, :within => 1..255
|
||||
validates :user, :presence => true, :associated => true
|
||||
validates :k, :v, :length => 1..255
|
||||
|
||||
# Turn this Node in to an XML Node without the <osm> wrapper.
|
||||
def to_xml_node
|
||||
|
|
|
@ -3,6 +3,5 @@ class UserRole < ActiveRecord::Base
|
|||
|
||||
ALL_ROLES = %w(administrator moderator)
|
||||
|
||||
validates_inclusion_of :role, :in => ALL_ROLES
|
||||
validates_uniqueness_of :role, :scope => :user_id
|
||||
validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }
|
||||
end
|
||||
|
|
|
@ -19,13 +19,15 @@ class Way < ActiveRecord::Base
|
|||
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
|
||||
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
|
||||
|
||||
validates_presence_of :id, :on => :update
|
||||
validates_presence_of :changeset_id, :version, :timestamp
|
||||
validates_uniqueness_of :id
|
||||
validates_inclusion_of :visible, :in => [true, false]
|
||||
validates_numericality_of :changeset_id, :version, :integer_only => true
|
||||
validates_numericality_of :id, :on => :update, :integer_only => true
|
||||
validates_associated :changeset
|
||||
validates :id, :uniqueness => true, :presence => { :on => :update },
|
||||
:numericality => { :on => :update, :integer_only => true }
|
||||
validates :version, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :changeset_id, :presence => true,
|
||||
:numericality => { :integer_only => true }
|
||||
validates :timestamp, :presence => true
|
||||
validates :changeset, :associated => true
|
||||
validates :visible, :inclusion => [true, false]
|
||||
|
||||
scope :visible, -> { where(:visible => true) }
|
||||
scope :invisible, -> { where(:visible => false) }
|
||||
|
|
|
@ -4,8 +4,7 @@ class WayTag < ActiveRecord::Base
|
|||
|
||||
belongs_to :way
|
||||
|
||||
validates_presence_of :way
|
||||
validates_length_of :k, :maximum => 255, :allow_blank => true
|
||||
validates_uniqueness_of :k, :scope => :way_id
|
||||
validates_length_of :v, :maximum => 255, :allow_blank => true
|
||||
validates :way, :presence => true, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
|
||||
validates :k, :uniqueness => { :scope => :way_id }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue