Moved strings to locales + Added 'Issues' button + Fixed typo in tests
authorShrey <shrey14099@iiitd.ac.in>
Sun, 7 Jun 2015 13:55:09 +0000 (19:25 +0530)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 22 Aug 2016 15:17:54 +0000 (16:17 +0100)
app/controllers/issues_controller.rb
app/views/diary_entry/_diary_comment.html.erb
app/views/diary_entry/_diary_entry.html.erb
app/views/issues/new.html.erb
app/views/issues/show.html.erb
app/views/layouts/_header.html.erb
app/views/notifier/new_issue_notification.html.erb
config/locales/en-GB.yml
config/locales/en.yml
test/controllers/issues_controller_test.rb

index 3cd0ceda09a785bb7348527b731b2025be36c05f..edb48e64c0d73a4b38ea3b3cf3800a7fed2d0efc 100644 (file)
@@ -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
index d74d06b8906daf93b57e5c1265fbb4653958b2bf..c741d7734630f5ca93b206c1102db4ec82979933 100644 (file)
@@ -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 %>
 </div>
index a5162ff597a09cfc4009477fec0e903a4afb934d..76a6666f31d9e973bec39852a02157168ce3c969 100644 (file)
@@ -33,7 +33,7 @@
 
       <li>
         <% 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 %>
       </li>
     <%= if_administrator(:li) do %>
index 5f9c7ce08abff355bb0e49b1aba9196d0c8d10b1..499035db68974e48abbb534f0ad7cd9b1b8a94c7 100644 (file)
@@ -19,7 +19,7 @@
                     <%= check_box_tag :spam, "[SPAM]" %>
                     </div>
                     <div class="new-report-string">
-                        <%= label_tag "This #{@issue.reportable.class.name} is/contains spam." %> <br/>
+                        <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.spam') %> <br/>
                     </div>
                 </div>
                 <br/>
@@ -29,7 +29,7 @@
                     <%= check_box_tag :offensive, "[OFFENSIVE]" %>
                     </div>
                     <div class="new-report-string">
-                        <%= label_tag "This #{@issue.reportable.class.name} is obscene/offensive." %> <br/>
+                        <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.offensive') %> <br/>
                     </div>
                 </div>
                 <br/>
@@ -39,7 +39,7 @@
                     <%= check_box_tag :threat, "[THREAT]" %>
                     </div>
                     <div class="new-report-string">
-                        <%= label_tag "This #{@issue.reportable.class.name} contains a threat." %> <br/>
+                        <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.threat') %> <br/>
                     </div>
                 </div>
                 <br/>
@@ -50,7 +50,7 @@
                         <%= check_box_tag :vandal, "[VANDAL]" %>
                         </div>
                         <div class="new-report-string">
-                            <%= label_tag "This #{@issue.reportable.class.name} is a vandal." %> <br/>
+                        <%= label_tag "This #{@issue.reportable.class.name} " + t('issues.report_strings.vandal') %> <br/>
                         </div>
                     </div>
                     <br/>
                     <%= check_box_tag :other, "[OTHER]" %>
                     </div>
                     <div class="new-report-string">
-                        <%= label_tag "Other." %> <br/>
+                        <%= label_tag t('issues.report_strings.other') %> <br/>
                     </div>
                 </div>
                 <br/>
 
                 <label class="standard-label"><b><%= t 'issue.new.message' -%>: </b></label> <br/>
-                <%= 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 %>
             </div>
 
             <div class='buttons'>
index 51498484dd0c3dd0d8b8c57cb65e213232bcc385..1f57c454e73a62babb9d18a9f3e1a4cceff2c8b5 100644 (file)
@@ -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? %>
                </small>
        </p>
