Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used string interpolation in notes_controller #11489

Merged
merged 7 commits into from
Oct 16, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def create
return
elsif params[:draft] == "true"
token = SecureRandom.urlsafe_base64(16, false)
@node.slug = @node.slug + " token:" + token
@node.slug = "#{@node.slug} token:#{token}"
@node.save!
end

Expand All @@ -153,7 +153,7 @@ def create
if params[:event] == 'on'
@node.add_tag('event', current_user)
@node.add_tag('event:rsvp', current_user)
@node.add_tag('date:' + params[:date], current_user) if params[:date]
@node.add_tag("date:#{params[:date]}", current_user) if params[:date]
end

@node.add_tag('first-time-poster', current_user) if current_user.first_time_poster
Expand Down Expand Up @@ -273,7 +273,7 @@ def update
if request.xhr?
render plain: "#{@node.path(format)}?_=#{Time.now.to_i}"
else
redirect_to URI.parse(@node.path(format)).path + '?_=' + Time.now.to_i.to_s
redirect_to "#{URI.parse(@node.path(format)).path}?_=#{Time.now.to_i}"
end
else
flash[:error] = I18n.t('notes_controller.edit_not_saved')
Expand Down Expand Up @@ -301,13 +301,13 @@ def delete
render plain: I18n.t('notes_controller.content_deleted')
else
flash[:notice] = I18n.t('notes_controller.content_deleted')
redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s
redirect_to "/dashboard?_=#{Time.now.to_i}"
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
else
flash[:error] = I18n.t('notes_controller.more_than_one_contributor')
redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s
redirect_to "/dashboard?_=#{Time.now.to_i}"
end
else
prompt_login
Expand All @@ -328,7 +328,7 @@ def author
def author_topic
@user = User.find_by(name: params[:author])
@tagnames = params[:topic].split('+')
@title = @user.name + " on '" + @tagnames.join(', ') + "'"
@title = "#{@user.name} on '#{@tagnames.join(', ')}'"
@notes = @user.notes_for_tags(@tagnames)
@unpaginated = true
render template: 'notes/index'
Expand Down Expand Up @@ -391,24 +391,24 @@ def rsvp
# leave a comment
@comment = @node.add_comment(subject: 'rsvp', uid: current_user.uid, body: 'I will be attending!')
# make a tag
@node.add_tag('rsvp:' + current_user.username, current_user)
redirect_to URI.parse(@node.path).path + '#comments'
@node.add_tag("rsvp:#{current_user.username}", current_user)
redirect_to "#{URI.parse(node.path).path}#comments"
end

# Updates title of a wiki page, takes id and title as query string params. maps to '/node/update/title'
def update_title
node = Node.find params[:id].to_i
unless current_user && current_user == node.author
flash.keep[:error] = I18n.t('notes_controller.author_can_edit_note')
return redirect_to URI.parse(node.path).path + "#comments"
return redirect_to "#{URI.parse(node.path).path}#comments"
end
node.update(title: params[:title])
redirect_to URI.parse(node.path).path + "#comments"
redirect_to "#{URI.parse(node.path).path}#comments"
end

def publish_draft
@node = Node.find(params[:id])
if current_user && current_user.uid == @node.uid || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}")
if (current_user && current_user.uid == @node.uid) || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}")
@node.path = @node.generate_path
@node.slug = @node.slug.split('token').first
@node['created'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types
Expand Down Expand Up @@ -470,11 +470,13 @@ def new_note
end

def new_preview_note
Node.new_preview_note(uid: current_user.uid,
title: params[:title],
body: params[:body],
main_image: params[:main_image],
location: params[:location])
Node.new_preview_note(
uid: current_user.uid,
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
title: params[:title],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLABEL
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)

body: params[:body],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLABEL
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)

main_image: params[:main_image],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLABEL
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)

location: params[:location]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLABEL
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)

)
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
end

def not_draft_and_user_is_first_time_poster?
Expand Down