Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions app/controllers/user_tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def create
else
@output[:errors] << I18n.t('user_tags_controller.value_cannot_be_empty')
end
if params[:translationswitch]
redirect_to URI.parse('/change_locale/zh-CN').path and return

Choose a reason for hiding this comment

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

Use && instead of and.

end
else
@output[:errors] << I18n.t('user_tags_controller.admin_user_manage_tags')
end
Expand Down Expand Up @@ -105,6 +108,10 @@ def delete
output[:errors] = I18n.t('user_tags_controller.tag_doesnt_exist')
end

if params[:translationswitch]
redirect_to URI.parse('/change_locale/en').path and return

Choose a reason for hiding this comment

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

Use && instead of and.

end

output[:tid] = @user_tag&.id
if request.xhr?
render json: output
Expand Down
16 changes: 16 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@
<a class="dropdown-item" href="/features">Features</a>
<div class="dropdown-divider"></div>
<% end %>

<% if Rails.env==="development" %>
<% if current_user %>
<% if current_user&.has_tag('translation-helper') %>
<a rel="tooltip" class="dropdown-item" data-placement="bottom" data-method="delete" href="/profile/tags/delete/<%= current_user.id %>?name=translation-helper&translationswitch=yes">
Switch off Translation
</a>
<% else %>
<a rel="tooltip" class="dropdown-item" data-placement="bottom" data-method="post" href="/profile/tags/create/<%= current_user.id %>?translationswitch=yes&name=translation-helper">
Switch on Translation
</a>
<% end %>
<div class="dropdown-divider"></div>
<% end %>
<% end %>

<% if current_user&.has_tag('translation-helper') && I18n.locale != :en %>
<div class="dropdown-item">
<%= link_to translation('layout._header.logout'), logout_path, class: "text-body" %>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ def setup
test "test get request for updating a comment" do
assert_routing({ path: '/comment/update/:id', method: 'get' }, {controller: 'comment', action: 'update', id: ':id' })
end

end