Merge pull request #1660 from consul/fix/rubocop_issues
Fix some Rubocop issues
This commit is contained in:
@@ -30,15 +30,17 @@ class Legislation::AnnotationsController < ApplicationController
|
||||
|
||||
def create
|
||||
if !@process.allegations_phase.open? || @draft_version.final_version?
|
||||
render json: {}, status: :not_found and return
|
||||
render(json: {}, status: :not_found) && (return)
|
||||
end
|
||||
|
||||
existing_annotation = @draft_version.annotations.where(
|
||||
range_start: annotation_params[:ranges].first[:start], range_start_offset: annotation_params[:ranges].first[:startOffset].to_i,
|
||||
range_end: annotation_params[:ranges].first[:end], range_end_offset: annotation_params[:ranges].first[:endOffset].to_i).first
|
||||
|
||||
if @annotation = existing_annotation
|
||||
if comment = @annotation.comments.create(body: annotation_params[:text], user: current_user)
|
||||
@annotation = existing_annotation
|
||||
if @annotation.present?
|
||||
comment = @annotation.comments.create(body: annotation_params[:text], user: current_user)
|
||||
if comment.present?
|
||||
render json: @annotation.to_json
|
||||
else
|
||||
render json: comment.errors.full_messages, status: :unprocessable_entity
|
||||
|
||||
@@ -8,7 +8,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version = @process.draft_versions.published.last
|
||||
draft_version = @process.draft_versions.published.last
|
||||
|
||||
if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version.present?
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
elsif @process.debate_phase.enabled?
|
||||
redirect_to legislation_process_debate_path(@process)
|
||||
@@ -33,7 +35,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
@phase = :draft_publication
|
||||
|
||||
if @process.draft_publication.started?
|
||||
if draft_version = @process.draft_versions.published.last
|
||||
draft_version = @process.draft_versions.published.last
|
||||
|
||||
if draft_version.present?
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
else
|
||||
render :phase_empty
|
||||
@@ -48,7 +52,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
@phase = :allegations_phase
|
||||
|
||||
if @process.allegations_phase.started?
|
||||
if draft_version = @process.draft_versions.published.last
|
||||
draft_version = @process.draft_versions.published.last
|
||||
|
||||
if draft_version.present?
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
else
|
||||
render :phase_empty
|
||||
@@ -63,7 +69,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
@phase = :result_publication
|
||||
|
||||
if @process.result_publication.started?
|
||||
if final_version = @process.final_draft_version
|
||||
final_version = @process.final_draft_version
|
||||
|
||||
if final_version.present?
|
||||
redirect_to legislation_process_draft_version_path(@process, final_version)
|
||||
else
|
||||
render :phase_empty
|
||||
|
||||
@@ -37,9 +37,8 @@ class Management::SessionsController < ActionController::Base
|
||||
end
|
||||
|
||||
def authenticated_manager?
|
||||
if manager = ManagerAuthenticator.new(params).auth
|
||||
session[:manager] = manager
|
||||
end
|
||||
manager = ManagerAuthenticator.new(params).auth
|
||||
session[:manager] = manager if manager.present?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,9 @@ class PagesController < ApplicationController
|
||||
skip_authorization_check
|
||||
|
||||
def show
|
||||
if @custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
||||
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
||||
|
||||
if @custom_page.present?
|
||||
render action: :custom_page
|
||||
else
|
||||
render action: params[:id]
|
||||
|
||||
@@ -11,7 +11,7 @@ class Users::SessionsController < Devise::SessionsController
|
||||
end
|
||||
|
||||
def after_sign_out_path_for(resource)
|
||||
request.referrer.present? ? request.referrer : super
|
||||
request.referer.present? ? request.referer : super
|
||||
end
|
||||
|
||||
def verifying_via_email?
|
||||
|
||||
@@ -21,7 +21,7 @@ module EmbedVideosHelper
|
||||
match = link.match(reg_exp)
|
||||
end
|
||||
|
||||
if match and match[2]
|
||||
if match && match[2]
|
||||
'<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>'
|
||||
else
|
||||
''
|
||||
|
||||
@@ -7,12 +7,12 @@ module VerificationHelper
|
||||
end
|
||||
|
||||
def mask_phone(number)
|
||||
match = number.match /\d{3}$/
|
||||
match = number.match(/\d{3}$/)
|
||||
"******#{match}"
|
||||
end
|
||||
|
||||
def mask_email(string)
|
||||
match = string.match /^(\w{1,3})(.*)@(.*)/
|
||||
match = string.match(/^(\w{1,3})(.*)@(.*)/)
|
||||
|
||||
data_to_display = match[1]
|
||||
data_to_mask = match[2]
|
||||
@@ -21,4 +21,4 @@ module VerificationHelper
|
||||
data_to_display + "*"*data_to_mask.size + "@" + email_provider
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,7 +129,7 @@ class Mailer < ApplicationMailer
|
||||
|
||||
def with_user(user, &block)
|
||||
I18n.with_locale(user.locale) do
|
||||
block.call
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ class Notification < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.add(user_id, notifiable)
|
||||
if notification = Notification.find_by(user_id: user_id, notifiable: notifiable)
|
||||
notification = Notification.find_by(user_id: user_id, notifiable: notifiable)
|
||||
|
||||
if notification.present?
|
||||
Notification.increment_counter(:counter, notification.id)
|
||||
else
|
||||
Notification.create!(user_id: user_id, notifiable: notifiable)
|
||||
@@ -50,4 +52,4 @@ class Notification < ActiveRecord::Base
|
||||
notifiable.is_a?(ProposalNotification) ? notifiable.proposal : notifiable
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ class Officing::Residence
|
||||
document_type: document_type).first
|
||||
end
|
||||
|
||||
def residence_in_madrid
|
||||
def residence_in_madrid
|
||||
return if errors.any?
|
||||
|
||||
unless residency_valid?
|
||||
|
||||
@@ -21,9 +21,8 @@ class SiteCustomization::Image < ActiveRecord::Base
|
||||
def self.image_path_for(filename)
|
||||
image_name = filename.split(".").first
|
||||
|
||||
if i = find_by(name: image_name)
|
||||
i.image.exists? ? i.image.url : nil
|
||||
end
|
||||
imageable = find_by(name: image_name)
|
||||
imageable.present? && imageable.image.exists? ? imageable.image.url : nil
|
||||
end
|
||||
|
||||
def required_width
|
||||
|
||||
Reference in New Issue
Block a user