Commit 8a5c98ff30faef1df4aed138ae053b08739e2750
1 parent
9ede4b26
Exists in
master
and in
29 other branches
ActionItem591: setted the templates and iterface to edit them
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2412 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
66 additions
and
3 deletions
Show diff stats
app/controllers/admin/admin_panel_controller.rb
app/models/environment.rb
@@ -31,7 +31,7 @@ class Environment < ActiveRecord::Base | @@ -31,7 +31,7 @@ class Environment < ActiveRecord::Base | ||
31 | 'disable_products_for_enterprises' => _('Disable products for enterprises'), | 31 | 'disable_products_for_enterprises' => _('Disable products for enterprises'), |
32 | } | 32 | } |
33 | end | 33 | end |
34 | - | 34 | + |
35 | # ################################################# | 35 | # ################################################# |
36 | # Relationships and applied behaviour | 36 | # Relationships and applied behaviour |
37 | # ################################################# | 37 | # ################################################# |
@@ -90,7 +90,7 @@ class Environment < ActiveRecord::Base | @@ -90,7 +90,7 @@ class Environment < ActiveRecord::Base | ||
90 | def settings | 90 | def settings |
91 | self[:settings] ||= {} | 91 | self[:settings] ||= {} |
92 | end | 92 | end |
93 | - | 93 | + |
94 | # Enables a feature identified by its name | 94 | # Enables a feature identified by its name |
95 | def enable(feature) | 95 | def enable(feature) |
96 | self.settings["#{feature}_enabled"] = true | 96 | self.settings["#{feature}_enabled"] = true |
@@ -193,7 +193,7 @@ class Environment < ActiveRecord::Base | @@ -193,7 +193,7 @@ class Environment < ActiveRecord::Base | ||
193 | 193 | ||
194 | self.settings['organization_approval_method'] = actual_value | 194 | self.settings['organization_approval_method'] = actual_value |
195 | end | 195 | end |
196 | - | 196 | + |
197 | # the description of the environment. Normally used in the homepage. | 197 | # the description of the environment. Normally used in the homepage. |
198 | def description | 198 | def description |
199 | self.settings[:description] | 199 | self.settings[:description] |
@@ -263,4 +263,32 @@ class Environment < ActiveRecord::Base | @@ -263,4 +263,32 @@ class Environment < ActiveRecord::Base | ||
263 | self[:theme] || 'default' | 263 | self[:theme] || 'default' |
264 | end | 264 | end |
265 | 265 | ||
266 | + def enterprise_template | ||
267 | + Enterprise.find settings[:enterprise_template_id] | ||
268 | + end | ||
269 | + | ||
270 | + def community_template | ||
271 | + Community.find settings[:community_template_id] | ||
272 | + end | ||
273 | + | ||
274 | + def person_template | ||
275 | + Person.find settings[:person_template_id] | ||
276 | + end | ||
277 | + | ||
278 | + after_create do |env| | ||
279 | + pre = env.name.to_slug + '_' | ||
280 | + ent_id = Enterprise.create!(:name => 'Enterprise template', :identifier => pre + 'enterprise_template', :environment => env, :public_profile => false).id | ||
281 | + com_id = Community.create!(:name => 'Community template', :identifier => pre + 'community_template', :environment => env, :public_profile => false).id | ||
282 | + pass = Digest::MD5.hexdigest rand.to_s | ||
283 | + user = User.create!(:login => 'person_template', :email => 'template@template.noo', :password => pass, :password_confirmation => pass).person | ||
284 | + user.environment = env | ||
285 | + user.public_profile = false | ||
286 | + user.save! | ||
287 | + usr_id = user.id | ||
288 | + env.settings[:enterprise_template_id] = ent_id | ||
289 | + env.settings[:community_template_id] = com_id | ||
290 | + env.settings[:person_template_id] = usr_id | ||
291 | + env.save! | ||
292 | + end | ||
293 | + | ||
266 | end | 294 | end |
@@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
1 | +<h1><%= _('Edit Templates') %></h1> | ||
2 | + | ||
3 | +<ul> | ||
4 | +<li><%= link_to _('Edit Person Template'), :controller => 'profile_editor', :profile => environment.person_template.identifier %></li> | ||
5 | +<li><%= link_to _('Edit Community Template'), :controller => 'profile_editor', :profile => environment.community_template.identifier %></li> | ||
6 | +<li><%= link_to _('Edit Enterprise Template'), :controller => 'profile_editor', :profile => environment.enterprise_template.identifier %></li> | ||
7 | +</ul> |
app/views/admin_panel/index.rhtml
@@ -10,4 +10,5 @@ | @@ -10,4 +10,5 @@ | ||
10 | <li><%= link_to _('Manage Categories'), :controller => 'categories'%></li> | 10 | <li><%= link_to _('Manage Categories'), :controller => 'categories'%></li> |
11 | <li><%= link_to _('Manage User roles'), :controller => 'role' %></li> | 11 | <li><%= link_to _('Manage User roles'), :controller => 'role' %></li> |
12 | <li><%= link_to _('Manage Validators by region'), :controller => 'region_validators' %></li> | 12 | <li><%= link_to _('Manage Validators by region'), :controller => 'region_validators' %></li> |
13 | + <li><%= link_to _('Edit Templates'), :action => 'edit_templates' %></li> | ||
13 | </ul> | 14 | </ul> |
lib/tasks/populate.rake
@@ -30,6 +30,12 @@ def create_roles | @@ -30,6 +30,12 @@ def create_roles | ||
30 | 'manage_environment_categories', | 30 | 'manage_environment_categories', |
31 | 'manage_environment_roles', | 31 | 'manage_environment_roles', |
32 | 'manage_environment_validators', | 32 | 'manage_environment_validators', |
33 | + 'edit_profile', | ||
34 | + 'destroy_profile', | ||
35 | + 'manage_memberships', | ||
36 | + 'post_content', | ||
37 | + 'edit_profile_design', | ||
38 | + 'manage_products', | ||
33 | ]) | 39 | ]) |
34 | Role.create!(:key => 'profile_admin', :name => N_('Profile Administrator'), :permissions => [ | 40 | Role.create!(:key => 'profile_admin', :name => N_('Profile Administrator'), :permissions => [ |
35 | 'edit_profile', | 41 | 'edit_profile', |
test/unit/environment_test.rb
@@ -379,4 +379,22 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -379,4 +379,22 @@ class EnvironmentTest < Test::Unit::TestCase | ||
379 | assert_equal 'default', Environment.new.theme | 379 | assert_equal 'default', Environment.new.theme |
380 | end | 380 | end |
381 | 381 | ||
382 | + should 'create templates' do | ||
383 | + e = Environment.create!(:name => 'test_env') | ||
384 | + e.reload | ||
385 | + | ||
386 | + assert_kind_of Enterprise, e.enterprise_template | ||
387 | + assert_kind_of Community, e.community_template | ||
388 | + assert_kind_of Person, e.person_template | ||
389 | + end | ||
390 | + | ||
391 | + should 'have private templates' do | ||
392 | + e = Environment.create!(:name => 'test_env') | ||
393 | + e.reload | ||
394 | + | ||
395 | + assert !e.enterprise_template.public? | ||
396 | + assert !e.community_template.public? | ||
397 | + assert !e.person_template.public? | ||
398 | + end | ||
399 | + | ||
382 | end | 400 | end |