Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Admin panel replaced with ActiveAdmin

  • Loading branch information...
commit 434f7f70f0a2bdad1dd6498173ec89d44564eb90 1 parent 3a9a58c
@marcinbiegun authored
Showing with 341 additions and 379 deletions.
  1. +1 −2  Gemfile
  2. +6 −7 Gemfile.lock
  3. +38 −0 app/admin/dashboards.rb
  4. +1 −0  app/assets/javascripts/active_admin.js
  5. +6 −0 app/assets/stylesheets/active_admin.css.scss
  6. +0 −3  app/assets/stylesheets/admin/admins.css.scss
  7. +8 −1 app/assets/stylesheets/application.css
  8. +0 −45 app/controllers/admin/admins_controller.rb
  9. +0 −44 app/controllers/admin/artists_controller.rb
  10. +0 −44 app/controllers/admin/external_audios_controller.rb
  11. +0 −16 app/controllers/admin/panel_controller.rb
  12. +0 −44 app/controllers/admin/releases_controller.rb
  13. +0 −44 app/controllers/admin/tracks_controller.rb
  14. +0 −2  app/helpers/admin/admins_helper.rb
  15. +0 −11 app/models/admin.rb
  16. +16 −0 app/models/admin_user.rb
  17. +0 −1  app/views/admin/panel/index.html.haml
  18. +0 −1  app/views/admin/panel/panel.html.haml
  19. +103 −0 config/initializers/active_admin.rb
  20. +29 −14 config/initializers/devise.rb
  21. +0 −50 config/locales/devise.en.yml
  22. +2 −14 config/routes.rb
  23. +25 −0 db/migrate/20111116191732_drop_admins_table.rb
  24. +31 −0 db/migrate/20111116193104_add_devise_to_admin_users.rb
  25. +16 −0 db/migrate/20111116203110_create_admin_notes.rb
  26. +25 −0 db/migrate/20111116203111_move_admin_notes_to_comments.rb
  27. +19 −6 db/schema.rb
  28. +3 −3 db/seeds.rb
  29. +11 −0 test/fixtures/admin_users.yml
  30. +0 −7 test/fixtures/admins.yml
  31. +0 −7 test/functional/admin/admins_controller_test.rb
  32. +1 −1  test/unit/{admin_test.rb → admin_user_test.rb}
  33. +0 −4 test/unit/helpers/admin/admins_helper_test.rb
  34. +0 −4 test/unit/helpers/groups_helper_test.rb
  35. +0 −4 test/unit/helpers/static_helper_test.rb
