Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rails admin #191

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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 .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
capybara-*.html
/log/*.log*
coverage
tmp
tmp/cache
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'doorkeeper', '~> 4'
# Revise if this is needed after Rails 6.0
gem 'image_processing'

gem 'rails_admin'
gem 'ancestry'
gem 'api-pagination'
gem 'api_cache'
Expand Down
128 changes: 81 additions & 47 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ GEM
globalid (>= 0.3.6)
activemodel (6.0.3.3)
activesupport (= 6.0.3.3)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.0.3.3)
activemodel (= 6.0.3.3)
activesupport (= 6.0.3.3)
Expand Down Expand Up @@ -124,15 +128,14 @@ GEM
parallel
choice (0.2.0)
coderay (1.1.3)
concurrent-ruby (1.1.7)
concurrent-ruby (1.1.8)
connection_pool (2.2.2)
countries (2.1.4)
i18n_data (~> 0.8.0)
money (~> 6.9)
sixarm_ruby_unaccent (~> 1.1)
unicode_utils (~> 1.4)
crack (0.4.5)
rexml
crack (0.4.4)
crass (1.0.6)
css_parser (1.7.0)
addressable
Expand All @@ -142,7 +145,7 @@ GEM
activesupport
diff-lcs (1.4.4)
diffy (3.3.0)
docile (1.3.4)
docile (1.3.2)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
doorkeeper (4.4.3)
Expand All @@ -161,12 +164,12 @@ GEM
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
railties (>= 5.0.0)
faker (2.15.1)
faker (2.14.0)
i18n (>= 1.6, < 2)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
fast_blank (1.0.0)
ffi (1.14.2)
ffi (1.13.1)
fog-aws (3.5.1)
fog-core (~> 2.1)
fog-json (~> 1.1)
Expand Down Expand Up @@ -206,7 +209,7 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
haml (5.2.1)
haml (5.1.2)
temple (>= 0.8.0)
tilt
hashdiff (1.0.1)
Expand All @@ -225,6 +228,12 @@ GEM
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jmespath (1.4.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.3.1)
jwt (2.2.1)
kaminari (1.2.1)
Expand All @@ -239,10 +248,10 @@ GEM
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
listen (3.4.0)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.8.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.8)
Expand Down Expand Up @@ -273,6 +282,7 @@ GEM
multipart-post (2.1.1)
mustermann (1.0.3)
nenv (0.3.0)
nested_form (0.3.2)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
Expand All @@ -293,10 +303,10 @@ GEM
rack (>= 1.2, < 3)
oj (3.7.12)
oj_mimic_json (1.0.1)
parallel (1.20.1)
parallel_tests (3.4.0)
parallel (1.19.2)
parallel_tests (3.3.0)
parallel
parser (3.0.0.0)
parser (2.7.1.5)
ast (~> 2.4.1)
pg (1.1.4)
pg_search (2.2.0)
Expand Down Expand Up @@ -324,14 +334,17 @@ GEM
raabro (1.1.6)
racc (1.5.2)
rack (2.2.3)
rack-attack (6.3.1)
rack-attack (6.0.0)
rack (>= 1.0, < 3)
rack-cache (1.9.0)
rack (>= 0.4)
rack-contrib (2.1.0)
rack (~> 2.0)
rack-cors (1.0.5)
rack (>= 1.6.0)
rack-pjax (1.1.0)
nokogiri (~> 1.5)
rack (>= 1.1)
rack-protection (2.0.5)
rack
rack-test (1.1.0)
Expand Down Expand Up @@ -366,6 +379,18 @@ GEM
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_admin (2.0.2)
activemodel-serializers-xml (>= 1.0)
builder (~> 3.1)
haml (>= 4.0, < 6)
jquery-rails (>= 3.0, < 5)
jquery-ui-rails (>= 5.0, < 7)
kaminari (>= 0.14, < 2.0)
nested_form (~> 0.3)
rack-pjax (>= 0.7)
rails (>= 5.0, < 7)
remotipart (~> 1.3)
sassc-rails (>= 1.3, < 3)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (6.0.3.3)
Expand All @@ -385,9 +410,10 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.3.0)
rdoc (6.2.1)
redis (4.2.2)
regexp_parser (2.0.3)
regexp_parser (1.8.0)
remotipart (1.4.4)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
Expand All @@ -397,41 +423,41 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.1)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (4.0.2)
rspec-support (~> 3.9.0)
rspec-rails (4.0.1)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.1)
rubocop (1.8.0)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (0.92.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
rubocop-ast (>= 0.5.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.0)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.5.0)
parser (>= 2.7.1.5)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.11.0)
ruby-progressbar (1.10.1)
ruby-vips (2.0.14)
ffi (~> 1.9)
ruby2ruby (2.4.4)
Expand All @@ -444,6 +470,14 @@ GEM
rufus-scheduler (3.6.0)
fugit (~> 1.1, >= 1.1.6)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sentry-raven (2.9.0)
faraday (>= 0.7.6, < 1.0)
sexp_processor (4.15.1)
Expand All @@ -453,12 +487,10 @@ GEM
rack (>= 1.5.0)
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5)
simplecov (0.21.1)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
sinatra (2.0.5)
mustermann (~> 1.0)
rack (~> 2.0)
Expand All @@ -478,27 +510,28 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.21.1)
sshkit (1.21.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
sshkit-sudo (0.1.0)
sshkit (~> 1.8)
stamp (0.6.0)
temple (0.8.2)
terminal-table (1.6.0)
thor (1.0.1)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.2)
timecop (0.9.1)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (2.0.0)
unicode-display_width (1.7.0)
unicode_utils (1.4.0)
vcr (6.0.0)
webmock (3.11.0)
webmock (3.9.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down Expand Up @@ -567,6 +600,7 @@ DEPENDENCIES
rails (= 6.0.3.3)
rails-erd
rails_12factor
rails_admin
ransack
rdoc
redis
Expand Down
Empty file added app/assets/config/manifest.js
Empty file.
7 changes: 7 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class Application < Rails::Application
end
end

# Needed for rails_admin
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Flash
config.middleware.use Rack::MethodOverride
config.middleware.use ActionDispatch::Session::CookieStore, {:key=>"_smartcitizen_session"}
# end rails_admin

config.api_only = true
end
end
52 changes: 52 additions & 0 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
RailsAdmin.config do |config|

### Popular gems integration

## == Devise ==
# config.authenticate_with do
# warden.authenticate! scope: :user
# end
# config.current_user_method(&:current_user)

config.authenticate_with do
authenticate_or_request_with_http_basic('Login required') do |username, password|
user = User.where(username: username).first
if user && user.authenticate(password)
user.is_admin?
else
false
end
end
end

## == CancanCan ==
# config.authorize_with :cancancan

## == Pundit ==
# config.authorize_with :pundit

## == PaperTrail ==
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0

### More at https://github.com/sferik/rails_admin/wiki/Base-configuration

## == Gravatar integration ==
## To disable Gravatar integration in Navigation Bar set to false
# config.show_gravatar = true

config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app

## With an audit adapter, you can add:
# history_index
# history_show
end
end
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require "sidekiq/web"
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

if Rails.env.production?
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
username == ENV["sidekiq_username"] && password == ENV["sidekiq_password"]
end
end

mount Sidekiq::Web, at: "/sidekiq"

api_version(module: "V0", path: {value: "v0"}, header: {name: "Accept", value: "application/vnd.smartcitizen; version=0"}, default: true, defaults: { format: :json }) do
Expand Down