public
Description: OneBody is web-based software that connects community members, especially churches, on the web.
Homepage: http://beonebody.com
Clone URL: git://github.com/seven1m/onebody.git
Add pages when creating a site.
Accept encrypted_password when creating new admin user from rake task.
Tim Morgan (author)
Thu Aug 14 22:07:55 -0700 2008
commit  75034c80e44a35a8d47de01128e67db22c01f0c7
tree    521a24dfa1fe44608875d83486d949936400136a
parent  baf41c2abb250813246e6f3e4dd4ee96035ebba5
...
67
68
69
70
 
71
72
73
...
94
95
96
 
 
 
 
 
 
 
97
98
99
...
67
68
69
 
70
71
72
73
...
94
95
96
97
98
99
100
101
102
103
104
105
106
0
@@ -67,7 +67,7 @@ class Site < ActiveRecord::Base
0
     Setting.get(:features, :multisite) or default?
0
   end
0
   
0
-  after_create :add_settings, :add_tasks
0
+  after_create :add_settings, :add_tasks, :add_pages
0
   
0
   def add_settings
0
     settings = YAML::load(File.open(SETTINGS_YAML_FILE))
0
@@ -94,6 +94,13 @@ class Site < ActiveRecord::Base
0
     ].each { |t| self.scheduled_tasks.create!(t) unless self.scheduled_tasks.find_by_name(t[:name]) }
0
   end
0
   
0
+  def add_pages
0
+    if connection.select_value("SELECT count(*) from pages where site_id=#{id}").to_i == 0
0
+      require Rails.root + "/db/migrate/20080722143227_move_system_content_to_pages"
0
+      MoveSystemContentToPages.up
0
+    end
0
+  end
0
+  
0
   def twitter_enabled?
0
     @twitter_enabled ||= self.settings.find_by_name('Twitter Account').value.to_s.any? \
0
       && self.settings.find_by_name('Twitter Password').value.to_s.any?
...
36
37
38
39
 
40
41
42
...
44
45
46
47
 
48
49
50
51
52
53
54
55
56
57
 
 
 
 
58
59
60
...
36
37
38
 
39
40
41
42
...
44
45
46
 
47
48
49
50
 
51
52
53
54
55
 
56
57
58
59
60
61
62
0
@@ -36,7 +36,7 @@ namespace :onebody do
0
   task :newuser => :environment do
0
     puts 'Create new admin user...'
0
     Site.current = site = ENV['SITE'] ? Site.find_by_name(ENV['SITE']) : Site.find(1)
0
-    unless password = ENV['PASSWORD']
0
+    unless password = ENV['PASSWORD'] or encrypted_password = ENV['ENCRYPTED_PASSWORD']
0
       password = ask('Password: ')         { |q| q.echo = false }
0
       confirm  = ask('Password (again): ') { |q| q.echo = false }
0
       raise 'Passwords do not match.' unless password == confirm
0
@@ -44,17 +44,19 @@ namespace :onebody do
0
     unless gender = ENV['GENDER']
0
       gender = ask('Gender ("m" or "f"): ').downcase == 'm' ? 'Male' : 'Female'
0
     end
0
-    person = site.people.create!(
0
+    attrs = {
0
       :email                        => ENV['EMAIL'] || ask('Email Address: '),
0
       :first_name                   => ENV['FIRST'] || ask('First Name: '),
0
       :last_name                    => ENV['LAST']  || ask('Last Name: '),
0
-      :password                     => password,
0
       :gender                       => gender,
0
       :can_sign_in                  => true,
0
       :visible_to_everyone          => true,
0
       :visible_on_printed_directory => true,
0
       :full_access                  => true
0
-    )
0
+    }
0
+    attrs[:password] = password if password
0
+    attrs[:encrypted_password] = encrypted_password if encrypted_password
0
+    person = site.people.create!(attrs)
0
     family = site.families.create!(
0
       :name => person.name,
0
       :last_name => person.last_name
...
120
121
122
123
 
124
125
126
...
120
121
122
 
123
124
125
126
0
@@ -120,7 +120,7 @@ namespace :onebody do
0
     
0
     def site_args(args={})
0
       %w(secondary_host max_admins max_people max_groups).each do |arg|
0
-        args[arg] = (ENV[a.upcase] == '' ? nil : ENV[a.upcase]) unless ENV[a.upcase].nil?
0
+        args[arg] = (ENV[arg.upcase] == '' ? nil : ENV[arg.upcase]) unless ENV[arg.upcase].nil?
0
       end
0
       %w(import_export_enabled pages_enabled pictures_enabled publications_enabled).each do |arg|
0
         args[arg] = %w(true yes on).include?(ENV[arg.upcase].downcase) unless ENV[arg.upcase].nil?

Comments