-       <p><%= link_to "Resolve", resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %></p>
-       <p><%= link_to "Ignore", ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %></p>
-       <p><%= link_to "Reopen", reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %></p>
+       <p><%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %></p>
+       <p><%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %></p>
+       <p><%= link_to t('issues.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %></p>
 <% end %>
 
 <div class="report-related-block">
index a8811c6c9c39ff27842ba803faef9aa651fb5036..3187d0b27f6ee7b029716d9f9810bdc43685e623 100644 (file)
@@ -38,6 +38,9 @@
   </nav>
   <nav class='secondary'>
     <ul>
+      <% if @user and @user.administrator? %>
+        <li class="compact-hide <%= current_page_class(issues_path) %>"><%= link_to t('layouts.issues'), issues_path %></li>
+      <% end %>
       <li class="compact-hide <%= current_page_class(traces_path) %>"><%= link_to t('layouts.gps_traces'), traces_path %></li>
       <li class="compact-hide <%= current_page_class(diary_path) %>"><%= link_to t('layouts.user_diaries'), diary_path %></li>
       <li class="compact-hide <%= current_page_class(copyright_path) %>"><%= link_to t('layouts.copyright'), copyright_path %></li>
index f57b7c6fc0f85e30bad32c36578aa1d544ec15dc..fbbfefedec5124830ad91a146655af46b26e8d07 100644 (file)
@@ -2,4 +2,3 @@
 
 <p><%= t("notifier.new_issue_notification.new_issue") %></p>
 
-
index e46cc3c26d62d9d82e26c6b6136d70b3ee899a1f..9e2ae21494d16418583da032aef486d32ea0d75a 100644 (file)
@@ -935,6 +935,28 @@ en-GB:
     results:
       no_results: No results found
       more_results: More results
+  issues:
+    report: Report
+    resolve: Resolve
+    ignore: Ignore
+    reopen: Reopen
+    create:
+      successful_report: Your report has been registered sucessfully
+      provide_details: Please provide the required details
+    update:
+      successful_update: Your report was successfully updated
+      provide_details: Please provide the required details
+    new:
+      details: Please provide some more details into the problem. (This field cannot be left blank!)
+    resolved: Issue status has been set to 'Resolved'
+    ignored: Issue status has been set to 'Ignored'
+    reopened: Issue status has been set to 'Open'
+    report_strings:
+      spam: is/contains spam
+      offensive: is obscene/offensive
+      threat: contains a threat
+      vandal: is a vandal
+      other: Other
   layouts:
     project_name:
       title: OpenStreetMap
@@ -951,6 +973,7 @@ en-GB:
     edit: Edit
     history: History
     export: Export
+    issues: Issues
     data: Data
     export_data: Export Data
     gps_traces: GPS Traces
@@ -1352,7 +1375,7 @@ en-GB:
     new_issue_notification:
       subject: "[OpenStreetMap] New Issue"
       greeting: "Hi,"
-      new_issue: "A new issue has been created:"
+      new_issue: "A new issue has been created"
   message:
     inbox:
       title: Inbox
index 24a829625db310bac344d5c1a4c2c15715737237..bb66f962b65eb68547f460e540af3ddd6c78a951 100644 (file)
@@ -905,6 +905,28 @@ en:
     results:
       no_results: "No results found"
       more_results: "More results"
+  issues:
+    report: Report
+    resolve: Resolve
+    ignore: Ignore
+    reopen: Reopen
+    create:
+      successful_report: Your report has been registered sucessfully
+      provide_details: Please provide the required details
+    update:
+      successful_update: Your report was successfully updated
+      provide_details: Please provide the required details
+    new:
+      details: Please provide some more details into the problem. (This field cannot be left blank!)
+    resolved: Issue status has been set to 'Resolved'
+    ignored: Issue status has been set to 'Ignored'
+    reopened: Issue status has been set to 'Open'
+    report_strings:
+      spam: is/contains spam
+      offensive: is obscene/offensive
+      threat: contains a threat
+      vandal: is a vandal
+      other: Other
   layouts:
     project_name:
       # in <title>
@@ -923,6 +945,7 @@ en:
     edit: Edit
     history: History
     export: Export
+    issues: Issues
     data: Data
     export_data: Export Data
     gps_traces: GPS Traces
@@ -1320,7 +1343,7 @@ en:
     new_issue_notification:
       subject: "[OpenStreetMap] New Issue"
       greeting: "Hi,"
-      new_issue: "A new issue has been created:"
+      new_issue: "A new issue has been created"
   message:
     inbox:
       title: "Inbox"
index a8ee6f613c78a66004591be791201a89edabd939..6eacac11da27efbd9f723a0dd51a4f55e0918ad2 100644 (file)
@@ -20,7 +20,7 @@ class IssuesControllerTest < ActionController::TestCase
     assert_response :success
     assert_difference "Issue.count",1 do 
       details = "Details of a report"
-      post :create, { :report => { :deatils => details},
+      post :create, { :report => { :details => details},
                       :issue => { reportable_id: 1, reportable_type: "DiaryEntry", reported_user_id: 1} }
     end
     assert_response :redirect