lib/tasks/kit.rake in kit_cms-2.3.20 vs lib/tasks/kit.rake in kit_cms-2.3.22
- old
+ new
@@ -93,13 +93,11 @@
= yield
'
l.locale = 'en'
l.handler = 'haml'
l.format = 'html'
- l.stylesheets = 'application'
l.system_id = 1
- l.javascripts = 'application'
l.path = 'layouts/application'
l.save!
end
desc "Create Basic Assets"
@@ -240,11 +238,58 @@
}.to_yaml
end
end
end
+ desc "Reset Password"
+ task :reset_password => :environment do
+ print "\nThis will reset the password of any admin user in any system. Typically you will use this to reset the superadmin account to allow access to the CMS Dashboard from where you can reset any other passwords. \n\nFirst you must select the system ID from this list:\n\n"
+ System.all.each do |s|
+ puts "#{s.id} : #{s.name}"
+ end
+ print "\nSystem ID? "
+ system_id = STDIN.gets.chomp
+
+ s = System.sys(system_id).first
+ unless s
+ puts "That System ID isn't valid. You'll have to start again.\n\n"
+ exit -1
+ end
+
+ puts "\nAdmin users of '#{s.name}':\n"
+ User.sys(system_id).includes(:roles).each do |u|
+ puts "User ID: #{u.id} Email: #{u.email}" if u.admin?
+ end
+
+ print "\nWhat is the User ID of the user whose password you want to change? "
+ user_id = STDIN.gets.chomp
+
+ u = User.sys(system_id).where(:id=>user_id).first
+
+ unless u
+ puts "That User ID isn't valid. You'll have to start again.\n\n"
+ exit -1
+ end
+
+ u = User.find(user_id)
+
+ print "\nFinally, enter a new password for #{u.email} within #{s.name}: "
+
+ password = STDIN.gets.chomp
+ if password.strip.length<=0
+ puts "\n\nThis utility has no restrictions on password complexity, but won't set an empty password. You'll have to start again.\n\n"
+ exit -1
+ end
+
+ u.password = password
+ u.save
+
+ puts "\nThe password has been changed. You should now sign in as '#{u.email}' with the new password '#{password}', then change the password from within the dashboard.\n\n"
+ end
+
+
desc "Initial Kit Setup"
task :setup_cms, [:email, :password] => :environment do |t, args|
print "\nThis will remove ALL existing Kit CMS data. If you enter anything other than 'YES' (without quotes) I'll stop.\n\nAre you sure? > "
confirm = STDIN.gets.chomp
@@ -260,7 +305,50 @@
Rake::Task['kit:basic_tree'].invoke
Rake::Task['kit:basic_homepage'].invoke
puts "\nStart the Rails server then visit http://localhost:3000 or to login to the administrative dashboard go to http://localhost:3000/db\n\n"
end
+
+ desc "Upgrade Stylesheets and Javascripts"
+ task :upgrade_assets => :environment do
+
+ Layout.all.each do |layout|
+ puts "Doing Layout #{layout.name} for System #{layout.system_id}"
+ puts "stylesheets #{layout.old_stylesheets}"
+ layout.old_stylesheets.split(",").each do |s|
+ puts "Doing stylesheet '#{s}'"
+ layout.html_assets << HtmlAsset.sys(layout.system_id).where(:name=>s).where(:file_type=>'css').first rescue nil
+ end if layout.old_stylesheets
+ end
+ Layout.all.each do |layout|
+ layout.old_javascripts.split(",").each do |s|
+ layout.html_assets << HtmlAsset.sys(layout.system_id).where(:name=>s).where(:file_type=>'js').first rescue nil
+ end if layout.old_javascripts
+ end
+ PageTemplate.all.each do |pt|
+ puts "Doing PT #{pt.name} for System #{pt.system_id}"
+ pt.old_stylesheets.split(",").each do |s|
+ pt.html_assets << HtmlAsset.sys(pt.system_id).where(:name=>s).where(:file_type=>'css').first rescue nil
+ end if pt.old_stylesheets
+ end
+ PageTemplate.all.each do |pt|
+ pt.old_javascripts.split(",").each do |s|
+ pt.html_assets << HtmlAsset.sys(pt.system_id).where(:name=>s).where(:file_type=>'js').first rescue nil
+ end if pt.old_javascripts
+ end
+ Form.all.each do |f|
+ puts "Doing form #{f.title} for System #{f.system_id}"
+ f.old_stylesheets.split(",").each do |s|
+ f.html_assets << HtmlAsset.sys(f.system_id).where(:name=>s).where(:file_type=>"css").first rescue nil
+ end if f.old_stylesheets
+ end
+
+ Form.all.each do |f|
+ if f.layout
+ l = Layout.sys(f.system_id).where(:name=>f.layout).first
+ f.layout = l if l
+ f.save
+ end
+ end
+ end
end