mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
Merge pull request #361 from ZogStriP/enforce-coding-convention
enforce coding convention
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
class Admin::ExportController < Admin::AdminController
|
||||
def create
|
||||
unless Export.is_export_running? or Import.is_import_running?
|
||||
unless Export.is_export_running? || Import.is_import_running?
|
||||
job_id = Jobs.enqueue( :exporter, user_id: current_user.id )
|
||||
render json: success_json.merge( job_id: job_id )
|
||||
else
|
||||
|
@ -223,7 +223,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def mini_profiler_enabled?
|
||||
defined?(Rack::MiniProfiler) and current_user.try(:admin?)
|
||||
defined?(Rack::MiniProfiler) && current_user.try(:admin?)
|
||||
end
|
||||
|
||||
def authorize_mini_profiler
|
||||
@ -250,8 +250,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def check_xhr
|
||||
unless (controller_name == 'forums' || controller_name == 'user_open_ids')
|
||||
# render 'default/empty' unless ((request.format && request.format.json?) or request.xhr?)
|
||||
raise RenderEmpty.new unless ((request.format && request.format.json?) or request.xhr?)
|
||||
raise RenderEmpty.new unless ((request.format && request.format.json?) || request.xhr?)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ class ClicksController < ApplicationController
|
||||
|
||||
def track
|
||||
requires_parameter(:url)
|
||||
if params[:topic_id].present? or params[:post_id].present?
|
||||
if params[:topic_id].present? || params[:post_id].present?
|
||||
args = {url: params[:url], ip: request.remote_ip}
|
||||
args[:user_id] = current_user.id if current_user.present?
|
||||
args[:post_id] = params[:post_id].to_i if params[:post_id].present?
|
||||
|
@ -12,7 +12,7 @@ class EmailController < ApplicationController
|
||||
@user = User.find_by_temporary_key(params[:key])
|
||||
|
||||
# Don't allow the use of a key while logged in as a different user
|
||||
@user = nil if current_user.present? and (@user != current_user)
|
||||
@user = nil if current_user.present? && (@user != current_user)
|
||||
|
||||
if @user.present?
|
||||
@user.update_column(:email_digests, false)
|
||||
|
@ -10,7 +10,7 @@ class ListController < ApplicationController
|
||||
list_opts = {page: params[:page]}
|
||||
|
||||
# html format means we need to farm exclude from the site options
|
||||
if params[:format].blank? or params[:format] == "html"
|
||||
if params[:format].blank? || params[:format] == "html"
|
||||
#TODO objectify this stuff
|
||||
SiteSetting.top_menu.split('|').each do |f|
|
||||
s = f.split(",")
|
||||
@ -35,7 +35,7 @@ class ListController < ApplicationController
|
||||
list = nil
|
||||
|
||||
# If they choose uncategorized, return topics NOT in a category
|
||||
if params[:category] == Slug.for(SiteSetting.uncategorized_name) or params[:category] == SiteSetting.uncategorized_name
|
||||
if params[:category] == Slug.for(SiteSetting.uncategorized_name) || params[:category] == SiteSetting.uncategorized_name
|
||||
list = query.list_uncategorized
|
||||
else
|
||||
@category = Category.where("slug = ? or id = ?", params[:category], params[:category].to_i).includes(:featured_users).first
|
||||
|
@ -12,7 +12,7 @@ class PostActionsController < ApplicationController
|
||||
|
||||
post_action = PostAction.act(current_user, @post, action.id, params[:message])
|
||||
|
||||
if post_action.blank? or post_action.errors.present?
|
||||
if post_action.blank? || post_action.errors.present?
|
||||
render_json_error(post_action)
|
||||
else
|
||||
# We need to reload or otherwise we are showing the old values on the front end
|
||||
|
@ -15,7 +15,7 @@ class SessionController < ApplicationController
|
||||
if @user.present?
|
||||
|
||||
# If the site requires user approval and the user is not approved yet
|
||||
if SiteSetting.must_approve_users? and !@user.approved?
|
||||
if SiteSetting.must_approve_users? && !@user.approved?
|
||||
render :json => {error: I18n.t("login.not_approved")}
|
||||
return
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ class TopicsController < ApplicationController
|
||||
create_topic_view
|
||||
|
||||
anonymous_etag(@topic_view.topic) do
|
||||
redirect_to_correct_topic and return if slugs_do_not_match
|
||||
redirect_to_correct_topic && return if slugs_do_not_match
|
||||
View.create_for(@topic_view.topic, request.remote_ip, current_user)
|
||||
track_visit_to_topic
|
||||
perform_show_response
|
||||
|
@ -156,7 +156,7 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||
user = user_open_id.user
|
||||
|
||||
# If we have to approve users
|
||||
if SiteSetting.must_approve_users? and !user.approved?
|
||||
if SiteSetting.must_approve_users? && !user.approved?
|
||||
@data = {awaiting_approval: true}
|
||||
else
|
||||
log_on_user(user)
|
||||
@ -222,7 +222,7 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||
user = User.find_by_email(email)
|
||||
|
||||
if user
|
||||
if SiteSetting.must_approve_users? and !user.approved?
|
||||
if SiteSetting.must_approve_users? && !user.approved?
|
||||
@data = {awaiting_approval: true}
|
||||
else
|
||||
log_on_user(user)
|
||||
|
@ -89,7 +89,7 @@ class UsersController < ApplicationController
|
||||
else
|
||||
|
||||
# Contact the Discourse Hub server
|
||||
email_given = (params[:email].present? or current_user.present?)
|
||||
email_given = (params[:email].present? || current_user.present?)
|
||||
available_locally = User.username_available?(params[:username])
|
||||
global_match = false
|
||||
available_globally, suggestion_from_discourse_hub = begin
|
||||
@ -101,9 +101,9 @@ class UsersController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
if available_globally and available_locally
|
||||
if available_globally && available_locally
|
||||
render json: {available: true, global_match: (global_match ? true : false)}
|
||||
elsif available_locally and !available_globally
|
||||
elsif available_locally && !available_globally
|
||||
if email_given
|
||||
# Nickname and email do not match what's registered on the discourse hub.
|
||||
render json: {available: false, global_match: false, suggestion: suggestion_from_discourse_hub}
|
||||
@ -113,7 +113,7 @@ class UsersController < ApplicationController
|
||||
# Don't give a suggestion until we get the email and try to match it with on the discourse hub.
|
||||
render json: {available: false}
|
||||
end
|
||||
elsif available_globally and !available_locally
|
||||
elsif available_globally && !available_locally
|
||||
# Already registered on this site with the matching nickname and email address. Why are you signing up again?
|
||||
render json: {available: false, suggestion: User.suggest_username(params[:username])}
|
||||
else
|
||||
@ -128,7 +128,7 @@ class UsersController < ApplicationController
|
||||
|
||||
def create
|
||||
|
||||
if params[:password_confirmation] != honeypot_value or 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
|
||||
return render(:json => {success: true, active: false, message: I18n.t("login.activate_email", email: params[:email]) })
|
||||
end
|
||||
@ -145,7 +145,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
user.password_required! unless auth
|
||||
|
||||
DiscourseHub.register_nickname( user.username, user.email ) if user.valid? and SiteSetting.call_discourse_hub?
|
||||
DiscourseHub.register_nickname( user.username, user.email ) if user.valid? && SiteSetting.call_discourse_hub?
|
||||
|
||||
if user.save
|
||||
|
||||
@ -174,7 +174,7 @@ class UsersController < ApplicationController
|
||||
TwitterUserInfo.create(:user_id => user.id, :screen_name => auth[:twitter_screen_name], :twitter_user_id => auth[:twitter_user_id])
|
||||
end
|
||||
|
||||
if auth[:facebook].present? and FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil?
|
||||
if auth[:facebook].present? && FacebookUserInfo.find_by_facebook_user_id(auth[:facebook][:facebook_user_id]).nil?
|
||||
FacebookUserInfo.create!(auth[:facebook].merge(user_id: user.id))
|
||||
end
|
||||
|
||||
@ -232,11 +232,11 @@ class UsersController < ApplicationController
|
||||
if @user.blank?
|
||||
flash[:error] = I18n.t('password_reset.no_token')
|
||||
else
|
||||
if request.put? and params[:password].present?
|
||||
if request.put? && params[:password].present?
|
||||
@user.password = params[:password]
|
||||
if @user.save
|
||||
|
||||
if SiteSetting.must_approve_users? and !@user.approved?
|
||||
if SiteSetting.must_approve_users? && !@user.approved?
|
||||
@requires_approval = true
|
||||
flash[:success] = I18n.t('password_reset.success_unapproved')
|
||||
else
|
||||
|
Reference in New Issue
Block a user