diff options
| author | hukl <contact@smyck.org> | 2009-03-08 22:31:00 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-03-08 22:31:00 +0100 |
| commit | 00fe407be045a5b6cf8269965c0fd35a44094741 (patch) | |
| tree | cf1d0599a6a4614e85021286260cac754d750b22 /app/models/page.rb | |
| parent | 3d62eef0723e39c8454035dc1e5ed6a214b20e8b (diff) | |
added date selector for published_at. Also removed the part that reset the published_at attribute to Time.now. Some cleanups
Diffstat (limited to 'app/models/page.rb')
| -rw-r--r-- | app/models/page.rb | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index a27ccfc..ae2f998 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -19,7 +19,7 @@ class Page < ActiveRecord::Base | |||
| 19 | before_save :rewrite_links_in_body | 19 | before_save :rewrite_links_in_body |
| 20 | 20 | ||
| 21 | # Security | 21 | # Security |
| 22 | attr_accessible :title, :abstract, :body, :template_name | 22 | attr_accessible :title, :abstract, :body, :template_name, :published_at |
| 23 | 23 | ||
| 24 | # Class Methods | 24 | # Class Methods |
| 25 | 25 | ||
| @@ -59,24 +59,6 @@ class Page < ActiveRecord::Base | |||
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | # Instance Methods | 61 | # Instance Methods |
| 62 | |||
| 63 | def clone_attributes_from page | ||
| 64 | return nil unless page | ||
| 65 | |||
| 66 | self.tag_list = page.tag_list.join(", ") | ||
| 67 | |||
| 68 | locale_before = I18n.locale | ||
| 69 | |||
| 70 | I18n.available_locales.each do |l| | ||
| 71 | next if l == :root | ||
| 72 | I18n.locale = l | ||
| 73 | self.title = page.title | ||
| 74 | self.abstract = page.abstract | ||
| 75 | self.body = page.body | ||
| 76 | end | ||
| 77 | |||
| 78 | I18n.locale = locale_before | ||
| 79 | end | ||
| 80 | 62 | ||
| 81 | def public_template_path | 63 | def public_template_path |
| 82 | File.join(PUBLIC_TEMPLATE_PATH, template_name) | 64 | File.join(PUBLIC_TEMPLATE_PATH, template_name) |
| @@ -106,8 +88,13 @@ class Page < ActiveRecord::Base | |||
| 106 | def clone_attributes_from page | 88 | def clone_attributes_from page |
| 107 | return nil unless page | 89 | return nil unless page |
| 108 | 90 | ||
| 91 | # Clone untranslated attributes | ||
| 92 | |||
| 109 | self.tag_list = page.tag_list.join(", ") | 93 | self.tag_list = page.tag_list.join(", ") |
| 110 | self.template_name = page.template_name | 94 | self.template_name = page.template_name |
| 95 | self.published_at = page.published_at | ||
| 96 | |||
| 97 | # Clone translated attributes | ||
| 111 | 98 | ||
| 112 | locale_before = I18n.locale | 99 | locale_before = I18n.locale |
| 113 | 100 | ||
