Sha256: abbacb03e9b1c568ba2a53e80fda8b47036e20bac0fdc0402fa7137a404fef3b

Contents?: true

Size: 1.73 KB

Versions: 4

Compression:

Stored size: 1.73 KB

Contents

namespace :kkt_shoppe do

  desc "Load seed data for the KktShoppe"
  task :seed => :environment do
    require File.join(KktShoppe.root, 'db', 'seeds')
  end

  desc "Create a default admin user"
  task :create_default_user => :environment do
    KktShoppe::User.create(:email_address => 'admin@example.com', :password => 'password', :password_confirmation => 'password', :first_name => 'Default', :last_name => 'Admin')
    puts
    puts "    New user has been created successfully."
    puts
    puts "    E-Mail Address..: admin@example.com"
    puts "    Password........: password"
    puts
  end

  desc "Import default set of countries"
  task :import_countries => :environment do
    KktShoppe::CountryImporter.import
  end

  desc "Run the key setup tasks for a new application"
  task :setup => :environment do
    Rake::Task["kkt_shoppe:import_countries"].invoke    if KktShoppe::Country.all.empty?
    Rake::Task["kkt_shoppe:create_default_user"].invoke if KktShoppe::User.all.empty?
  end

  desc "Converts nifty-attachment attachments to KktShoppe Attachments"
  task :attachments => :environment do
    require "nifty/attachments"

    attachments = Nifty::Attachments::Attachment.all

    attachments.each do |attachment|
      object = attachment.parent_type.constantize.find(attachment.parent_id)

      attach = object.attachments.build
      attach.role = attachment.role
      attach.file_name = attachment.file_name

      tempfile = Tempfile.new("attach-#{attachment.token}")
      tempfile.binmode
      tempfile.write(attachment.data)
      uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: tempfile, filename: attachment.file_name, type: attachment.file_type)

      attach.file = uploaded_file
      attach.save!
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kkt_shoppe-2.0.2 lib/tasks/kkt_shoppe.rake
kkt_shoppe-2.0.1 lib/tasks/kkt_shoppe.rake
kkt_shoppe-2.0.0 lib/tasks/kkt_shoppe.rake
kkt_shoppe-1.3.0 lib/tasks/kkt_shoppe.rake