From cf4cfc530ae54abee7b6a0dccbc9d4603ab35611 Mon Sep 17 00:00:00 2001 From: Shrey Date: Sun, 7 Jun 2015 19:25:09 +0530 Subject: [PATCH] Moved strings to locales + Added 'Issues' button + Fixed typo in tests --- app/controllers/issues_controller.rb | 36 ++++++++++--------- app/views/diary_entry/_diary_comment.html.erb | 2 +- app/views/diary_entry/_diary_entry.html.erb | 2 +- app/views/issues/new.html.erb | 12 +++---- app/views/issues/show.html.erb | 6 ++-- app/views/layouts/_header.html.erb | 3 ++ .../notifier/new_issue_notification.html.erb | 1 - config/locales/en-GB.yml | 25 ++++++++++++- config/locales/en.yml | 25 ++++++++++++- test/controllers/issues_controller_test.rb | 2 +- 10 files changed, 83 insertions(+), 31 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 3cd0ceda0..edb48e64c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -32,26 +32,30 @@ class IssuesController < ApplicationController Notifier.new_issue_notification(User.find(admin.user_id)).deliver_now end end - @report = @issue.reports.build(report_params) - details = params[:report][:details].to_s + "||" + params[:spam].to_s + "||" + params[:offensive].to_s + "||" + params[:threat].to_s + "||" + params[:vandal].to_s + "||" + params[:other].to_s - @report.reporter_user_id = @user.id - @report.details = details - if @issue.save! - redirect_to root_path, notice: 'Your report has been registered sucessfully.' + if params[:report][:details] and (params[:spam] or params[:offensive] or params[:threat] or params[:vandal] or params[:other]) + @report = @issue.reports.build(report_params) + details = params[:report][:details].to_s + "||" + params[:spam].to_s + "||" + params[:offensive].to_s + "||" + params[:threat].to_s + "||" + params[:vandal].to_s + "||" + params[:other].to_s + @report.reporter_user_id = @user.id + @report.details = details + if @issue.save! + redirect_to root_path, notice: t('issues.create.successful_report') + end else - render :new + redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.create.provide_details') end end def update @issue = Issue.find_by(issue_params) - @report = @issue.reports.where(reporter_user_id: @user.id).first - details = params[:report][:details].to_s + "||" + params[:spam].to_s + "||" + params[:offensive].to_s + "||" + params[:threat].to_s + "||" + params[:vandal].to_s + "||" + params[:other].to_s - @report.details = details - if @report.save! - redirect_to root_path, notice: 'Your report was successfully updated.' + if params[:report][:details] and (params[:spam] or params[:offensive] or params[:threat] or params[:vandal] or params[:other]) + @report = @issue.reports.where(reporter_user_id: @user.id).first + details = params[:report][:details].to_s + "||" + params[:spam].to_s + "||" + params[:offensive].to_s + "||" + params[:threat].to_s + "||" + params[:vandal].to_s + "||" + params[:other].to_s + @report.details = details + if @report.save! + redirect_to root_path, notice: t('issues.update.successful_update') + end else - render :edit + redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.update.provide_details') end end @@ -67,7 +71,7 @@ class IssuesController < ApplicationController def resolve if @issue.resolve @issue.save! - redirect_to @issue, notice: "Issue status has been set to: 'Resolved'" + redirect_to @issue, notice: t('issues.resolved') else render :show end @@ -76,7 +80,7 @@ class IssuesController < ApplicationController def ignore if @issue.ignore @issue.save! - redirect_to @issue, notice: "Issue status has been set to: 'Ignored'" + redirect_to @issue, notice: t('issues.ignored') else render :show end @@ -85,7 +89,7 @@ class IssuesController < ApplicationController def reopen if @issue.reopen @issue.save! - redirect_to @issue, notice: "Issue status has been set to: 'Open'" + redirect_to @issue, notice: t('issues.reopened') else render :show end diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index d74d06b89..c741d7734 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -6,6 +6,6 @@ <%= link_to t('diary_entry.diary_comment.hide_link'), hide_diary_comment_path(:display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id), :method => :post, :data=> { :confirm => t('diary_entry.diary_comment.confirm') } %> | <% end %> <% if @user and diary_comment.user.id != @user.id %> - <%= link_to 'Report', new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, reported_user_id: diary_comment.user.id) %> + <%= link_to t('issues.report'), new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, reported_user_id: diary_comment.user.id) %> <% end %> diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index a5162ff59..76a6666f3 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -33,7 +33,7 @@
  • <% if @user and diary_entry.user.id != @user.id %> - <%= link_to 'Report', new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id) %> + <%= link_to t('issues.report'), new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id) %> <% end %>
  • <%= if_administrator(:li) do %> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 5f9c7ce08..499035db6 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -19,7 +19,7 @@ <%= check_box_tag :spam, "[SPAM]" %>
    - <%= label_tag "This #{@issue.reportable.class.name} is/contains spam." %>
    + <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.spam') %>

    @@ -29,7 +29,7 @@ <%= check_box_tag :offensive, "[OFFENSIVE]" %>
    - <%= label_tag "This #{@issue.reportable.class.name} is obscene/offensive." %>
    + <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.offensive') %>

    @@ -39,7 +39,7 @@ <%= check_box_tag :threat, "[THREAT]" %>
    - <%= label_tag "This #{@issue.reportable.class.name} contains a threat." %>
    + <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.threat') %>

    @@ -50,7 +50,7 @@ <%= check_box_tag :vandal, "[VANDAL]" %>
    - <%= label_tag "This #{@issue.reportable.class.name} is a vandal." %>
    + <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.vandal') %>

    @@ -61,13 +61,13 @@ <%= check_box_tag :other, "[OTHER]" %>
    - <%= label_tag "Other." %>
    + <%= label_tag t('issues.report_strings.other') %>


    - <%= text_area :report, :details, :cols => 80, :rows => 20, placeholder: "Please provide some more details into the problem. (This field cannot be left blank!)" %> + <%= text_area :report, :details, :cols => 80, :rows => 20, placeholder: t('issues.new.details'), required: true %>
    diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 51498484d..1f57c454e 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -7,9 +7,9 @@ <%= @issue.reports.count %> reports | First reported: <%= l @issue.created_at.to_date, :format => :long %> <%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:long)}" if @issue.resolved_at? %>

    -

    <%= link_to "Resolve", resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %>

    -

    <%= link_to "Ignore", ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %>

    -

    <%= link_to "Reopen", reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %>

    +

    <%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %>

    +

    <%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %>

    +

    <%= link_to t('issues.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %>

    <% end %>