diff --git a/Gemfile b/Gemfile index a6035096..bf05aed4 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,8 @@ gem 'locomotive_jammit-s3', :require => 'jammit-s3' gem 'SystemTimer', :platforms => :ruby_18 gem 'cells' +gem 'highline' + # The rest of the dependencies are for use when in the locomotive dev environment group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 427d6678..fb6e46bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -309,6 +309,7 @@ DEPENDENCIES growl-glue haml (= 3.1.2) heroku (= 1.19.1) + highline httparty (>= 0.6.1) inherited_resources (~> 1.1.2) launchy diff --git a/lib/tasks/locomotive.rake b/lib/tasks/locomotive.rake index 8f16c3e5..a36f5a70 100644 --- a/lib/tasks/locomotive.rake +++ b/lib/tasks/locomotive.rake @@ -1,6 +1,7 @@ # encoding: utf-8 require 'locomotive' +require 'highline/import' namespace :locomotive do @@ -45,6 +46,21 @@ namespace :locomotive do ::Locomotive::Import::Job.run!(url, site, { :samples => true, :reset => reset }) end + desc 'Add a new admin user (NOTE: currently only supports adding user to first site)' + task :add_admin => :environment do + name = ask('Display name: ') { |q| q.echo = true } + email = ask('Email address: ') { |q| q.echo = true } + password = ask('Password: ') { |q| q.echo = '*' } + password_confirm = ask('Confirm password: ') { |q| q.echo = '*' } + + account = Account.create :email => email, :password => password, :password_confirmation => password_confirm, :name => name + + # TODO: this should be changed to work for multi-sites (see desc) + site = Site.first + site.memberships.build :account => account, :role => 'admin' + site.save! + end + namespace :upgrade do desc 'Set roles to the existing users'