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 5501402..6ef7b04 100644 (file)
@@ -60,7 +60,7 @@ class IssuesController < ApplicationController
 
     # 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])
index b063935..ef9ae20 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,
-                                                                                                                                                               :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
-
+               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
index 6de535e..0abc270 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
 
-       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
index a33214a..7e08ac3 100644 (file)
 <% 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") %>
index 4f0fb9f..622d912 100644 (file)
@@ -145,6 +145,7 @@ en-GB:
         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}'
@@ -1005,7 +1006,20 @@ en-GB:
           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
index 9fc1785..6e5a08b 100644 (file)
@@ -131,6 +131,7 @@ en:
         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}"
@@ -976,6 +977,19 @@ en:
         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>
index 709754d..1fce3d0 100644 (file)
@@ -17,7 +17,7 @@ class CreateIssuesAndReports < ActiveRecord::Migration
       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]
@@ -32,8 +32,8 @@ class CreateIssuesAndReports < ActiveRecord::Migration
       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
index 9fb35a9..98b2afd 100644 (file)
@@ -9,8 +9,8 @@ class CreateIssueComments < ActiveRecord::Migration
       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
index 4c1328a..5919574 100644 (file)
@@ -2449,7 +2449,7 @@ ALTER TABLE ONLY gpx_files
 --
 
 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
-    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
-    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
-    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
-    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;
 
 
 --