cs = Changeset.find(closeid.to_i)
cs.set_closed_time_now
if cs.user_id != user.id
- fail OSM::APIUserChangesetMismatchError.new
+ raise OSM::APIUserChangesetMismatchError.new
elsif closecomment.empty?
cs.save!
else
def getpresets(usertoken, lang) #:doc:
user = getuser(usertoken)
- if user && !user.languages.empty?
- http_accept_language.user_preferred_languages = user.languages
- end
+ langs = if user && !user.languages.empty?
+ Locale.list(user.languages)
+ else
+ Locale.list(http_accept_language.user_preferred_languages)
+ end
- lang = http_accept_language.compatible_language_from(getlocales)
- (real_lang, localised) = getlocalized(lang)
+ lang = getlocales.preferred(langs)
+ (real_lang, localised) = getlocalized(lang.to_s)
# Tell Potlatch what language it's using
localised["__potlatch_locale"] = real_lang
return -1, t("application.setup_user_auth.blocked") if user.blocks.active.exists?
query = Trace.visible_to(user)
- if searchterm.to_i > 0
- query = query.where(:id => searchterm.to_i)
- else
- query = query.where("MATCH(name) AGAINST (?)", searchterm).limit(21)
- end
+ query = if searchterm.to_i > 0
+ query.where(:id => searchterm.to_i)
+ else
+ query.where("MATCH(name) AGAINST (?)", searchterm).limit(21)
+ end
gpxs = query.collect do |gpx|
[gpx.id, gpx.name, gpx.description]
end
# -- Save revised way
- pointlist.collect! do|a|
+ pointlist.collect! do |a|
renumberednodes[a] ? renumberednodes[a] : a
end # renumber nodes
new_way = Way.new
def getuser(token) #:doc:
if token =~ /^(.+)\:(.+)$/
- user = User.authenticate(:username => $1, :password => $2)
+ User.authenticate(:username => $1, :password => $2)
else
- user = User.authenticate(:token => token)
+ User.authenticate(:token => token)
end
- user
end
def getlocales
- Dir.glob("#{Rails.root}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") }
+ @locales ||= Locale.list(Dir.glob("#{Rails.root}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") })
end
##