A corporation manager and dashboard for EVE Online
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

56 řádky
1.9 KiB

  1. require 'io/console'
  2. namespace :calefaction do
  3. desc "Sets some initial database values and creates an admin user"
  4. task setup: :environment do
  5. print "Enter your corporation's name: "
  6. corp_name = STDIN.gets.chomp
  7. print "\nEnter your corporation's ID (this is visible in the URL for "\
  8. "your corp's page on \nzKillboard, among other places): "
  9. corp_id = STDIN.gets.chomp.to_i
  10. if corp_id <= 0
  11. puts 'Corporation ID must be a positive integer. Stopping.'
  12. next
  13. end
  14. print "\nEnter your character's name: "
  15. user_name = STDIN.gets.chomp
  16. print "\nEnter your email address (used for password resets; may be blank): "
  17. user_email = STDIN.gets.chomp
  18. user_email = nil if user_email.empty?
  19. print "\nEnter your new password (to log in to the website, **NOT** for EVE!): "
  20. user_pass = STDIN.noecho(&:gets).chomp
  21. puts
  22. print "\nConfirm the password: "
  23. if user_pass != STDIN.noecho(&:gets).chomp
  24. puts "\nPasswords do not match. Stopping."
  25. next
  26. end
  27. puts
  28. print "\nEnter your character's API key ID (create one at\n"\
  29. "https://community.eveonline.com/support/api-key/createpredefined?accessMask=8): "
  30. user_api_key = STDIN.gets.chomp
  31. print "\nEnter the verification code for the key you just entered: "
  32. user_api_verify = STDIN.gets.chomp
  33. User.transaction do
  34. AdminSetting.where(key: %w(corp_name site_name)).update_all(value: corp_name)
  35. AdminSetting.find_by(key: 'corp_id').update(value: corp_id)
  36. user = User.new(name: user_name, email: user_email, password: user_pass,
  37. api_key: user_api_key, api_verify: user_api_verify,
  38. is_admin: true, is_corp: true)
  39. unless user.member_of? corp_id
  40. puts 'You are not a member of the given corporation. Stopping.'
  41. raise ActiveRecord::Rollback
  42. end
  43. user.save
  44. end
  45. end
  46. end