iplemented rails admin
This commit is contained in:
@@ -40,6 +40,10 @@ gem 'puma'
|
|||||||
gem 'geocoder'
|
gem 'geocoder'
|
||||||
gem 'rails_12factor'
|
gem 'rails_12factor'
|
||||||
|
|
||||||
|
gem 'rails_admin'
|
||||||
|
|
||||||
|
gem 'mongoid_paranoia'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug'
|
gem 'byebug'
|
||||||
|
|||||||
@@ -68,9 +68,13 @@ GEM
|
|||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.6.0)
|
execjs (2.6.0)
|
||||||
|
font-awesome-rails (4.6.1.0)
|
||||||
|
railties (>= 3.2, < 5.1)
|
||||||
geocoder (1.3.1)
|
geocoder (1.3.1)
|
||||||
globalid (0.3.6)
|
globalid (0.3.6)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
|
haml (4.0.7)
|
||||||
|
tilt
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
jbuilder (2.4.1)
|
jbuilder (2.4.1)
|
||||||
activesupport (>= 3.0.0, < 5.1)
|
activesupport (>= 3.0.0, < 5.1)
|
||||||
@@ -79,7 +83,12 @@ GEM
|
|||||||
rails-dom-testing (>= 1, < 3)
|
rails-dom-testing (>= 1, < 3)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
|
jquery-ui-rails (5.0.5)
|
||||||
|
railties (>= 3.2.16)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
|
kaminari (0.16.3)
|
||||||
|
actionpack (>= 3.0.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
loofah (2.0.3)
|
loofah (2.0.3)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.6.4)
|
mail (2.6.4)
|
||||||
@@ -97,11 +106,18 @@ GEM
|
|||||||
mongo (~> 2.1)
|
mongo (~> 2.1)
|
||||||
origin (~> 2.1)
|
origin (~> 2.1)
|
||||||
tzinfo (>= 0.3.37)
|
tzinfo (>= 0.3.37)
|
||||||
|
mongoid-compatibility (0.3.1)
|
||||||
|
activesupport
|
||||||
|
mongoid (>= 2.0)
|
||||||
mongoid-rspec (3.0.0)
|
mongoid-rspec (3.0.0)
|
||||||
mongoid (~> 5.0)
|
mongoid (~> 5.0)
|
||||||
rake
|
rake
|
||||||
rspec (~> 3.3)
|
rspec (~> 3.3)
|
||||||
|
mongoid_paranoia (0.2.1)
|
||||||
|
mongoid (>= 4)
|
||||||
|
mongoid-compatibility
|
||||||
multi_json (1.11.2)
|
multi_json (1.11.2)
|
||||||
|
nested_form (0.3.2)
|
||||||
nokogiri (1.6.7.2)
|
nokogiri (1.6.7.2)
|
||||||
mini_portile2 (~> 2.0.0.rc2)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
origin (2.2.0)
|
origin (2.2.0)
|
||||||
@@ -113,6 +129,9 @@ GEM
|
|||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
puma (3.2.0)
|
puma (3.2.0)
|
||||||
rack (1.6.4)
|
rack (1.6.4)
|
||||||
|
rack-pjax (0.8.0)
|
||||||
|
nokogiri (~> 1.5)
|
||||||
|
rack (~> 1.1)
|
||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (4.2.6)
|
rails (4.2.6)
|
||||||
@@ -140,6 +159,20 @@ GEM
|
|||||||
rails_12factor (0.0.3)
|
rails_12factor (0.0.3)
|
||||||
rails_serve_static_assets
|
rails_serve_static_assets
|
||||||
rails_stdout_logging
|
rails_stdout_logging
|
||||||
|
rails_admin (0.8.1)
|
||||||
|
builder (~> 3.1)
|
||||||
|
coffee-rails (~> 4.0)
|
||||||
|
font-awesome-rails (>= 3.0, < 5)
|
||||||
|
haml (~> 4.0)
|
||||||
|
jquery-rails (>= 3.0, < 5)
|
||||||
|
jquery-ui-rails (~> 5.0)
|
||||||
|
kaminari (~> 0.14)
|
||||||
|
nested_form (~> 0.3)
|
||||||
|
rack-pjax (~> 0.7)
|
||||||
|
rails (~> 4.0)
|
||||||
|
remotipart (~> 1.0)
|
||||||
|
safe_yaml (~> 1.0)
|
||||||
|
sass-rails (>= 4.0, < 6)
|
||||||
rails_serve_static_assets (0.0.5)
|
rails_serve_static_assets (0.0.5)
|
||||||
rails_stdout_logging (0.0.5)
|
rails_stdout_logging (0.0.5)
|
||||||
railties (4.2.6)
|
railties (4.2.6)
|
||||||
@@ -150,6 +183,7 @@ GEM
|
|||||||
rake (11.1.1)
|
rake (11.1.1)
|
||||||
rdoc (4.2.2)
|
rdoc (4.2.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
|
remotipart (1.2.1)
|
||||||
rspec (3.4.0)
|
rspec (3.4.0)
|
||||||
rspec-core (~> 3.4.0)
|
rspec-core (~> 3.4.0)
|
||||||
rspec-expectations (~> 3.4.0)
|
rspec-expectations (~> 3.4.0)
|
||||||
@@ -171,6 +205,7 @@ GEM
|
|||||||
rspec-mocks (~> 3.4.0)
|
rspec-mocks (~> 3.4.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.4.0)
|
||||||
rspec-support (3.4.1)
|
rspec-support (3.4.1)
|
||||||
|
safe_yaml (1.0.4)
|
||||||
sass (3.4.21)
|
sass (3.4.21)
|
||||||
sass-rails (5.0.4)
|
sass-rails (5.0.4)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
@@ -233,11 +268,13 @@ DEPENDENCIES
|
|||||||
jquery-rails
|
jquery-rails
|
||||||
mongoid (~> 5.0.0)
|
mongoid (~> 5.0.0)
|
||||||
mongoid-rspec (= 3.0.0)
|
mongoid-rspec (= 3.0.0)
|
||||||
|
mongoid_paranoia
|
||||||
pry-rails
|
pry-rails
|
||||||
puma
|
puma
|
||||||
rails (~> 4.2)
|
rails (~> 4.2)
|
||||||
rails-i18n
|
rails-i18n
|
||||||
rails_12factor
|
rails_12factor
|
||||||
|
rails_admin
|
||||||
rspec-rails (~> 3.0)
|
rspec-rails (~> 3.0)
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
sdoc (~> 0.4.0)
|
sdoc (~> 0.4.0)
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
class Admin::SupportersController < Admin::ApplicationController
|
|
||||||
def index
|
|
||||||
@supporters = Supporter.desc(:created_at)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
class Supporter
|
class Supporter
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include Mongoid::Paranoia
|
||||||
include Geocoder::Model::Mongoid
|
include Geocoder::Model::Mongoid
|
||||||
|
|
||||||
COUNTER_START = 322
|
COUNTER_START = 322
|
||||||
@@ -20,6 +21,9 @@ class Supporter
|
|||||||
field :coordinates, type: Array
|
field :coordinates, type: Array
|
||||||
field :comments, type: String
|
field :comments, type: String
|
||||||
field :language, type: String
|
field :language, type: String
|
||||||
|
field :email2, type: String
|
||||||
|
field :email3, type: String
|
||||||
|
field :duplicate, type: Boolean, default: false
|
||||||
|
|
||||||
validates :first_name, presence: true
|
validates :first_name, presence: true
|
||||||
validates :last_name, presence: true
|
validates :last_name, presence: true
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
h1 #{@supporters.count} Unterstützer
|
|
||||||
table.table
|
|
||||||
tr
|
|
||||||
th Eingeschrieben
|
|
||||||
th Adresse
|
|
||||||
th Unterstützung
|
|
||||||
th width="20%" Kommentar
|
|
||||||
- @supporters.each do |supporter|
|
|
||||||
tr
|
|
||||||
td = distance_of_time_in_words_to_now(supporter.created_at)
|
|
||||||
td
|
|
||||||
address
|
|
||||||
= "#{supporter.first_name} #{supporter.last_name}"
|
|
||||||
=
|
|
||||||
br
|
|
||||||
= supporter.street
|
|
||||||
br
|
|
||||||
= "#{supporter.zip} #{supporter.city}"
|
|
||||||
td
|
|
||||||
= supporter.support
|
|
||||||
- if supporter.li_membership
|
|
||||||
br
|
|
||||||
| Mitgliedschaft
|
|
||||||
td = supporter.comments
|
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
RailsAdmin.config do |config|
|
||||||
|
config.authorize_with do
|
||||||
|
unless Rails.env.development?
|
||||||
|
authenticate_or_request_with_http_basic('Administration') do |username, password|
|
||||||
|
username == 'admin' && password == ENV['ADMIN_PASSWORD']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config.model 'Supporter' do
|
||||||
|
list do
|
||||||
|
field :duplicate
|
||||||
|
field :first_name
|
||||||
|
field :last_name
|
||||||
|
field :zip
|
||||||
|
field :city
|
||||||
|
field :email
|
||||||
|
field :language
|
||||||
|
field :support
|
||||||
|
field :li_membership
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
### Popular gems integration
|
||||||
|
|
||||||
|
## == Devise ==
|
||||||
|
# config.authenticate_with do
|
||||||
|
# warden.authenticate! scope: :user
|
||||||
|
# end
|
||||||
|
# config.current_user_method(&:current_user)
|
||||||
|
|
||||||
|
## == Cancan ==
|
||||||
|
# config.authorize_with :cancan
|
||||||
|
|
||||||
|
## == 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
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
de:
|
||||||
|
admin:
|
||||||
|
js:
|
||||||
|
true: True
|
||||||
|
false: False
|
||||||
|
is_present: Is present
|
||||||
|
is_blank: Is blank
|
||||||
|
date: Date ...
|
||||||
|
between_and_: Between ... and ...
|
||||||
|
today: Today
|
||||||
|
yesterday: Yesterday
|
||||||
|
this_week: This week
|
||||||
|
last_week: Last week
|
||||||
|
number: Number ...
|
||||||
|
contains: Contains
|
||||||
|
is_exactly: Is exactly
|
||||||
|
starts_with: Starts with
|
||||||
|
ends_with: Ends with
|
||||||
|
too_many_objects: "Too many objects, use search box above"
|
||||||
|
no_objects: "No objects found"
|
||||||
|
loading: "Loading..."
|
||||||
|
toggle_navigation: Toggle navigation
|
||||||
|
home:
|
||||||
|
name: "Home"
|
||||||
|
pagination:
|
||||||
|
previous: "« Prev"
|
||||||
|
next: "Next »"
|
||||||
|
truncate: "…"
|
||||||
|
misc:
|
||||||
|
search: "Search"
|
||||||
|
filter: "Filter"
|
||||||
|
refresh: "Refresh"
|
||||||
|
show_all: "Show all"
|
||||||
|
add_filter: "Add filter"
|
||||||
|
bulk_menu_title: "Selected items"
|
||||||
|
remove: "Remove"
|
||||||
|
add_new: "Add new"
|
||||||
|
chosen: "Chosen %{name}"
|
||||||
|
chose_all: "Choose all"
|
||||||
|
clear_all: "Clear all"
|
||||||
|
up: "Up"
|
||||||
|
down: "Down"
|
||||||
|
navigation: "Navigation"
|
||||||
|
navigation_static_label: "Links"
|
||||||
|
log_out: "Log out"
|
||||||
|
ago: "ago"
|
||||||
|
flash:
|
||||||
|
successful: "%{name} successfully %{action}"
|
||||||
|
error: "%{name} failed to be %{action}"
|
||||||
|
noaction: "No actions were taken"
|
||||||
|
model_not_found: "Model '%{model}' could not be found"
|
||||||
|
object_not_found: "%{model} with id '%{id}' could not be found"
|
||||||
|
table_headers:
|
||||||
|
model_name: "Model name"
|
||||||
|
last_created: "Last created"
|
||||||
|
records: "Records"
|
||||||
|
username: "User"
|
||||||
|
changes: "Changes"
|
||||||
|
created_at: "Date/Time"
|
||||||
|
item: "Item"
|
||||||
|
message: "Message"
|
||||||
|
actions:
|
||||||
|
dashboard:
|
||||||
|
title: "Site Administration"
|
||||||
|
menu: "Dashboard"
|
||||||
|
breadcrumb: "Dashboard"
|
||||||
|
index:
|
||||||
|
title: "List of %{model_label_plural}"
|
||||||
|
menu: "List"
|
||||||
|
breadcrumb: "%{model_label_plural}"
|
||||||
|
show:
|
||||||
|
title: "Details for %{model_label} '%{object_label}'"
|
||||||
|
menu: "Show"
|
||||||
|
breadcrumb: "%{object_label}"
|
||||||
|
show_in_app:
|
||||||
|
menu: "Show in app"
|
||||||
|
new:
|
||||||
|
title: "New %{model_label}"
|
||||||
|
menu: "Add new"
|
||||||
|
breadcrumb: "New"
|
||||||
|
link: "Add a new %{model_label}"
|
||||||
|
done: "created"
|
||||||
|
edit:
|
||||||
|
title: "Edit %{model_label} '%{object_label}'"
|
||||||
|
menu: "Edit"
|
||||||
|
breadcrumb: "Edit"
|
||||||
|
link: "Edit this %{model_label}"
|
||||||
|
done: "updated"
|
||||||
|
delete:
|
||||||
|
title: "Delete %{model_label} '%{object_label}'"
|
||||||
|
menu: "Delete"
|
||||||
|
breadcrumb: "Delete"
|
||||||
|
link: "Delete '%{object_label}'"
|
||||||
|
done: "deleted"
|
||||||
|
bulk_delete:
|
||||||
|
title: "Delete %{model_label_plural}"
|
||||||
|
menu: "Multiple delete"
|
||||||
|
breadcrumb: "Multiple delete"
|
||||||
|
bulk_link: "Delete selected %{model_label_plural}"
|
||||||
|
export:
|
||||||
|
title: "Export %{model_label_plural}"
|
||||||
|
menu: "Export"
|
||||||
|
breadcrumb: "Export"
|
||||||
|
link: "Export found %{model_label_plural}"
|
||||||
|
bulk_link: "Export selected %{model_label_plural}"
|
||||||
|
done: "exported"
|
||||||
|
history_index:
|
||||||
|
title: "History for %{model_label_plural}"
|
||||||
|
menu: "History"
|
||||||
|
breadcrumb: "History"
|
||||||
|
history_show:
|
||||||
|
title: "History for %{model_label} '%{object_label}'"
|
||||||
|
menu: "History"
|
||||||
|
breadcrumb: "History"
|
||||||
|
form:
|
||||||
|
cancel: "Cancel"
|
||||||
|
basic_info: "Basic info"
|
||||||
|
required: "Required"
|
||||||
|
optional: "Optional"
|
||||||
|
one_char: "character"
|
||||||
|
char_length_up_to: "length up to"
|
||||||
|
char_length_of: "length of"
|
||||||
|
save: "Save"
|
||||||
|
save_and_add_another: "Save and add another"
|
||||||
|
save_and_edit: "Save and edit"
|
||||||
|
all_of_the_following_related_items_will_be_deleted: "? The following related items may be deleted or orphaned:"
|
||||||
|
are_you_sure_you_want_to_delete_the_object: "Are you sure you want to delete this %{model_name}"
|
||||||
|
confirmation: "Yes, I'm sure"
|
||||||
|
bulk_delete: "The following objects will be deleted, which may delete or orphan some of their related dependencies:"
|
||||||
|
new_model: "%{name} (new)"
|
||||||
|
export:
|
||||||
|
confirmation: "Export to %{name}"
|
||||||
|
select: "Select fields to export"
|
||||||
|
select_all_fields: "Select All Fields"
|
||||||
|
fields_from: "Fields from %{name}"
|
||||||
|
fields_from_associated: "Fields from associated %{name}"
|
||||||
|
display: "Display %{name}: %{type}"
|
||||||
|
options_for: "Options for %{name}"
|
||||||
|
empty_value_for_associated_objects: "<empty>"
|
||||||
|
click_to_reverse_selection: 'Click to reverse selection'
|
||||||
|
csv:
|
||||||
|
header_for_root_methods: "%{name}" # 'model' is available
|
||||||
|
header_for_association_methods: "%{name} [%{association}]"
|
||||||
|
encoding_to: "Encode to"
|
||||||
|
encoding_to_help: "Choose output encoding. Leave empty to let current input encoding untouched: (%{name})"
|
||||||
|
skip_header: "No header"
|
||||||
|
skip_header_help: "Do not output a header (no fields description)"
|
||||||
|
default_col_sep: ","
|
||||||
|
col_sep: "Column separator"
|
||||||
|
col_sep_help: "Leave blank for default ('%{value}')" # value is default_col_sep
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
development:
|
development:
|
||||||
clients:
|
clients:
|
||||||
default:
|
default:
|
||||||
database: ch420_development
|
# database: ch420_development
|
||||||
# database: heroku_t242kdp0
|
database: heroku_t242kdp0
|
||||||
hosts:
|
hosts:
|
||||||
- localhost:27017
|
- localhost:27017
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -3,9 +3,10 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
get '/map', to: 'pages#map', as: :map
|
get '/map', to: 'pages#map', as: :map
|
||||||
|
# resources :supporters, only: :index
|
||||||
resources :supporters, only: :index
|
|
||||||
end
|
end
|
||||||
|
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
||||||
|
|
||||||
get '/cities_autocomplete', to: 'cities_autocomplete#index', as: :cities_autocomplete
|
get '/cities_autocomplete', to: 'cities_autocomplete#index', as: :cities_autocomplete
|
||||||
scope '/:locale' do
|
scope '/:locale' do
|
||||||
get '/', to: 'supporters#new'
|
get '/', to: 'supporters#new'
|
||||||
|
|||||||
Reference in New Issue
Block a user