]> git.openstreetmap.org Git - rails.git/commitdiff
Added support for reporting Changesets + Deleting issues from the CLI
authorShrey <shrey14099@iiitd.ac.in>
Fri, 19 Jun 2015 17:56:45 +0000 (23:26 +0530)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 22 Aug 2016 15:17:54 +0000 (16:17 +0100)
app/controllers/issues_controller.rb
app/helpers/issues_helper.rb
app/models/issue.rb
app/views/browse/changeset.html.erb
config/locales/en-GB.yml
config/locales/en.yml
db/migrate/20150516073616_create_issues_and_reports.rb
db/migrate/20150526130032_create_issue_comments.rb
db/structure.sql

index 550140232876e2771a1fb6214a070fd934b9606f..6ef7b04235b4943d6d115f184755a9494dd2335a 100644 (file)
@@ -60,7 +60,7 @@ class IssuesController < ApplicationController
 
     # TODO: Find better place to add these
     admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User']
 
     # TODO: Find better place to add these
     admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User']
-    moderator_issues = []
+    moderator_issues = [ 'Changeset' ]
 
     
     @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
 
     
     @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
index b063935ea3c851649b066269de5408013d28c652..ef9ae20de9626b90ce6c063073636ac9c31a1665 100644 (file)
@@ -10,14 +10,17 @@ module IssuesHelper
                                                                                                                                :id => reportable.id
                when "User"
                        link_to reportable.display_name.to_s,   :controller => reportable.class.name.underscore,
                                                                                                                                :id => reportable.id
                when "User"
                        link_to reportable.display_name.to_s,   :controller => reportable.class.name.underscore,
-                                                                                                                                                               :action => "view",
+                                                                                                                                                               :action => :view,
                                                                                                                                                                :display_name => reportable.display_name
                when "DiaryComment"
                        link_to "#{reportable.diary_entry.title}, Comment id ##{reportable.id}",        :controller => reportable.diary_entry.class.name.underscore,
                                                                                                                :action => :view,
                                                                                                                :display_name => reportable.diary_entry.user.display_name,
                                                                                                                :id => reportable.id
                                                                                                                                                                :display_name => reportable.display_name
                when "DiaryComment"
                        link_to "#{reportable.diary_entry.title}, Comment id ##{reportable.id}",        :controller => reportable.diary_entry.class.name.underscore,
                                                                                                                :action => :view,
                                                                                                                :display_name => reportable.diary_entry.user.display_name,
                                                                                                                :id => reportable.id
-
+               when "Changeset"
+                       link_to "Changeset ##{reportable.id}, Closed at: #{l(reportable.closed_at.to_datetime, :format => :long)}",             :controller => :browse,
+                                                                                                                                                                                                       :action => :changeset,
+                                                                                                                                                                                                       :id => reportable.id
                else
                        nil
                end
                else
                        nil
                end
index 6de535e819b7a0fb147f7770827a5b7319de91eb..0abc27063de4c547eb212a3642b8d5e696b124ce 100644 (file)
@@ -2,8 +2,8 @@ class Issue < ActiveRecord::Base
        belongs_to :reportable, :polymorphic => true
        belongs_to :user, :class_name => "User", :foreign_key => :reported_user_id
 
        belongs_to :reportable, :polymorphic => true
        belongs_to :user, :class_name => "User", :foreign_key => :reported_user_id
 
-       has_many :reports
-       has_many :comments, :class_name => "IssueComment"
+       has_many :reports, dependent: :destroy
+       has_many :comments, :class_name => "IssueComment", dependent: :destroy
        
        validates :reportable_id, :uniqueness => { :scope => [ :reportable_type ] }
        validates :reported_user_id, :presence => true
        
        validates :reportable_id, :uniqueness => { :scope => [ :reportable_type ] }
        validates :reported_user_id, :presence => true
index a33214a70231955009b9546847a09f04cd750207..7e08ac3a8f5a62b42e7c48954f0aa146d1fae290 100644 (file)
 <% end %>
 
 <div class='secondary-actions'>
 <% end %>
 
 <div class='secondary-actions'>
