diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 550140232..6ef7b0423 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -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])
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index b063935ea..ef9ae20de 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -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
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 6de535e81..0abc27063 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -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
diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb
index a33214a70..7e08ac3a8 100644
--- a/app/views/browse/changeset.html.erb
+++ b/app/views/browse/changeset.html.erb
@@ -129,6 +129,10 @@
<% end %>
+ <% 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) %>
+ ·
+ <% end %>
<%= link_to(t('browse.changeset.changesetxml'), :controller => "changeset", :action => "read") %>
·
<%= link_to(t('browse.changeset.osmchangexml'), :controller => "changeset", :action => "download") %>
diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml
index 4f0fb9f03..622d912ce 100644
--- a/config/locales/en-GB.yml
+++ b/config/locales/en-GB.yml
@@ -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
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9fc1785b5..6e5a08b24 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -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
diff --git a/db/migrate/20150516073616_create_issues_and_reports.rb b/db/migrate/20150516073616_create_issues_and_reports.rb
index 709754dbf..1fce3d051 100644
--- a/db/migrate/20150516073616_create_issues_and_reports.rb
+++ b/db/migrate/20150516073616_create_issues_and_reports.rb
@@ -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
diff --git a/db/migrate/20150526130032_create_issue_comments.rb b/db/migrate/20150526130032_create_issue_comments.rb
index 9fb35a922..98b2afd10 100644
--- a/db/migrate/20150526130032_create_issue_comments.rb
+++ b/db/migrate/20150526130032_create_issue_comments.rb
@@ -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
diff --git a/db/structure.sql b/db/structure.sql
index 4c1328a18..5919574f4 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -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;
--