Skip to content

Commit

Permalink
Release #487
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0grog committed Feb 18, 2019
2 parents a676a09 + 4193692 commit bc52855
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 83 deletions.
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gem 'sentry-raven'
gem 'readthis'
gem 'hiredis'
gem 'google-api-client'
gem 'addressable', '~> 2.5'
gem 'addressable', '~> 2.6'

# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
Expand All @@ -44,7 +44,7 @@ gem 'bootsnap', '>= 1.3.1', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem 'rubocop', '~> 0.60.0', require: false
gem 'rubocop', '~> 0.63.1', require: false
gem 'dotenv-rails'
end

Expand All @@ -63,8 +63,6 @@ group :test do
end

group :production do
gem 'newrelic_rpm'

# Send transactional e-mail with Postmark
gem 'postmark-rails', group: :postmark
end
Expand Down
55 changes: 26 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
aws-partitions (1.128.0)
aws-sdk-core (3.44.2)
aws-partitions (1.136.0)
aws-sdk-core (3.46.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-kms (1.13.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.30.0)
aws-sdk-s3 (1.30.1)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
Expand All @@ -81,26 +81,26 @@ GEM
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
dotenv (2.5.0)
dotenv-rails (2.5.0)
dotenv (= 2.5.0)
dotenv (2.6.0)
dotenv-rails (2.6.0)
dotenv (= 2.6.0)
railties (>= 3.2, < 6.0)
erubi (1.8.0)
execjs (2.7.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.9.25)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
google-api-client (0.27.1)
google-api-client (0.28.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.5, < 0.8.0)
googleauth (>= 0.5, < 0.10.0)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
signet (~> 0.10)
googleauth (0.7.1)
googleauth (0.8.0)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
Expand All @@ -113,9 +113,9 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.4.0)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
jaro_winkler (1.5.2)
jmespath (1.4.0)
json (2.1.0)
jwt (2.1.0)
Expand Down Expand Up @@ -145,23 +145,21 @@ GEM
multi_xml (0.6.0)
multipart-post (2.0.0)
mustermann (1.0.3)
newrelic_rpm (5.6.0.349)
nio4r (2.3.1)
nokogiri (1.10.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
oj (3.7.6)
oj (3.7.8)
orm_adapter (0.5.0)
os (1.0.0)
parallel (1.12.1)
parser (2.5.3.0)
parallel (1.13.0)
parser (2.6.0.0)
ast (~> 2.4.0)
pg (1.1.3)
postmark (1.14.0)
pg (1.1.4)
postmark (1.15.0)
json
rake
postmark-rails (0.18.0)
postmark-rails (0.19.0)
actionmailer (>= 3.0.0)
postmark (~> 1.14.0)
postmark (~> 1.15.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -227,7 +225,7 @@ GEM
resque-heroku-signals (1.27.4.3)
resque (= 1.27.4)
retriable (3.1.2)
rubocop (0.60.0)
rubocop (0.63.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
Expand All @@ -249,7 +247,7 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sentry-raven (2.7.4)
sentry-raven (2.9.0)
faraday (>= 0.7.6, < 1.0)
signet (0.11.0)
addressable (~> 2.3)
Expand Down Expand Up @@ -281,7 +279,7 @@ GEM
uber (0.1.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0)
unicode-display_width (1.4.1)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.2.7)
Expand All @@ -303,7 +301,7 @@ PLATFORMS
ruby

DEPENDENCIES
addressable (~> 2.5)
addressable (~> 2.6)
aws-sdk-s3 (~> 1.30)
bootsnap (>= 1.3.1)
byebug
Expand All @@ -314,7 +312,6 @@ DEPENDENCIES
httparty
jwt (~> 2.1)
listen (~> 3.1)
newrelic_rpm
oj (~> 3.7)
pg (~> 1.1)
postmark-rails
Expand All @@ -325,7 +322,7 @@ DEPENDENCIES
readthis
resque
resque-heroku-signals
rubocop (~> 0.60.0)
rubocop (~> 0.63.1)
sass-rails (~> 5.0)
sentry-raven
spring
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/edgi-govdata-archiving/overview/blob/master/CONDUCT.md)

# web-monitoring-db

This repository is the database and API underlying the EDGI [Web Monitoring Project](https://github.com/edgi-govdata-archiving/web-monitoring).
Expand Down Expand Up @@ -223,6 +225,7 @@ This project wouldn’t exist without a lot of amazing people’s help. Thanks t
| [📖](# "Documentation") [👀](# "Reviewer") | [Dan Allan](https://github.com/danielballan) |
| [📋](# "Organizer") [🔍](# "Funding/Grant Finder") | [Andrew Bergman](https://github.com/ambergman) |
| [💻](# "Code") [🚇](# "Infrastructure") [📖](# "Documentation") [💬](# "Answering Questions") [👀](# "Reviewer") | [Rob Brackett](https://github.com/Mr0grog) |
| [💻](# "Code") | [Alessandro Caporrini](https://github.com/acaporrini) |
| [📖](# "Documentation") | [Patrick Connolly](https://github.com/patcon) |
| [💻](# "Code") | [Robert Dalin](https://github.com/rdalin82) |
| [💻](# "Code") | [Kate Donaldson](https://github.com/katelovescode) |
Expand Down
40 changes: 40 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,46 @@ def destroy_user
end
end

def promote_user_to_admin
@user = User.find(params[:id])

@user.update_attributes!(admin: true)

respond_to do |format|
format.html do
if !@user.admin?
redirect_to admin_path, alert: 'There was an error while promoting the user to admin'
else
redirect_to admin_path, notice: "#{@user.email} has been promoted to admin"
end
end

format.json do
render json: { data: { success: @user.admin? } }
end
end
end

def demote_user_from_admin
@user = User.find(params[:id])

@user.update_attributes!(admin: false)

respond_to do |format|
format.html do
if @user.admin?
redirect_to admin_path, alert: 'There was an error while demoting the user from admin'
else
redirect_to admin_path, notice: "#{@user.email} has been demoted from admin"
end
end

format.json do
render json: { data: { success: !@user.admin? } }
end
end
end


protected

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/import_versions_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def perform(import)
begin
import_raw_data(@import.load_data)
@added.uniq {|version| version.uuid}.each do |version|
AnalyzeChangeJob.perform_later(version)
AnalyzeChangeJob.perform_later(version) if version.different?
end
rescue StandardError => error
@import.processing_errors << if Rails.env.development?
Expand Down
16 changes: 16 additions & 0 deletions app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<th>ID</th>
<th>E-mail</th>
<th>Confirmed</th>
<th>Admin</th>
<th>Added</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -14,13 +16,27 @@
<td><%= user.id %></td>
<td><%= user.email %></td>
<td><% if user.confirmed? %>✔︎<% end %></td>
<td><% if user.admin? %>✔︎<% end %></td>
<td><%= user.created_at %></td>
<td>
<%= form_tag(controller: "admin", action: "destroy_user", method: "delete") do %>
<input type="hidden" name="id" value="<%= user.id %>">
<input type="submit" value="Delete Account">
<% end %>
</td>
<td>
<% if user.admin? %>
<%= form_tag(controller: "admin", action: "demote_user_from_admin", method: :put) do %>
<input type="submit" value="Demote from admin">
<input type="hidden" name="id" value="<%= user.id %>">
<% end %>
<% else %>
<%= form_tag(controller: "admin", action: "promote_user_to_admin", method: "put") do %>
<input type="submit" value="Promote to admin" >
<input type="hidden" name="id" value="<%= user.id %>">
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
Expand Down
45 changes: 0 additions & 45 deletions config/newrelic.yml

This file was deleted.

5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
post 'admin/cancel_invitation'
delete 'admin/destroy_user'
post 'admin/destroy_user'

put 'admin/promote_user_to_admin'
post 'admin/promote_user_to_admin'
put 'admin/demote_user_from_admin'
post 'admin/demote_user_from_admin'
get 'healthcheck', to: 'healthcheck#index'
end
Loading

0 comments on commit bc52855

Please sign in to comment.