Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.1
2.6.6
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruby 2.6.6

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby "2.4.1"
ruby "2.6.6"

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
Expand Down
53 changes: 28 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ GEM
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0)
bcrypt (3.1.11)
bcrypt (3.1.13)
bindex (0.5.0)
builder (3.2.3)
builder (3.2.4)
capybara (2.15.1)
addressable
mini_mime (>= 0.1.3)
Expand All @@ -62,26 +62,27 @@ GEM
connection_pool (2.2.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.6)
dalli (2.7.6)
declarative (0.0.9)
declarative-option (0.1.0)
devise (4.3.0)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
dig_rb (1.0.1)
dotenv (1.0.2)
dotenv-rails (1.0.2)
dotenv (= 1.0.2)
erubi (1.6.1)
erubi (1.9.0)
excon (0.58.0)
execjs (2.7.0)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
geocoder (1.4.4)
geocoder (1.6.2)
globalid (0.4.0)
activesupport (>= 4.2.0)
google-api-client (0.13.4)
Expand All @@ -103,7 +104,8 @@ GEM
httparty (0.15.6)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (0.8.6)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand All @@ -118,7 +120,8 @@ GEM
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
loofah (2.0.3)
loofah (2.5.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
Expand All @@ -128,15 +131,15 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (0.1.4)
mini_portile2 (2.2.0)
minitest (5.10.3)
mini_portile2 (2.4.0)
minitest (5.14.0)
msgpack (1.1.0)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
os (0.9.6)
pg (0.21.0)
Expand All @@ -146,7 +149,7 @@ GEM
slop (~> 3.4)
public_suffix (3.0.0)
puma (3.10.0)
rack (2.0.3)
rack (2.2.2)
rack-cors (0.4.1)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -165,15 +168,15 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.1.3)
actionpack (= 5.1.3)
activesupport (= 5.1.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (13.0.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand All @@ -183,9 +186,9 @@ GEM
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
retriable (3.1.1)
ruby_dep (1.5.0)
rubyzip (1.2.1)
Expand Down Expand Up @@ -231,10 +234,10 @@ GEM
dalli
msgpack
redis
thor (0.20.0)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.3)
tzinfo (1.2.7)
thread_safe (~> 0.1)
uber (0.1.0)
uglifier (3.2.0)
Expand All @@ -244,8 +247,8 @@ GEM
jeff (~> 1.0)
multi_xml (~> 0.6.0)
vcr (3.0.3)
warden (1.2.7)
rack (>= 1.0)
warden (1.2.8)
rack (>= 2.0.6)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand Down Expand Up @@ -295,7 +298,7 @@ DEPENDENCIES
webmock (~> 3.0)

RUBY VERSION
ruby 2.4.1p111
ruby 2.6.6p146

BUNDLED WITH
1.15.4
1.17.2
1 change: 0 additions & 1 deletion app/controllers/connect/flagged_markers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class Connect::FlaggedMarkersController < ApplicationController
helper_method :fields

def index
logger.info current_user
@flagged_markers = ::Connect::Marker.unresolved.flagged
end

Expand Down
30 changes: 30 additions & 0 deletions app/controllers/connect/unresolved_markers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Connect::UnresolvedMarkersController < ApplicationController
before_action :authenticate_admin!
helper_method :fields

def index
@unresolved_markers = ::Connect::Marker.unresolved.not_flagged.needs.order(:created_at)
end

def show
@unresolved_marker = ::Connect::Marker.find(params[:id])
end

def update
::Connect::Marker.find(params[:id]).update!(resolved: true)
logger.info "#{current_user.email} marked marker[#{params[:id]}] as resolved."
redirect_to connect_unresolved_markers_url, notice: 'Marker resolved.'
end

# def destroy
# ::Connect::Marker.find(params[:id]).clear_inappropriate_flag!
# logger.info "#{current_user.email} cleared marker[#{params[:id]}]."
# redirect_to connect_flagged_markers_url, notice: 'Marker cleared.'
# end

private

def fields
%w(created_at name phone address categories)
end
end
2 changes: 2 additions & 0 deletions app/models/connect/marker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Marker < ApplicationRecord
scope :by_category, ->(category) { where('categories ? :category', category: category) }
scope :by_device_uuid, ->(device_uuid) { where(device_uuid: device_uuid) }
scope :by_type, ->(type) { where(marker_type: type) }
scope :haves, ->() { by_type(MARKER_TYPES.first) }
scope :needs, ->() { by_type(MARKER_TYPES.second) }
scope :flagged, ->() { where("data ? 'inappropriate_flag'") }
scope :not_flagged, ->() { where.not("data ? 'inappropriate_flag'") }
scope :resolved, -> { where(resolved: true) }
Expand Down
48 changes: 48 additions & 0 deletions app/views/connect/unresolved_markers/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<h1>Unresolved Markers</h1>

<p>
These are map markers from the <a href="http://disasterconnect.io/">Disaster Connect app</a>
that have unresolved needs.
</p>
<p>
As an admin, you have the ability to mark these needs as resolved. Once a need is marked as
resolved, it will remain hidden from public view and this screen as well.
</p>

<table id="data-table" class="shared-table">
<thead>
<tr>
<th></th>
<% fields.map(&:titleize).each do |header| %>
<th><%= header %></th>
<% end %>
<th></th>
</tr>
</thead>

<tbody>
<% @unresolved_markers.each do |row| %>
<tr>
<td><%= link_to 'Show', connect_unresolved_marker_path(row) %></td>
<% fields.each do |field| %>
<td><%= row[field] %></td>
<% end %>
<td>
<%= link_to 'Resolve', connect_unresolved_marker_path(row),
method: :patch,
title: "Mark this need as resolved",
class: "button button-outline" %>
</td>
</tr>
<% end %>
</tbody>
</table>

<script>
window.onload = function() {
$('#data-table').DataTable({
"stateSave": true,
"order": [[ 1, "desc" ]]
});
};
</script>
27 changes: 27 additions & 0 deletions app/views/connect/unresolved_markers/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1>Marker <%= @unresolved_marker.id %></h1>

<%= link_to 'Resolve', connect_unresolved_marker_path(@unresolved_marker),
method: :patch,
title: "Mark this need as resolved",
class: "button button-outline" %> |
<%= link_to 'Back', connect_unresolved_markers_path, class: "button button-outline" %>

<div class="row">
<div class="column">
<h4>Marker Details</h4>
<pre><code><%= JSON.pretty_generate @unresolved_marker.as_json %></code></pre>
</div>
<div class="column">
<div id="map" style="height: 300px; width: 100%"></div>
<script>
$(window).ready(function(){
simpleMap({
selector: "#map",
name: "<%= j @unresolved_marker.name %>",
lat: <%= @unresolved_marker.latitude || 0%>,
lng: <%= @unresolved_marker.longitude || 0%>
})
})
</script>
</div>
</div>
59 changes: 30 additions & 29 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,36 @@
</head>

<body>
<div class="navbar">
<ul>
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Shelters", shelters_path %></li>
<% if user_signed_in? && current_user.admin? %>
<li><%= link_to "Shelters Update Queue", drafts_shelters_path %></li>
<% end %>
<li><%= link_to "Needs", needs_path %></li>
<% if user_signed_in? && current_user.admin? %>
<li><%= link_to "Needs Update Queue", drafts_needs_path %></li>
<li><%= link_to "Users", users_path %></li>
<li><%= link_to "AmazonProducts", amazon_products_path %></li>
<li><%= link_to "Charitable Organizations", charitable_organizations_path %></li>
<li><%= link_to "Pages", pages_path %></li>
<li><%= link_to "Flagged Markers", connect_flagged_markers_path %></li>
<% end %>
<div class="right">
<li class="welcome-span"><span>Welcome <%= user_signed_in? ? current_user.email : "guest" %>!</span></li>
<% if user_signed_in? %>
<li>
<%= link_to "Logout", destroy_user_session_path, method: :delete %>
</li>
<% else %>
<li><%= link_to "Login", new_user_session_path %><li>
<li><%= link_to "Sign up", new_user_registration_path %><li>
<% end %>
</div>
</ul>
</div>
<div class="navbar">
<ul>
<li><%= link_to "Home", root_path %></li>
<%# <li><%= link_to "Shelters", shelters_path %></li> %>
<% if user_signed_in? && current_user.admin? %>
<%# <li><%= link_to "Shelters Update Queue", drafts_shelters_path %></li> %>
<% end %>
<%# <li><%= link_to "Needs", needs_path %></li> %>
<% if user_signed_in? && current_user.admin? %>
<%# <li><%= link_to "Needs Update Queue", drafts_needs_path %></li> %>
<li><%= link_to "Users", users_path %></li>
<%# <li><%= link_to "AmazonProducts", amazon_products_path %></li> %>
<%# <li><%= link_to "Charitable Organizations", charitable_organizations_path %></li> %>
<%# <li><%= link_to "Pages", pages_path %></li> %>
<li><%= link_to "Unresolved Markers", connect_unresolved_markers_path %></li>
<li><%= link_to "Flagged Markers", connect_flagged_markers_path %></li>
<% end %>
<div class="right">
<li class="welcome-span"><span>Welcome <%= user_signed_in? ? current_user.email : "guest" %>!</span></li>
<% if user_signed_in? %>
<li>
<%= link_to "Logout", destroy_user_session_path, method: :delete %>
</li>
<% else %>
<li><%= link_to "Login", new_user_session_path %><li>
<li><%= link_to "Sign up", new_user_registration_path %><li>
<% end %>
</div>
</ul>
</div>
<div class="container">
<p id="notice"><%= notice %></p>
<p id="alert"><%= alert %></p>
Expand Down
Loading