+  <% if @user and @user.id != @changeset.user.id %>
+    <%= link_to t('browse.changeset.report'), new_issue_url(reportable_id: @changeset.id, reportable_type: @changeset.class.name, reported_user_id: @changeset.user.id) %>
+    &middot;
+  <% end %>
   <%= link_to(t('browse.changeset.changesetxml'), :controller => "changeset", :action => "read") %>
   &middot;
   <%= link_to(t('browse.changeset.osmchangexml'), :controller => "changeset", :action => "download") %>
   <%= link_to(t('browse.changeset.changesetxml'), :controller => "changeset", :action => "read") %>
   &middot;
   <%= link_to(t('browse.changeset.osmchangexml'), :controller => "changeset", :action => "download") %>
index 4f0fb9f03feb2fd363e0f93f6db261c58cdef66f..622d912ce06c99e20643a4670d859459d826c2fd 100644 (file)
@@ -145,6 +145,7 @@ en-GB:
         title_comment: Changeset %{id} - %{comment}
       join_discussion: Log in to join the discussion
       discussion: Discussion
         title_comment: Changeset %{id} - %{comment}
       join_discussion: Log in to join the discussion
       discussion: Discussion
+      report: Report this changeset
     node:
       title: 'Node: %{name}'
       history_title: 'Node History: %{name}'
     node:
       title: 'Node: %{name}'
       history_title: 'Node History: %{name}'
@@ -1005,7 +1006,20 @@ en-GB:
           details: This User is a vandal
         other: 
           type: "[OTHER]"
           details: This User is a vandal
         other: 
           type: "[OTHER]"
-          details: Other      
+          details: Other  
+      Changeset:
+        type1:
+          type: "[TYPE1]"
+          details: Placeholder 1    
+        type2:
+          type: "[TYPE1]"
+          details: Placeholder 2    
+        type3:
+          type: "[TYPE3]"
+          details: Placeholder 3    
+        other: 
+          type: "[OTHER]"
+          details: Other  
   layouts:
     project_name:
       title: OpenStreetMap
   layouts:
     project_name:
       title: OpenStreetMap
index 9fc1785b54a112d9fdcaaea9d093a41c76700b32..6e5a08b24f849a51575c97d10771a125b4969301 100644 (file)
@@ -131,6 +131,7 @@ en:
         title_comment: "Changeset %{id} - %{comment}"
       join_discussion: "Log in to join the discussion"
       discussion: Discussion
         title_comment: "Changeset %{id} - %{comment}"
       join_discussion: "Log in to join the discussion"
       discussion: Discussion
+      report: Report this changeset
     node:
       title: "Node: %{name}"
       history_title: "Node History: %{name}"
     node:
       title: "Node: %{name}"
       history_title: "Node History: %{name}"
@@ -976,6 +977,19 @@ en:
         other: 
           type: "[OTHER]"
           details: Other      
         other: 
           type: "[OTHER]"
           details: Other      
+      Changeset:
+        type1:
+          type: "[TYPE1]"
+          details: Placeholder 1    
+        type2:
+          type: "[TYPE1]"
+          details: Placeholder 2    
+        type3:
+          type: "[TYPE3]"
+          details: Placeholder 3    
+        other: 
+          type: "[OTHER]"
+          details: Other            
   layouts:
     project_name:
       # in <title>
   layouts:
     project_name:
       # in <title>
index 709754dbf325e6cbefcf6523202d6308cea19a6e..1fce3d0512ed91e2ce75b4b2a95e3036ec0e199a 100644 (file)
@@ -17,7 +17,7 @@ class CreateIssuesAndReports < ActiveRecord::Migration
       t.timestamps null: false
     end
 
       t.timestamps null: false
     end
 
