Skip to content

Commit

Permalink
Index view and list reports on other types
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- committed May 9, 2018
1 parent 73635ec commit 45a4cbc
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/abuse_report_statuses.scss
Expand Up @@ -17,7 +17,7 @@
}
}

h1 .report-status {
h1 .report-status, h3 .report-status {
font-size: 60% !important;
}

Expand Down
8 changes: 8 additions & 0 deletions app/assets/stylesheets/abuse_reports.scss
Expand Up @@ -5,3 +5,11 @@
.report-title {
margin-bottom: 0.6em;
}

.abuse-report {
margin: 1em;

h3 {
margin-top: 5px;
}
}
4 changes: 3 additions & 1 deletion app/controllers/abuse_contacts_controller.rb
Expand Up @@ -26,7 +26,9 @@ def create
end
end

def show; end
def show
@reports = @contact.reports.includes(:status, :contact, :user)
end

def edit; end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/abuse_report_statuses_controller.rb
Expand Up @@ -20,7 +20,9 @@ def create
end
end

def show; end
def show
@reports = @status.reports.includes(:contact, :status, :user)
end

def edit; end

Expand Down
14 changes: 13 additions & 1 deletion app/controllers/abuse_reports_controller.rb
Expand Up @@ -6,7 +6,19 @@ class AbuseReportsController < ApplicationController
before_action :verify_access, except: [:index, :new, :create]
before_action :verify_admin, only: [:destroy]

def index; end
def index
case params[:filter]
when 'closed'
ids = [AbuseReportStatus['Closed: Successful'].id, AbuseReportStatus['Closed: Unsuccessful'].id]
@reports = AbuseReport.where(abuse_report_status_id: ids).paginate(page: params[:page], per_page: 90)
when 'stale'
@reports = AbuseReport.where(status: AbuseReportStatus['Stale']).paginate(page: params[:page], per_page: 90)
when 'open'
@reports = AbuseReport.where(status: AbuseReportStatus['Open']).paginate(page: params[:page], per_page: 90)
else
@reports = AbuseReport.where(status: AbuseReportStatus['Open']).paginate(page: params[:page], per_page: 90)
end
end

def new; end

Expand Down
11 changes: 10 additions & 1 deletion app/views/abuse_contacts/show.html.erb
Expand Up @@ -2,4 +2,13 @@
<p><span class="glyphicon glyphicon-envelope"></span> <%= @contact.email %></p>
<p><span class="glyphicon glyphicon-link"></span> <%= link_to @contact.link, @contact.link %></p>

<%= raw(sanitize(AbuseContactsController.renderer.render(@contact.details), scrubber: Announcement.scrubber)) %>
<%= raw(sanitize(AbuseContactsController.renderer.render(@contact.details), scrubber: Announcement.scrubber)) %>

<h3>Reports to this contact</h3>
<% @reports.in_groups_of(3).map(&:compact).each do |g| %>
<div class="row">
<% g.each do |r| %>
<%= render 'abuse_reports/report', report: r %>
<% end %>
</div>
<% end %>
10 changes: 9 additions & 1 deletion app/views/abuse_report_statuses/show.html.erb
@@ -1 +1,9 @@
<h1>Report Status <%= render 'status', status: @status, nl: true %></h1>
<h1>Reports with status <%= render 'status', status: @status, nl: true %></h1>

<% @reports.in_groups_of(3).map(&:compact).each do |g| %>
<div class="row">
<% g.each do |r| %>
<%= render 'abuse_reports/report', report: r %>
<% end %>
</div>
<% end %>
19 changes: 19 additions & 0 deletions app/views/abuse_reports/_report.html.erb
@@ -0,0 +1,19 @@
<div class="col-md-4">
<div class="panel panel-default abuse-report">
<div class="panel-body">
<h3>
<%= render 'abuse_report_statuses/status', status: report.status, nl: true %>
<%= link_to abuse_report_path(report) do %>
#<%= report.id %>
<% end %>
</h3>
<p>
Reported to
<strong><%= link_to report.contact.name, abuse_contact_path(report.contact) %></strong>
by
<strong><%= report.user.username %></strong>
<%= time_ago_in_words report.created_at %> ago
</p>
</div>
</div>
</div>
18 changes: 18 additions & 0 deletions app/views/abuse_reports/index.html.erb
@@ -0,0 +1,18 @@
<h1>Abuse Reports</h1>
<p>One giant list of all the abuse reports, ever.</p>

<ul class="nav nav-tabs">
<li class="<%= 'active' if params[:filter] == 'open' || params[:filter].nil? %>"><%= link_to 'Open', abuse_reports_path(filter: 'open') %></li>
<li class="<%= 'active' if params[:filter] == 'stale' %>"><%= link_to 'Stale', abuse_reports_path(filter: 'stale') %></li>
<li class="<%= 'active' if params[:filter] == 'closed' %>"><%= link_to 'Closed', abuse_reports_path(filter: 'closed') %></li>
</ul>

<% @reports.in_groups_of(3).map(&:compact).each do |g| %>
<div class="row">
<% g.each do |r| %>
<%= render 'report', report: r %>
<% end %>
</div>
<% end %>
<%= will_paginate @reports, renderer: BootstrapPagination::Rails %>

0 comments on commit 45a4cbc

Please sign in to comment.