mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 03:55:43 +08:00
Use consistent new-style hashes in render calls *twitch*
This commit is contained in:
parent
3d4fb43c73
commit
54c7b1ab63
@ -43,7 +43,7 @@ limit 100
|
|||||||
posts = sql.exec.to_a
|
posts = sql.exec.to_a
|
||||||
|
|
||||||
if posts.length == 0
|
if posts.length == 0
|
||||||
render :json => {users: [], posts: []}
|
render json: {users: [], posts: []}
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,17 +4,17 @@ class DraftController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
seq = params[:sequence] || DraftSequence.current(current_user, params[:draft_key])
|
seq = params[:sequence] || DraftSequence.current(current_user, params[:draft_key])
|
||||||
render :json => {draft: Draft.get(current_user, params[:draft_key], seq), draft_sequence: seq}
|
render json: {draft: Draft.get(current_user, params[:draft_key], seq), draft_sequence: seq}
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
|
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
|
||||||
render :text => 'ok'
|
render text: 'ok'
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
Draft.clear(current_user, params[:draft_key], params[:sequence].to_i)
|
Draft.clear(current_user, params[:draft_key], params[:sequence].to_i)
|
||||||
render :text => 'ok'
|
render text: 'ok'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,16 +17,16 @@ class ExcerptController < ApplicationController
|
|||||||
post = route.has_key?(:post_number) ? topic_posts.last : topic_posts.first
|
post = route.has_key?(:post_number) ? topic_posts.last : topic_posts.first
|
||||||
guardian.ensure_can_see!(post)
|
guardian.ensure_can_see!(post)
|
||||||
|
|
||||||
render :json => post, serializer: PostExcerptSerializer, root: false
|
render json: post, serializer: PostExcerptSerializer, root: false
|
||||||
when 'users'
|
when 'users'
|
||||||
user = User.where(username_lower: route[:username].downcase).first
|
user = User.where(username_lower: route[:username].downcase).first
|
||||||
guardian.ensure_can_see!(user)
|
guardian.ensure_can_see!(user)
|
||||||
render :json => user, serializer: UserExcerptSerializer, root: false
|
render json: user, serializer: UserExcerptSerializer, root: false
|
||||||
when 'list'
|
when 'list'
|
||||||
if route[:action] == 'category'
|
if route[:action] == 'category'
|
||||||
category = Category.where(slug: route[:category]).first
|
category = Category.where(slug: route[:category]).first
|
||||||
guardian.ensure_can_see!(category)
|
guardian.ensure_can_see!(category)
|
||||||
render :json => category, serializer: CategoryExcerptSerializer, root: false
|
render json: category, serializer: CategoryExcerptSerializer, root: false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render nothing: true, status: 404
|
render nothing: true, status: 404
|
||||||
|
@ -6,9 +6,9 @@ class ForumsController < ApplicationController
|
|||||||
|
|
||||||
def status
|
def status
|
||||||
if $shutdown
|
if $shutdown
|
||||||
render :text => 'shutting down', :status => 500
|
render text: 'shutting down', :status => 500
|
||||||
else
|
else
|
||||||
render :text => 'ok'
|
render text: 'ok'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class PostsController < ApplicationController
|
|||||||
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :nothing => true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class SessionController < ApplicationController
|
|||||||
|
|
||||||
# If the site requires user approval and the user is not approved yet
|
# If the site requires user approval and the user is not approved yet
|
||||||
if SiteSetting.must_approve_users? && !@user.approved?
|
if SiteSetting.must_approve_users? && !@user.approved?
|
||||||
render :json => {error: I18n.t("login.not_approved")}
|
render json: {error: I18n.t("login.not_approved")}
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -27,13 +27,13 @@ class SessionController < ApplicationController
|
|||||||
render_serialized(@user, UserSerializer)
|
render_serialized(@user, UserSerializer)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
render :json => {error: I18n.t("login.not_activated"), reason: 'not_activated', sent_to_email: @user.email_logs.where(email_type: 'signup').order('created_at DESC').first.try(:to_address), current_email: @user.email}
|
render json: {error: I18n.t("login.not_activated"), reason: 'not_activated', sent_to_email: @user.email_logs.where(email_type: 'signup').order('created_at DESC').first.try(:to_address), current_email: @user.email}
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render :json => {error: I18n.t("login.incorrect_username_email_or_password")}
|
render json: {error: I18n.t("login.incorrect_username_email_or_password")}
|
||||||
end
|
end
|
||||||
|
|
||||||
def forgot_password
|
def forgot_password
|
||||||
@ -45,7 +45,7 @@ class SessionController < ApplicationController
|
|||||||
Jobs.enqueue(:user_email, type: :forgot_password, user_id: user.id, email_token: email_token.token)
|
Jobs.enqueue(:user_email, type: :forgot_password, user_id: user.id, email_token: email_token.token)
|
||||||
end
|
end
|
||||||
# always render of so we don't leak information
|
# always render of so we don't leak information
|
||||||
render :json => {result: "ok"}
|
render json: {result: "ok"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -2,7 +2,7 @@ class UserActionsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
requires_parameters(:user_id)
|
requires_parameters(:user_id)
|
||||||
per_chunk = 60
|
per_chunk = 60
|
||||||
render :json => UserAction.stream(
|
render json: UserAction.stream(
|
||||||
user_id: params[:user_id].to_i,
|
user_id: params[:user_id].to_i,
|
||||||
offset: params[:offset],
|
offset: params[:offset],
|
||||||
limit: per_chunk,
|
limit: per_chunk,
|
||||||
@ -14,7 +14,7 @@ class UserActionsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
requires_parameters(:id)
|
requires_parameters(:id)
|
||||||
render :json => UserAction.stream_item(params[:id], guardian)
|
render json: UserAction.stream_item(params[:id], guardian)
|
||||||
end
|
end
|
||||||
|
|
||||||
def private_messages
|
def private_messages
|
||||||
|
@ -29,13 +29,13 @@ class Users::OmniauthCallbacksController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json { render :json => @data }
|
format.json { render json: @data }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure
|
def failure
|
||||||
flash[:error] = I18n.t("login.omniauth_error", strategy: params[:strategy].titleize)
|
flash[:error] = I18n.t("login.omniauth_error", strategy: params[:strategy].titleize)
|
||||||
render :layout => 'no_js'
|
render layout: 'no_js'
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_or_sign_on_user_using_twitter(auth_token)
|
def create_or_sign_on_user_using_twitter(auth_token)
|
||||||
|
@ -138,7 +138,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
if params[:password_confirmation] != honeypot_value || params[:challenge] != challenge_value.try(:reverse)
|
if params[:password_confirmation] != honeypot_value || params[:challenge] != challenge_value.try(:reverse)
|
||||||
# Don't give any indication that we caught you in the honeypot
|
# Don't give any indication that we caught you in the honeypot
|
||||||
return render(:json => {success: true, active: false, message: I18n.t("login.activate_email", email: params[:email]) })
|
return render(json: {success: true, active: false, message: I18n.t("login.activate_email", email: params[:email]) })
|
||||||
end
|
end
|
||||||
|
|
||||||
user = User.new
|
user = User.new
|
||||||
@ -196,14 +196,14 @@ class UsersController < ApplicationController
|
|||||||
session[:authentication] = nil
|
session[:authentication] = nil
|
||||||
|
|
||||||
# JSON result
|
# JSON result
|
||||||
render :json => {success: true, active: active_result, message: msg }
|
render json: {success: true, active: active_result, message: msg }
|
||||||
else
|
else
|
||||||
render :json => {success: false, message: I18n.t("login.errors", errors: user.errors.full_messages.join("\n"))}
|
render json: {success: false, message: I18n.t("login.errors", errors: user.errors.full_messages.join("\n"))}
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::StatementInvalid
|
rescue ActiveRecord::StatementInvalid
|
||||||
render :json => {success: false, message: I18n.t("login.something_already_taken")}
|
render json: {success: false, message: I18n.t("login.something_already_taken")}
|
||||||
rescue DiscourseHub::NicknameUnavailable
|
rescue DiscourseHub::NicknameUnavailable
|
||||||
render :json => {success: false, message: I18n.t("login.errors", errors:I18n.t("login.not_available", suggestion: User.suggest_username(params[:username])) )}
|
render json: {success: false, message: I18n.t("login.errors", errors:I18n.t("login.not_available", suggestion: User.suggest_username(params[:username])) )}
|
||||||
rescue RestClient::Forbidden
|
rescue RestClient::Forbidden
|
||||||
render json: {errors: [I18n.t("discourse_hub.access_token_problem")]}
|
render json: {errors: [I18n.t("discourse_hub.access_token_problem")]}
|
||||||
end
|
end
|
||||||
@ -257,7 +257,7 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :layout => 'no_js'
|
render layout: 'no_js'
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_email
|
def change_email
|
||||||
@ -285,7 +285,7 @@ class UsersController < ApplicationController
|
|||||||
else
|
else
|
||||||
flash[:error] = I18n.t('change_email.error')
|
flash[:error] = I18n.t('change_email.error')
|
||||||
end
|
end
|
||||||
render :layout => 'no_js'
|
render layout: 'no_js'
|
||||||
end
|
end
|
||||||
|
|
||||||
def activate_account
|
def activate_account
|
||||||
@ -303,7 +303,7 @@ class UsersController < ApplicationController
|
|||||||
else
|
else
|
||||||
flash[:error] = I18n.t('activation.already_done')
|
flash[:error] = I18n.t('activation.already_done')
|
||||||
end
|
end
|
||||||
render :layout => 'no_js'
|
render layout: 'no_js'
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_activation_email
|
def send_activation_email
|
||||||
|
Loading…
x
Reference in New Issue
Block a user