Commit 5d4345c4f9ff03506fe99ce0e135fb75d94a9066

Authored by AntonioTerceiro
1 parent 18230315

r215@sede: terceiro | 2007-07-28 07:53:39 -0300

ActionItem8: making VirtualCommunity provide flexible_template functionality. 
 


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@219 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/home_controller.rb
1 1 class HomeController < ApplicationController
2 2  
3   - uses_flexible_template :owner => 'owner'
4   -
5   - def flexible_template_owner
6   - Profile.find(1)
7   - end
  3 + uses_flexible_template :owner => 'virtual_community'
8 4  
9 5 end
... ...
app/models/profile.rb
... ... @@ -11,7 +11,7 @@ class Profile &lt; ActiveRecord::Base
11 11 homepage.save!
12 12 end
13 13  
14   - act_as_flexible_template
  14 + acts_as_flexible_template
15 15  
16 16 # Valid identifiers must match this format.
17 17 IDENTIFIER_FORMAT = /^[a-z][a-z0-9_]*[a-z0-9]$/
... ...
app/models/virtual_community.rb
... ... @@ -16,6 +16,8 @@ class VirtualCommunity &lt; ActiveRecord::Base
16 16 # Relationships and applied behaviour
17 17 # #################################################
18 18  
  19 + acts_as_flexible_template
  20 +
19 21 # One VirtualCommunity can be reached by many domains
20 22 has_many :domains, :as => :owner
21 23  
... ... @@ -76,6 +78,36 @@ class VirtualCommunity &lt; ActiveRecord::Base
76 78 def has_terms_of_use?
77 79 ! self.settings['terms_of_use'].nil?
78 80 end
  81 +
  82 + # Returns the template used by +flexible_template+ plugin.
  83 + def flexible_template_template
  84 + self.settings['flexible_template_template']
  85 + end
  86 +
  87 + # Sets the template used by +flexible_template+ plugin.
  88 + def flexible_template_template=(value)
  89 + self.settings['flexible_template_template'] = value
  90 + end
  91 +
  92 + # Returns the theme used by +flexible_template+ plugin
  93 + def flexible_template_theme
  94 + self.settings['flexible_template_theme']
  95 + end
  96 +
  97 + # Sets the theme used by +flexible_template+ plugin
  98 + def flexible_template_theme=(value)
  99 + self.settings['flexible_template_theme'] = value
  100 + end
  101 +
  102 + # Returns the icon theme used by +flexible_template+ plugin
  103 + def flexible_template_icon_theme
  104 + self.settings['flexible_template_icon_theme']
  105 + end
  106 +
  107 + # Sets the icon theme used by +flexible_template+ plugin
  108 + def flexible_template_icon_theme=(value)
  109 + self.settings['flexible_template_icon_theme'] = value
  110 + end
79 111  
80 112 # #################################################
81 113 # Validations
... ...
test/unit/virtual_community_test.rb
... ... @@ -78,4 +78,23 @@ class VirtualCommunityTest &lt; Test::Unit::TestCase
78 78 assert v.has_terms_of_use?
79 79 end
80 80  
  81 + def test_should_profive_flexible_template_stuff
  82 + v = VirtualCommunity.new
  83 +
  84 + # template
  85 + assert_nil v.flexible_template_template
  86 + v.flexible_template_template = 'bli'
  87 + assert_equal 'bli', v.flexible_template_template
  88 +
  89 + # theme
  90 + assert_nil v.flexible_template_theme
  91 + v.flexible_template_theme = 'bli'
  92 + assert_equal 'bli', v.flexible_template_theme
  93 +
  94 + # icon theme
  95 + assert_nil v.flexible_template_icon_theme
  96 + v.flexible_template_icon_theme = 'bli'
  97 + assert_equal 'bli', v.flexible_template_icon_theme
  98 + end
  99 +
81 100 end
... ...