-    add_foreign_key :issues, :users, :column => :reported_user_id,:name => "issues_reported_user_id_fkey"
+    add_foreign_key :issues, :users, :column => :reported_user_id,:name => "issues_reported_user_id_fkey", on_delete: :cascade
 
     add_index :issues, :reported_user_id
     add_index :issues, [:reportable_id, :reportable_type]
 
     add_index :issues, :reported_user_id
     add_index :issues, [:reportable_id, :reportable_type]
@@ -32,8 +32,8 @@ class CreateIssuesAndReports < ActiveRecord::Migration
       t.timestamps null: false
     end
 
       t.timestamps null: false
     end
 
-    add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
-    add_foreign_key :reports, :users,:column => :reporter_user_id, :name => "reports_reporter_user_id_fkey"
+    add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey", on_delete: :cascade
+    add_foreign_key :reports, :users,:column => :reporter_user_id, :name => "reports_reporter_user_id_fkey", on_delete: :cascade
 
     add_index :reports, :reporter_user_id
     add_index :reports, :issue_id
 
     add_index :reports, :reporter_user_id
     add_index :reports, :issue_id
index 9fb35a9225b81c77a3a0090f74cdd196a31547fe..98b2afd106c7e2c9fd3219317998e8070e5dc6b2 100644 (file)
@@ -9,8 +9,8 @@ class CreateIssueComments < ActiveRecord::Migration
       t.timestamps null: false
     end
 
       t.timestamps null: false
     end
 
-       add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
-       add_foreign_key :issue_comments, :users,:column => :commenter_user_id, :name => "issue_comments_commenter_user_id"
+       add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", on_delete: :cascade
+       add_foreign_key :issue_comments, :users,:column => :commenter_user_id, :name => "issue_comments_commenter_user_id", on_delete: :cascade
 
        add_index :issue_comments, :commenter_user_id
        add_index :issue_comments, :issue_id
 
        add_index :issue_comments, :commenter_user_id
        add_index :issue_comments, :issue_id
index 4c1328a183564db1e5e81acfe0b15e94fdc08687..5919574f45f9ba170583149b57882e547265eda9 100644 (file)
@@ -2449,7 +2449,7 @@ ALTER TABLE ONLY gpx_files
 --
 
 ALTER TABLE ONLY issue_comments
 --
 
 ALTER TABLE ONLY issue_comments
-    ADD CONSTRAINT issue_comments_commenter_user_id FOREIGN KEY (commenter_user_id) REFERENCES users(id);
+    ADD CONSTRAINT issue_comments_commenter_user_id FOREIGN KEY (commenter_user_id) REFERENCES users(id) ON DELETE CASCADE;
 
 
 --
 
 
 --
@@ -2457,7 +2457,7 @@ ALTER TABLE ONLY issue_comments
 --
 
 ALTER TABLE ONLY issue_comments
 --
 
 ALTER TABLE ONLY issue_comments
-    ADD CONSTRAINT issue_comments_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id);
+    ADD CONSTRAINT issue_comments_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
 
 
 --
 
 
 --
@@ -2465,7 +2465,7 @@ ALTER TABLE ONLY issue_comments
 --
 
 ALTER TABLE ONLY issues
 --
 
 ALTER TABLE ONLY issues
-    ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id);
+    ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id) ON DELETE CASCADE;
 
 
 --
 
 
 --
@@ -2585,7 +2585,7 @@ ALTER TABLE ONLY relations
 --
 
 ALTER TABLE ONLY reports
 --
 
 ALTER TABLE ONLY reports
-    ADD CONSTRAINT reports_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id);
+    ADD CONSTRAINT reports_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
 
 
 --
 
 
 --
@@ -2593,7 +2593,7 @@ ALTER TABLE ONLY reports
 --
 
 ALTER TABLE ONLY reports
 --
 
 ALTER TABLE ONLY reports
-    ADD CONSTRAINT reports_reporter_user_id_fkey FOREIGN KEY (reporter_user_id) REFERENCES users(id);
+    ADD CONSTRAINT reports_reporter_user_id_fkey FOREIGN KEY (reporter_user_id) REFERENCES users(id) ON DELETE CASCADE;
 
 
 --
 
 
 --