Skip to content

Commit

Permalink
Update admin model, add admin controllers for redirects and admins.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkravets committed Sep 7, 2015
1 parent 91d7917 commit b272428
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 92 deletions.
126 changes: 70 additions & 56 deletions Gemfile.lock
@@ -1,76 +1,85 @@
PATH
remote: .
specs:
ants (0.2.0)
ants (0.2.1)
devise
mongoid (>= 4.0)
mongoid-slug (>= 4.0.0)

GEM
remote: http://rubygems.org/
specs:
actionmailer (4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
actionmailer (4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.1)
actionview (= 4.2.1)
activesupport (= 4.2.1)
actionpack (4.2.4)
actionview (= 4.2.4)
activesupport (= 4.2.4)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.1)
activesupport (= 4.2.1)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.1)
activesupport (= 4.2.1)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4)
activesupport (= 4.2.4)
globalid (>= 0.3.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
activemodel (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
activerecord (4.2.4)
activemodel (= 4.2.4)
activesupport (= 4.2.4)
arel (~> 6.0)
activesupport (4.2.1)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
arel (6.0.3)
bcrypt (3.1.10)
bson (3.2.4)
builder (3.2.2)
connection_pool (2.2.0)
coveralls (0.8.1)
coveralls (0.8.2)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.10.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
devise (3.5.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
globalid (0.3.5)
globalid (0.3.6)
activesupport (>= 4.1.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
json (1.8.2)
loofah (2.0.1)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.5)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.6.1)
minitest (5.8.0)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
Expand All @@ -88,74 +97,79 @@ GEM
mini_portile (~> 0.6.0)
optionable (0.2.0)
origin (2.1.1)
rack (1.6.0)
orm_adapter (0.5.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.1)
actionmailer (= 4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
activemodel (= 4.2.1)
activerecord (= 4.2.1)
activesupport (= 4.2.1)
rails (4.2.4)
actionmailer (= 4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
activemodel (= 4.2.4)
activerecord (= 4.2.4)
activesupport (= 4.2.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.1)
railties (= 4.2.4)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.1)
actionpack (= 4.2.1)
activesupport (= 4.2.1)
railties (4.2.4)
actionpack (= 4.2.4)
activesupport (= 4.2.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-aspic (0.0.2)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
simplecov (0.10.0)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sprockets (3.0.2)
sprockets (3.3.4)
rack (~> 1.0)
sprockets-rails (2.2.4)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
stringex (2.5.2)
term-ansicolor (1.3.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.5)
tins (1.5.1)
tins (1.6.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
warden (1.2.3)
rack (>= 1.0)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion ants.gemspec
Expand Up @@ -22,6 +22,7 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme

s.add_dependency('mongoid', '>= 4.0' )
s.add_dependency('mongoid-slug', '>= 4.0.0')
s.add_dependency('devise')

s.add_development_dependency('rails', [ '>= 4.2' ])
s.add_development_dependency('rspec', [ '>= 2.0' ])
Expand All @@ -30,5 +31,4 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme

s.add_development_dependency('bundler', '~> 1.9')
s.add_development_dependency('rake', '~> 10.0')

end
3 changes: 3 additions & 0 deletions app/controllers/admin/admins_controller.rb
@@ -0,0 +1,3 @@
class Admin::AdminsController < Admin::BaseController
mongosteen
end
4 changes: 4 additions & 0 deletions app/controllers/admin/redirects_controller.rb
@@ -0,0 +1,4 @@
class Admin::RedirectsController < Admin::BaseController
mongosteen
csv_config({ only: [ :old_path, :new_path ] })
end
47 changes: 14 additions & 33 deletions app/models/admin.rb
@@ -1,26 +1,17 @@
# -------------------------------------------------------------------
# Make sure /config/initializers/device.rb includes :email like:
#
# config.case_insensitive_keys = [ :email ]
#
# This is required to make it possible for users login with case
# insensative emails.
# -------------------------------------------------------------------
class Admin
include Mongoid::Document
include Mongoid::Timestamps

include Mongoid::Search
include Ants::Id


## Attributes
field :name
field :permissions, type: Array


# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :registerable, :validatable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :authentication_keys => [ :email ]
# :confirmable, :lockable, :timeoutable, :registerable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable

## Database authenticatable
field :email, type: String, default: ""
Expand All @@ -40,21 +31,9 @@ class Admin
field :current_sign_in_ip, type: String
field :last_sign_in_ip, type: String

## Confirmable
# field :confirmation_token, type: String
# field :confirmed_at, type: Time
# field :confirmation_sent_at, type: Time
# field :unconfirmed_email, type: String # Only if using reconfirmable

## Lockable
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
# field :unlock_token, type: String # Only if unlock strategy is :email or :both
# field :locked_at, type: Time


## Validations
validates :name, presence: true
validates :email, presence: true, allow_blank: false, uniqueness: true


## Search
Expand All @@ -75,15 +54,6 @@ def devise_mailer
end


def last_sign_in_ago
if last_sign_in_at
'Seen ' + ActionController::Base.helpers.time_ago_in_words(last_sign_in_at) + ' ago'
else
'Never seen'
end
end


def _list_item_title
name.empty? ? email : name
end
Expand All @@ -98,6 +68,17 @@ def _list_item_thumbnail
"http://www.gravatar.com/avatar/#{ Digest::MD5.hexdigest(email) }?s=80&d=retro&r=g"
end


private

def last_sign_in_ago
if last_sign_in_at
'Seen ' + ActionController::Base.helpers.time_ago_in_words(last_sign_in_at) + ' ago'
else
'Never seen'
end
end

end


Expand Down
1 change: 0 additions & 1 deletion app/models/redirect.rb
@@ -1,7 +1,6 @@
class Redirect
include Mongoid::Document
include Mongoid::Timestamps

include Mongoid::Search
include Ants::Id

Expand Down
1 change: 1 addition & 0 deletions lib/ants.rb
@@ -1,5 +1,6 @@
require 'mongoid'
require 'mongoid_slug'
require 'devise'

module Ants
require 'ants/engine'
Expand Down
2 changes: 1 addition & 1 deletion lib/ants/version.rb
@@ -1,3 +1,3 @@
module Ants
VERSION = "0.2.0"
VERSION = "0.2.1"
end

0 comments on commit b272428

Please sign in to comment.