background: #eee;
opacity: 0.7;
}
+
+.report-related-block {
+ display:inline-block;
+}
+
+.report-block {
+ width:475px;
+ float:left;
+ margin-right:100px;
+}
+
+.related-block{
+ float:right;
+}
+
+.issue-comments {
+ width:475px;
+}
\ No newline at end of file
@read_reports = @issue.read_reports
@unread_reports = @issue.unread_reports
@comments = @issue.comments
+ @related_issues = @issue.user.issues
end
def new
unless create_new_issue_params.blank?
@issue = Issue.find_or_initialize_by(create_new_issue_params)
- puts params[:user_id].to_s + "--------------"
end
end
@report = @issue.reports.build(report_params)
@report.user_id = @user.id
if @issue.save!
- redirect_to root_path, notice: 'Issue was successfully created.'
+ redirect_to root_path, notice: 'Your report has been registered sucessfully.'
else
render :new
end
end
def create_new_issue_params
- params.permit(:reportable_id, :reportable_type, :user_id)
+ params.permit(:reportable_id, :reportable_type, :reported_user_id)
end
def issue_params
- params[:issue].permit(:reportable_id, :reportable_type,:user_id)
+ params[:issue].permit(:reportable_id, :reportable_type,:reported_user_id)
end
def report_params
:display_name => reportable.user.display_name,
:id => reportable.id
when "User"
- link_to reportable.display_name, :controller => reportable.class.name.underscore,
+ link_to reportable.display_name.to_s, :controller => reportable.class.name.underscore,
:action => "view",
:display_name => reportable.display_name
when "DiaryComment"
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"
+
validates :reportable_id, :uniqueness => { :scope => [ :reportable_type ] }
- belongs_to :user
- validates :user_id, :presence => true
+ validates :reported_user_id, :presence => true
# Check if more statuses are needed
enum status: %w( open ignored resolved )
has_many :roles, :class_name => "UserRole"
- has_many :issues
+ has_many :issues, :class_name => "Issue", :foreign_key => :reported_user_id
has_many :issue_comments
has_many :reports
<%= if_administrator(:span) do %>
<%= 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 %>
- <%= link_to 'Report', new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, user_id: diary_comment.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) %>
</div>
<%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
<% end %>
- <li><%= link_to 'Report', new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, user_id: diary_entry.user.id) %></li>
+ <li><%= link_to 'Report', new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id) %></li>
<%= if_administrator(:li) do %>
<%= link_to t('diary_entry.diary_entry.hide_link'), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t('diary_entry.diary_entry.confirm') } %>
+<div class="issue-comments">
<% comments.each do |comment| %>
<div class="comment">
<div style="float:left">
On <%= l comment.created_at.to_datetime, :format => :long %> </span>
<hr>
<% end %>
+</div>
+<br/>
<div class="comment">
<%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => @user.id } do |f| %>
- <%= richtext_area :issue_comment, :body, :cols => 80, :rows => 8 %>
+ <%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8 %>
<%= submit_tag 'Submit' %>
<% end %>
</div>
\ No newline at end of file
<div class='form-row'>
<%= f.hidden_field :reportable_id %>
<%= f.hidden_field :reportable_type %>
- <%= f.hidden_field :user_id %>
+ <%= f.hidden_field :reported_user_id %>
</div>
<div class='form-row'>
<label class="standard-label"><%= t 'issue.new.message' -%></label>
<p>Issue type: <%= @issue.reportable_type %></p>
<p class="deemphasize">
<small>
- <%= @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? %>
+ <%= @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>
<% end %>
-<h3>Reports under this issue:</h3>
-<% if @read_reports.present? %>
- <div class="read-reports">
- <h4>Read Reports:</h4>
- <%= render 'reports',reports: @read_reports %>
+<div class="report-related-block">
+
+ <div class="report-block">
+ <h3>Reports under this issue:</h3>
+
+ <% if @read_reports.present? %>
+ <div class="read-reports">
+ <h4>Read Reports:</h4>
+ <%= render 'reports',reports: @read_reports %>
+ </div>
+ <% end %>
+
+ <% if @unread_reports.any? %>
+ <div class="unread-reports">
+ <h4>New Reports:</h4>
+ <%= render 'reports',reports: @unread_reports %>
+ </div>
+ <% end %>
+ <br/>
</div>
-<% end %>
-<% if @unread_reports.any? %>
- <div class="unread-reports">
- <h4>New Reports:</h4>
- <%= render 'reports',reports: @unread_reports %>
+ <div class="related-block">
+ <h3> Other issues against this user: </h3>
+ <div class="unread-reports">
+ <% if @related_issues.count > 1 %>
+ <% @related_issues.each do |issue| %>
+ <% if issue.id != @issue.id %>
+ <%= link_to "#{issue.reportable_type} ##{issue.reportable_id}", issue %>
+ <% end %>
+ <% end %>
+ <% else %>
+ <p>No other reports against this user!</p>
+ <% end %>
+ </div>
</div>
-<% end %>
-<br/>
+
+</div>
+
<h3>Comments on this issue:</h3>
<div class="unread-reports">
<%= render 'comments', comments: @comments %>
</div>
+
<% end %>
</li>
<li>
- <%= link_to 'Report', new_issue_url(reportable_id: @this_user.id, reportable_type: @this_user.class.name, user_id: @this_user.id) %>
+ <%= link_to t('user.view.report'), new_issue_url(reportable_id: @this_user.id, reportable_type: @this_user.class.name, reported_user_id: @this_user.id) %>
</li>
<% if @this_user.blocks.exists? %>
<li>
friends_diaries: friends' diary entries
nearby_changesets: nearby user changesets
nearby_diaries: nearby user diary entries
+ report: Report User
popup:
your location: Your location
nearby mapper: Nearby mapper
friends_diaries: "friends' diary entries"
nearby_changesets: "nearby user changesets"
nearby_diaries: "nearby user diary entries"
+ report: "Report User"
popup:
your location: "Your location"
nearby mapper: "Nearby mapper"
+require "migrate"
+
class CreateIssues < ActiveRecord::Migration
def change
create_table :issues do |t|
- t.string :reportable_type
- t.integer :reportable_id
- t.integer :user_id
+ t.string :reportable_type, :null => false
+ t.integer :reportable_id, :null => false
+ t.integer :reported_user_id, :null => false
t.integer :status
t.datetime :resolved_at
t.integer :resolved_by
t.timestamps null: false
end
+
+ add_foreign_key :issues, :users, :column => :reported_user_id,:name => "issues_reported_user_id_fkey"
+
+ add_index :issues, :reported_user_id,
+ add_index :issues, [:reportable_id, :reportable_type]
+
end
end
t.timestamps null: false
end
+
+ add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
+ add_foreign_key :reports, :users, :name => "reports_user_id_fkey"
+
+ add_index :reports, :issue_id
+ add_index :reports, :user_id
+
end
end
t.timestamps null: false
end
+
+ add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
+ add_foreign_key :issue_comments, :users, :name => "issue_comments_user_id"
+
+ add_index :issue_comments, :user_id
+ add_index :issue_comments, :issue_id
+
end
end
+++ /dev/null
-require "migrate"
-
-class AddForeignKeysForIssues < ActiveRecord::Migration
- def change
- add_foreign_key :issues, :users, :name => "issues_user_id_fkey"
- add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
- add_foreign_key :reports, :users, :name => "reports_user_id_fkey"
- add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
- add_foreign_key :issue_comments, :users, :name => "issue_comments_user_id"
- end
-end
+++ /dev/null
-class AddIndexesForIssues < ActiveRecord::Migration
- def self.up
- add_index :issues, :user_id
- add_index :issues, [:reportable_id, :reportable_type]
- add_index :reports, :issue_id
- add_index :reports, :user_id
- add_index :issue_comments, :user_id
- add_index :issue_comments, :issue_id
- end
-
- def self.down
- remove_index :issues, :user_id
- remove_index :issues, [:reportable_id, :reportable_type]
- remove_index :reports, :issue_id
- remove_index :reports, :user_id
- remove_index :issue_comments, :user_id
- remove_index :issue_comments, :issue_id
- end
-end
CREATE TABLE issues (
id integer NOT NULL,
- reportable_type character varying,
- reportable_id integer,
- user_id integer,
+ reportable_type character varying NOT NULL,
+ reportable_id integer NOT NULL,
+ reported_user_id integer NOT NULL,
status integer,
resolved_at timestamp without time zone,
resolved_by integer,
CREATE INDEX index_issue_comments_on_user_id ON issue_comments USING btree (user_id);
---
--- Name: index_issues_on_reportable_id_and_reportable_type; Type: INDEX; Schema: public; Owner: -; Tablespace:
---
-
-CREATE INDEX index_issues_on_reportable_id_and_reportable_type ON issues USING btree (reportable_id, reportable_type);
-
-
---
--- Name: index_issues_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
---
-
-CREATE INDEX index_issues_on_user_id ON issues USING btree (user_id);
-
-
--
-- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX relations_timestamp_idx ON relations USING btree ("timestamp");
+--
+-- Name: reportable_object_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX reportable_object_idx ON issues USING btree (reportable_id, reportable_type);
+
+
+--
+-- Name: reported_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX reported_user_id_idx ON issues USING btree (reported_user_id);
+
+
--
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -
--
--
--- Name: issues_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+-- Name: issues_reported_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY issues
- ADD CONSTRAINT issues_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
+ ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id);
--
INSERT INTO schema_migrations (version) VALUES ('20150526130032');
-INSERT INTO schema_migrations (version) VALUES ('20150528113100');
-
-INSERT INTO schema_migrations (version) VALUES ('20150528114520');
-
INSERT INTO schema_migrations (version) VALUES ('21');
INSERT INTO schema_migrations (version) VALUES ('22');