View
3  Gemfile
@@ -9,7 +9,6 @@ gem 'sqlite3'
gem 'therubyracer'
# Application
-gem 'devise'
gem 'formtastic'
gem 'haml'
gem 'haml-rails'
@@ -18,11 +17,11 @@ gem 'paperclip'
group :assets do
gem 'coffee-rails', "~> 3.1.0"
- gem 'sass-rails', " ~> 3.1.0"
gem 'uglifier'
end
# ActiveAdmin
gem 'activeadmin'
+gem 'sass-rails'
gem 'meta_search', '>= 1.1.0.pre'
View
13 Gemfile.lock
@@ -52,10 +52,10 @@ GEM
execjs
coffee-script-source (1.1.3)
columnize (0.3.4)
- devise (1.4.9)
+ devise (1.5.0)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
- warden (~> 1.0.3)
+ warden (~> 1.1)
erubis (2.7.0)
execjs (1.2.9)
multi_json (~> 1.0)
@@ -82,7 +82,7 @@ GEM
json (1.6.1)
kaminari (0.12.4)
rails (>= 3.0.0)
- libv8 (3.3.10.2)
+ libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
@@ -163,10 +163,10 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
- uglifier (1.0.4)
+ uglifier (1.1.0)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
- warden (1.0.6)
+ warden (1.1.0)
rack (>= 1.0)
PLATFORMS
@@ -175,7 +175,6 @@ PLATFORMS
DEPENDENCIES
activeadmin
coffee-rails (~> 3.1.0)
- devise
execjs
formtastic
haml
@@ -186,7 +185,7 @@ DEPENDENCIES
rails (= 3.1.0)
rake
ruby-debug19
- sass-rails (~> 3.1.0)
+ sass-rails
sqlite3
therubyracer
uglifier
View
38 app/admin/dashboards.rb
@@ -0,0 +1,38 @@
+ActiveAdmin::Dashboards.build do
+
+ # Define your dashboard sections here. Each block will be
+ # rendered on the dashboard in the context of the view. So just
+ # return the content which you would like to display.
+
+ # == Simple Dashboard Section
+ # Here is an example of a simple dashboard section
+ #
+ # section "Recent Posts" do
+ # ul do
+ # Post.recent(5).collect do |post|
+ # li link_to(post.title, admin_post_path(post))
+ # end
+ # end
+ # end
+
+ # == Render Partial Section
+ # The block is rendered within the context of the view, so you can
+ # easily render a partial rather than build content in ruby.
+ #
+ # section "Recent Posts" do
+ # div do
+ # render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
+ # end
+ # end
+
+ # == Section Ordering
+ # The dashboard sections are ordered by a given priority from top left to
+ # bottom right. The default priority is 10. By giving a section numerically lower
+ # priority it will be sorted higher. For example:
+ #
+ # section "Recent Posts", :priority => 10
+ # section "Recent User", :priority => 1
+ #
+ # Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.
+
+end
View
1  app/assets/javascripts/active_admin.js
@@ -0,0 +1 @@
+//= require active_admin/base
View
6 app/assets/stylesheets/active_admin.css.scss
@@ -0,0 +1,6 @@
+// Active Admin CSS Styles
+@import "active_admin/mixins";
+@import "active_admin/base";
+
+// To customize the Active Admin interfaces, add your
+// styles here:
View
3  app/assets/stylesheets/admin/admins.css.scss
@@ -1,3 +0,0 @@
-// Place all the styles related to the admin/admins controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
View
9 app/assets/stylesheets/application.css
@@ -2,6 +2,13 @@
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
+ *
*= require_self
- *= require_tree .
+ *= require bootstrap-1.4
+ *= require artists/artists
+ *= require music-player/style
+ *= require releases/releases
+ *= require statics/statics
+ *= require style
*/
+
View
45 app/controllers/admin/admins_controller.rb
@@ -1,45 +0,0 @@
-class Admin::AdminsController < ApplicationController
-
- def index
- @admins = Admin.all
- end
-
- def show
- @admin = Admin.find(params[:id])
- end
-
- def new
- @admin = Admin.new
- end
-
- def edit
- @admin = Admin.find(params[:id])
- end
-
- def create
- @admin = Admin.new(params[:artist])
-
- if @admin.save
- redirect_to(@admin, :notice => 'Admin was successfully created.')
- else
- render :action => "new"
- end
- end
-
- def update
- @admin = Admin.find(params[:id])
-
- if @admin.update_attributes(params[:artist])
- redirect_to(@admin, :notice => 'Admin was successfully updated.')
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @admin = Admin.find(params[:id])
- @admin.destroy
-
- redirect_to(admins_url)
- end
-end
View
44 app/controllers/admin/artists_controller.rb
@@ -1,44 +0,0 @@
-class Admin::ArtistsController < ApplicationController
- def index
- @artists = Artist.all
- end
-
- def show
- @artist = Artist.find(params[:id])
- end
-
- def new
- @artist = Artist.new
- end
-
- def edit
- @artist = Artist.find(params[:id])
- end
-
- def create
- @artist = Artist.new(params[:artist])
-
- if @artist.save
- redirect_to(@artist, :notice => 'Artist was successfully created.')
- else
- render :action => "new"
- end
- end
-
- def update
- @artist = Artist.find(params[:id])
-
- if @artist.update_attributes(params[:artist])
- redirect_to(@artist, :notice => 'Artist was successfully updated.')
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @artist = Artist.find(params[:id])
- @artist.destroy
-
- redirect_to(artists_url)
- end
-end
View
44 app/controllers/admin/external_audios_controller.rb
@@ -1,44 +0,0 @@
-class Admin::ExternalAudiosController < ApplicationController
- def index
- @external_audios = ExternalAudio.all
- end
-
- def show
- @external_audio = ExternalAudio.find(params[:id])
- end
-
- def new
- @external_audio = ExternalAudio.new
- end
-
- def edit
- @external_audio = ExternalAudio.find(params[:id])
- end
-
- def create
- @external_audio = ExternalAudio.new(params[:artist])
-
- if @external_audio.save
- redirect_to(@external_audio, :notice => 'External_audio was successfully created.')
- else
- render :action => "new"
- end
- end
-
- def update
- @external_audio = ExternalAudio.find(params[:id])
-
- if @external_audio.update_attributes(params[:artist])
- redirect_to(@external_audio, :notice => 'External_audio was successfully updated.')
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @external_audio = ExternalAudio.find(params[:id])
- @external_audio.destroy
-
- redirect_to(external_audios_url)
- end
-end
View
16 app/controllers/admin/panel_controller.rb
@@ -1,16 +0,0 @@
-class Admin::PanelController < ApplicationController
-
- #before_filter :authenticate_admin, :except => [:index]
-
- def index
- if current_admin
- redirect_to '/admin/panel'
- else
- redirect_to '/admin/login'
- end
- end
-
- def panel
- end
-
-end
View
44 app/controllers/admin/releases_controller.rb
@@ -1,44 +0,0 @@
-class Admin::ReleasesController < ApplicationController
- def index
- @releases = Release.all
- end
-
- def show
- @release = Release.find(params[:id])
- end
-
- def new
- @release = Release.new
- end
-
- def edit
- @release = Release.find(params[:id])
- end
-
- def create
- @release = Release.new(params[:artist])
-
- if @release.save
- redirect_to(@release, :notice => 'Release was successfully created.')
- else
- render :action => "new"
- end
- end
-
- def update
- @release = Release.find(params[:id])
-
- if @release.update_attributes(params[:artist])
- redirect_to(@release, :notice => 'Release was successfully updated.')
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @release = Release.find(params[:id])
- @release.destroy
-
- redirect_to(releases_url)
- end
-end
View
44 app/controllers/admin/tracks_controller.rb
@@ -1,44 +0,0 @@
-class Track::TracksController < ApplicationController
- def index
- @tracks = Track.all
- end
-
- def show
- @track = Track.find(params[:id])
- end
-
- def new
- @track = Track.new
- end
-
- def edit
- @track = Track.find(params[:id])
- end
-
- def create
- @track = Track.new(params[:artist])
-
- if @track.save
- redirect_to(@track, :notice => 'Track was successfully created.')
- else
- render :action => "new"
- end
- end
-
- def update
- @track = Track.find(params[:id])
-
- if @track.update_attributes(params[:artist])
- redirect_to(@track, :notice => 'Track was successfully updated.')
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @track = Track.find(params[:id])
- @track.destroy
-
- redirect_to(tracks_url)
- end
-end
View
2  app/helpers/admin/admins_helper.rb
@@ -1,2 +0,0 @@
-module Admin::AdminsHelper
-end
View
11 app/models/admin.rb
@@ -1,11 +0,0 @@
-class Admin < ActiveRecord::Base
- # Include default devise modules. Others available are:
- # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
-
- # Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me
-
- validates_uniqueness_of :email
-end
View
16 app/models/admin_user.rb
@@ -0,0 +1,16 @@
+class AdminUser < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+end
View
1  app/views/admin/panel/index.html.haml
@@ -1 +0,0 @@
-Admin Panel
View
1  app/views/admin/panel/panel.html.haml
@@ -1 +0,0 @@
-panel
View
103 config/initializers/active_admin.rb
@@ -0,0 +1,103 @@
+ActiveAdmin.setup do |config|
+
+ # == Site Title
+ #
+ # Set the title that is displayed on the main layout
+ # for each of the active admin pages.
+ #
+ config.site_title = "Netlabel Cms"
+
+ # Set the link url for the title. For example, to take
+ # users to your main site. Defaults to no link.
+ #
+ # config.site_title_link = "/"
+
+ # == Default Namespace
+ #
+ # Set the default namespace each administration resource
+ # will be added to.
+ #
+ # eg:
+ # config.default_namespace = :hello_world
+ #
+ # This will create resources in the HelloWorld module and
+ # will namespace routes to /hello_world/*
+ #
+ # To set no namespace by default, use:
+ # config.default_namespace = false
+ #
+ # Default:
+ # config.default_namespace = :admin
+
+ # == User Authentication
+ #
+ # Active Admin will automatically call an authentication
+ # method in a before filter of all controller actions to
+ # ensure that there is a currently logged in admin user.
+ #
+ # This setting changes the method which Active Admin calls
+ # within the controller.
+ config.authentication_method = :authenticate_admin_user!
+
+
+ # == Current User
+ #
+ # Active Admin will associate actions with the current
+ # user performing them.
+ #
+ # This setting changes the method which Active Admin calls
+ # to return the currently logged in user.
+ config.current_user_method = :current_admin_user
+
+
+ # == Logging Out
+ #
+ # Active Admin displays a logout link on each screen. These
+ # settings configure the location and method used for the link.
+ #
+ # This setting changes the path where the link points to. If it's
+ # a string, the strings is used as the path. If it's a Symbol, we
+ # will call the method to return the path.
+ #
+ # Default:
+ # config.logout_link_path = :destroy_admin_user_session_path
+
+ # This setting changes the http method used when rendering the
+ # link. For example :get, :delete, :put, etc..
+ #
+ # Default:
+ # config.logout_link_method = :get
+
+
+ # == Admin Comments
+ #
+ # Admin comments allow you to add comments to any model for admin use
+ #
+ # Admin comments are enabled by default in the default
+ # namespace only. You can turn them on in a namesapce
+ # by adding them to the comments array.
+ #
+ # Default:
+ # config.allow_comments_in = [:admin]
+
+
+ # == Controller Filters
+ #
+ # You can add before, after and around filters to all of your
+ # Active Admin resources from here.
+ #
+ # config.before_filter :do_something_awesome
+
+
+ # == Register Stylesheets & Javascripts
+ #
+ # We recommend using the built in Active Admin layout and loading
+ # up your own stylesheets / javascripts to customize the look
+ # and feel.
+ #
+ # To load a stylesheet:
+ # config.register_stylesheet 'my_stylesheet.css'
+ #
+ # To load a javascript file:
+ # config.register_javascript 'my_javascript.js'
+end
View
43 config/initializers/devise.rb
@@ -2,7 +2,8 @@
# four configuration values can also be set straight in your models.
Devise.setup do |config|
# ==> Mailer Configuration
- # Configure the e-mail address which will be shown in DeviseMailer.
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
# Configure the class responsible to send e-mails.
@@ -36,6 +37,11 @@
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [ :email ]
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [ :email ]
+
# Tell if authentication through request.params is enabled. True by default.
# config.params_authenticatable = true
@@ -48,21 +54,29 @@
# The realm used in Http Basic Authentication. "Application" by default.
# config.http_authentication_realm = "Application"
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
- config.stretches = 10
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments.
+ config.stretches = Rails.env.test? ? 1 : 10
# Setup a pepper to generate the encrypted password.
- # config.pepper = "d2074bd98cca682749dc5f60447a003f2d3c6b8dbf69817719998efff07e164d63f1caf7ed5f11a33ded44032f62f1c6e1d5f60f69b2894bb35575ceb1ff0771"
+ # config.pepper = "ec470647a7578e712019295645bc95065dcf06176bae37f69af608cd141ce0d42789861efa4788f0e8d05e5d371d81bcda19b7f893fb02f78a748ae16577a46f"
# ==> Configuration for :confirmable
- # The time you want to give your user to confirm his account. During this time
- # he will be able to access your application without confirming. Default is 0.days
- # When confirm_within is zero, the user won't be able to sign in without confirming.
- # You can use this to let your user access some features of your application
- # without confirming the account, but blocking it after a certain period
- # (ie 2 days).
+ # A period that the user is allowed to access the website even without
+ # confirming his account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming his account,
+ # access will be blocked just in the third day. Default is 0.days, meaning
+ # the user cannot access the website without confirming his account.
# config.confirm_within = 2.days
# Defines which key will be used when confirming an account
@@ -90,8 +104,10 @@
# Range for password length. Default is 6..128.
# config.password_length = 6..128
- # Regex to use to validate the email address
- # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
+ # Email regex used to validate email formats. It simply asserts that
+ # an one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
@@ -174,8 +190,8 @@
# Explorer requests.
# config.navigational_formats = [:"*/*", "*/*", :html]
- # The default HTTP method used to sign out a resource. Default is :get.
- # config.sign_out_via = :get
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
@@ -187,7 +203,6 @@
# change the failure app, you can configure them inside the config.warden block.
#
# config.warden do |manager|
- # manager.failure_app = AnotherApp
# manager.intercept_401 = false
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
# end
View
50 config/locales/devise.en.yml
@@ -1,50 +0,0 @@
-# Additional translations at http://github.com/plataformatec/devise/wiki/I18n
-
-en:
- errors:
- messages:
- expired: "has expired, please request a new one"
- not_found: "not found"
- already_confirmed: "was already confirmed, please try signing in"
- not_locked: "was not locked"
- not_saved:
- one: "1 error prohibited this %{resource} from being saved:"
- other: "%{count} errors prohibited this %{resource} from being saved:"
-
- devise:
- failure:
- already_authenticated: 'You are already signed in.'
- unauthenticated: 'You need to sign in or sign up before continuing.'
- unconfirmed: 'You have to confirm your account before continuing.'
- locked: 'Your account is locked.'
- invalid: 'Invalid email or password.'
- invalid_token: 'Invalid authentication token.'
- timeout: 'Your session expired, please sign in again to continue.'
- inactive: 'Your account was not activated yet.'
- sessions:
- signed_in: 'Signed in successfully.'
- signed_out: 'Signed out successfully.'
- passwords:
- send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
- updated: 'Your password was changed successfully. You are now signed in.'
- confirmations:
- send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
- confirmed: 'Your account was successfully confirmed. You are now signed in.'
- registrations:
- signed_up: 'Welcome! You have signed up successfully.'
- inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
- updated: 'You updated your account successfully.'
- destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
- unlocks:
- send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
- unlocked: 'Your account was successfully unlocked. You are now signed in.'
- omniauth_callbacks:
- success: 'Successfully authorized from %{kind} account.'
- failure: 'Could not authorize you from %{kind} because "%{reason}".'
- mailer:
- confirmation_instructions:
- subject: 'Confirmation instructions'
- reset_password_instructions:
- subject: 'Reset password instructions'
- unlock_instructions:
- subject: 'Unlock Instructions'
View
16 config/routes.rb
@@ -1,20 +1,8 @@
NetlabelCms::Application.routes.draw do
- devise_for :admins
- devise_scope :admin do
- get "admin/login" => "devise/sessions#new"
- get "admin/logout" => "devise/sessions#destroy"
- end
+ devise_for :admin_users, ActiveAdmin::Devise.config
- namespace :admin do
- resources :admins
- resources :artists
- resources :external_audios
- resources :releases
- resources :tracks
- end
- match 'admin', :controller => 'admin/panel', :action => 'index'
- match 'admin/panel', :controller => 'admin/panel', :action => 'panel'
+ ActiveAdmin.routes(self)
resources :artists
resources :tracks
View
25 db/migrate/20111116191732_drop_admins_table.rb
@@ -0,0 +1,25 @@
+class DropAdminsTable < ActiveRecord::Migration
+ def up
+ drop_table :admins
+ end
+
+ def down
+ create_table "admins", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true
+ add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true
+ end
+end
View
31 db/migrate/20111116193104_add_devise_to_admin_users.rb
@@ -0,0 +1,31 @@
+class AddDeviseToAdminUsers < ActiveRecord::Migration
+ def self.up
+ create_table(:admin_users) do |t|
+ t.database_authenticatable :null => false
+ t.recoverable
+ t.rememberable
+ t.trackable
+
+ # t.encryptable
+ # t.confirmable
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
+ # t.token_authenticatable
+
+
+ # Uncomment below if timestamps were not included in your original model.
+ # t.timestamps
+ end
+
+ add_index :admin_users, :email, :unique => true
+ add_index :admin_users, :reset_password_token, :unique => true
+ # add_index :admin_users, :confirmation_token, :unique => true
+ # add_index :admin_users, :unlock_token, :unique => true
+ # add_index :admin_users, :authentication_token, :unique => true
+ end
+
+ def self.down
+ # By default, we don't want to make any assumption about how to roll back a migration when your
+ # model already existed. Please edit below which fields you would like to remove in this migration.
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
View
16 db/migrate/20111116203110_create_admin_notes.rb
@@ -0,0 +1,16 @@
+class CreateAdminNotes < ActiveRecord::Migration
+ def self.up
+ create_table :admin_notes do |t|
+ t.references :resource, :polymorphic => true, :null => false
+ t.references :admin_user, :polymorphic => true
+ t.text :body
+ t.timestamps
+ end
+ add_index :admin_notes, [:resource_type, :resource_id]
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+
+ def self.down
+ drop_table :admin_notes
+ end
+end
View
25 db/migrate/20111116203111_move_admin_notes_to_comments.rb
@@ -0,0 +1,25 @@
+class MoveAdminNotesToComments < ActiveRecord::Migration
+ def self.up
+ remove_index :admin_notes, [:admin_user_type, :admin_user_id]
+ rename_table :admin_notes, :active_admin_comments
+ rename_column :active_admin_comments, :admin_user_type, :author_type
+ rename_column :active_admin_comments, :admin_user_id, :author_id
+ add_column :active_admin_comments, :namespace, :string
+ add_index :active_admin_comments, [:namespace]
+ add_index :active_admin_comments, [:author_type, :author_id]
+
+ # Update all the existing comments to the default namespace
+ say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
+ execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
+ end
+
+ def self.down
+ remove_index :active_admin_comments, :column => [:author_type, :author_id]
+ remove_index :active_admin_comments, :column => [:namespace]
+ remove_column :active_admin_comments, :namespace
+ rename_column :active_admin_comments, :author_id, :admin_user_id
+ rename_column :active_admin_comments, :author_type, :admin_user_type
+ rename_table :active_admin_comments, :admin_notes
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+end
View
25 db/schema.rb
@@ -11,9 +11,24 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111113170913) do
+ActiveRecord::Schema.define(:version => 20111116203111) do
- create_table "admins", :force => true do |t|
+ create_table "active_admin_comments", :force => true do |t|
+ t.integer "resource_id", :null => false
+ t.string "resource_type", :null => false
+ t.integer "author_id"
+ t.string "author_type"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "namespace"
+ end
+
+ add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id"
+ add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace"
+ add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id"
+
+ create_table "admin_users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
@@ -24,12 +39,10 @@
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
- t.datetime "created_at"
- t.datetime "updated_at"
end
- add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true
- add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true
+ add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true
+ add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true
create_table "artists", :force => true do |t|
t.string "name"
View
6 db/seeds.rb
@@ -1,5 +1,5 @@
-Admin.create!(
- :email => "admin@admin.com",
+AdminUser.create!(
+ :email => 'admin@example.com',
:password => 'password',
:password_confirmation => 'password'
)
@@ -490,4 +490,4 @@
# mvapo01 VA - Hybrid Disorder
{ :release_id => 16 , :name => "Sonic Squirrel .ZIP" , :audio_type => "mp3", :bitrate => 320 , :url => "http://sonicsquirrel.net/get/release/zip/7360" , :description => "Contains audio files, covers and release notes"},
-])
+])
View
11 test/fixtures/admin_users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
View
7 test/fixtures/admins.yml
@@ -1,7 +0,0 @@
-one:
- email: admin@admin.com
- encrypted_password: $2a$10$NHKC7kmiXFNl6hDVm1u3gOvexxZrjcQTZnsvxWUMfQVpdEXfGJyju
-
-two:
- email: admin2@admin.com
- encrypted_password: $2a$10$NHKC7kmiXFNl6hDVm1u3gOvexxZrjcQTZnsvxWUMfQVpdEXfGJyju
View
7 test/functional/admin/admins_controller_test.rb
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class Admin::AdminsControllerTest < ActionController::TestCase
- # test "the truth" do
- # assert true
- # end
-end
View
2  test/unit/admin_test.rb → test/unit/admin_user_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class AdminTest < ActiveSupport::TestCase
+class AdminUserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
View
4 test/unit/helpers/admin/admins_helper_test.rb
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class Admin::AdminsHelperTest < ActionView::TestCase
-end
View
4 test/unit/helpers/groups_helper_test.rb
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class GroupsHelperTest < ActionView::TestCase
-end
View
4 test/unit/helpers/static_helper_test.rb
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class StaticHelperTest < ActionView::TestCase
-end

0 comments on commit 434f7f7

Please sign in to comment.
Something went wrong with that request. Please try again.