app/models/page_template.rb in kit_cms-2.3.20 vs app/models/page_template.rb in kit_cms-2.3.22

- old
+ new

@@ -1,14 +1,17 @@ class PageTemplate < ActiveRecord::Base + has_many :html_assetable, :as=>:html_assetable + has_many :html_assets, :through=>:html_assetable + has_many :pages belongs_to :layout has_and_belongs_to_many :blocks has_many :views has_many :page_template_terms belongs_to :user - attr_accessible :name, :template_type, :layout_id, :allow_anonymous_comments, :allow_user_comments, :hidden, :is_mobile, :mobile_version_id, :body, :stylesheets, :javascripts + attr_accessible :name, :template_type, :layout_id, :allow_anonymous_comments, :allow_user_comments, :hidden, :is_mobile, :mobile_version_id, :body, :system_id, :html_asset_ids, :header, :footer, :is_default, :page_type use_kit_caching before_validation :set_page_type @@ -81,9 +84,26 @@ def has_mobile_version? self.mobile_version_id != 0 end def self.create_default(sid, user_id) - PageTemplate.create(:system_id=>sid, :stylesheets=>"application", :header=>'', :footer=>'', :layout_id=>Layout.sys(sid).first.id, :template_type=>"haml", :is_mobile=>0, :is_default=>1, :page_type=>"default", :name=>"default", :body=>"= field('body')") + PageTemplate.create(:system_id=>sid, :header=>'', :footer=>'', :layout_id=>Layout.sys(sid).first.id, :template_type=>"haml", :is_mobile=>0, :is_default=>1, :page_type=>"default", :name=>"default", :body=>"= field('body')") end + def javascripts + self.html_assets.where(:file_type=>"js").all + end + + def stylesheets + self.html_assets.where(:file_type=>"css").all + end + + def old_stylesheets + self.read_attribute(:stylesheets) + end + + def old_javascripts + self.read_attribute(:javascripts) + end + + end