Commit d7db87da602f310ea19054be9a546957cfdb13db
1 parent
74447430
Exists in
master
and in
29 other branches
ActionItem1173: removing useless code
Showing
6 changed files
with
0 additions
and
127 deletions
Show diff stats
app/controllers/admin/admin_panel_controller.rb
... | ... | @@ -16,25 +16,6 @@ class AdminPanelController < AdminController |
16 | 16 | end |
17 | 17 | end |
18 | 18 | |
19 | - def manage_templates | |
20 | - @person_templates = environment.templates('person') | |
21 | - @community_templates = environment.templates('community') | |
22 | - @enterprise_templates = environment.templates('enterprise') | |
23 | - @templates = @person_templates + @community_templates + @enterprise_templates | |
24 | - end | |
25 | - | |
26 | - def set_template | |
27 | - environment.person_template = Person.find(params[:environment][:person_template]) if params[:environment][:person_template] | |
28 | - environment.enterprise_template = Enterprise.find(params[:environment][:enterprise_template]) if params[:environment][:enterprise_template] | |
29 | - environment.community_template = Community.find(params[:environment][:community_template]) if params[:environment][:community_template] | |
30 | - if environment.save! | |
31 | - flash[:notice] = _('Template updated successfully') | |
32 | - else | |
33 | - flash[:error] = _('Could not update template') | |
34 | - end | |
35 | - redirect_to :action => 'manage_templates' | |
36 | - end | |
37 | - | |
38 | 19 | def set_portal_community |
39 | 20 | env = environment |
40 | 21 | @portal_community = env.portal_community || Community.new | ... | ... |
app/models/environment.rb
... | ... | @@ -594,25 +594,6 @@ class Environment < ActiveRecord::Base |
594 | 594 | settings[:inactive_enterprise_template_id] = value.id |
595 | 595 | end |
596 | 596 | |
597 | - def templates(profile = 'profile') | |
598 | - klass = profile.classify.constantize | |
599 | - templates = [] | |
600 | - if settings[:templates_ids] | |
601 | - settings[:templates_ids].each do |template_id| | |
602 | - templates << klass.find_by_id(template_id) | |
603 | - end | |
604 | - end | |
605 | - templates.compact | |
606 | - end | |
607 | - | |
608 | - def add_templates=(values) | |
609 | - if settings[:templates_ids] | |
610 | - settings[:templates_ids].concat(values.map(&:id)) | |
611 | - else | |
612 | - settings[:templates_ids] = values.map(&:id) | |
613 | - end | |
614 | - end | |
615 | - | |
616 | 597 | def replace_enterprise_template_when_enable |
617 | 598 | settings[:replace_enterprise_template_when_enable] || false |
618 | 599 | end | ... | ... |
app/views/admin_panel/index.rhtml
... | ... | @@ -10,7 +10,6 @@ |
10 | 10 | <tr><td><%= link_to _('Manage Categories'), :controller => 'categories'%></td></tr> |
11 | 11 | <tr><td><%= link_to _('Manage User roles'), :controller => 'role' %></td></tr> |
12 | 12 | <tr><td><%= link_to _('Manage Validators by region'), :controller => 'region_validators' %></td></tr> |
13 | - <tr><td><%= link_to _('Manage Templates'), :action => 'manage_templates' %></td></tr> | |
14 | 13 | <tr><td><%= link_to _('Edit Templates'), :action => 'edit_templates' %></td></tr> |
15 | 14 | <tr><td><%= link_to _('Manage Fields'), :controller => 'features', :action => 'manage_fields' %></td></tr> |
16 | 15 | <tr><td><%= link_to _('Set Portal'), :action => 'set_portal_community' %></td></tr> | ... | ... |
app/views/admin_panel/manage_templates.rhtml
... | ... | @@ -1,24 +0,0 @@ |
1 | -<h1><%= _('Set Templates') %></h1> | |
2 | - | |
3 | -<% labelled_form_for(:environment, @environment, :url => {:action => 'set_template'}) do |f| %> | |
4 | - <p> | |
5 | - <label for='environment_person_template'><%= _('Person Template') %></label><br/> | |
6 | - <%= f.select :person_template, @person_templates.map {|item| [ item.identifier, item.id]}, :selected => (environment.person_template.nil? ? nil : environment.person_template.id) %> | |
7 | - </p> | |
8 | - | |
9 | - <p> | |
10 | - <label for='environment_community_template'><%= _('Community Template') %></label><br/> | |
11 | - <%= f.select :community_template, @community_templates.map {|item| [ item.identifier, item.id]}, :selected => (environment.community_template.nil? ? nil : environment.community_template.id) %> | |
12 | - </p> | |
13 | - | |
14 | - <p> | |
15 | - <label for='environment_enterprise_template'><%= _('Enterprise Template') %></label><br/> | |
16 | - <%= f.select :enterprise_template, @enterprise_templates.map {|item| [ item.identifier, item.id]}, :selected => (environment.enterprise_template.nil? ? nil : environment.enterprise_template.id) %> | |
17 | - </p> | |
18 | - | |
19 | - <% button_bar do %> | |
20 | - <%= submit_button(:save, _('Save')) %> | |
21 | - <%= button(:cancel, _('Cancel'), :action => 'index') %> | |
22 | - <% end %> | |
23 | - | |
24 | -<% end %> |
test/functional/admin_panel_controller_test.rb
... | ... | @@ -99,42 +99,6 @@ class AdminPanelControllerTest < Test::Unit::TestCase |
99 | 99 | assert_equal "This <strong>is</strong> my new environment", Environment.default.message_for_disabled_enterprise |
100 | 100 | end |
101 | 101 | |
102 | - should 'list templates' do | |
103 | - get :manage_templates | |
104 | - | |
105 | - assert_kind_of Array, assigns(:person_templates) | |
106 | - assert_kind_of Array, assigns(:community_templates) | |
107 | - assert_kind_of Array, assigns(:enterprise_templates) | |
108 | - end | |
109 | - | |
110 | - should 'display environment template options' do | |
111 | - e = Environment.default | |
112 | - @controller.stubs(:environment).returns(e) | |
113 | - profile_template = Profile.create!(:name =>'template_test', :identifier => 'template_test', :environment => e) | |
114 | - e.settings[:templates_ids] = [profile_template.id] | |
115 | - e.save! | |
116 | - e.stubs(:templates).with('person').returns([profile_template]) | |
117 | - e.stubs(:templates).with('community').returns([profile_template]) | |
118 | - e.stubs(:templates).with('enterprise').returns([profile_template]) | |
119 | - | |
120 | - assert_equal [profile_template], e.templates('person') | |
121 | - | |
122 | - get :manage_templates | |
123 | - ['person_template', 'community_template', 'enterprise_template'].each do |template| | |
124 | - assert_tag :tag => 'select', :attributes => { :id => "environment_#{template}"}, :descendant => { :tag => 'option', :content => 'template_test'} | |
125 | - end | |
126 | - end | |
127 | - | |
128 | - should 'set template' do | |
129 | - e = Environment.default | |
130 | - @controller.stubs(:environment).returns(e) | |
131 | - profile_template = Enterprise.create!(:name =>'template_test', :identifier => 'template_test') | |
132 | - | |
133 | - post :set_template, :environment => {:enterprise_template => profile_template.id} | |
134 | - | |
135 | - assert_equal profile_template, e.enterprise_template | |
136 | - end | |
137 | - | |
138 | 102 | should 'not use WYSWYIG if disabled' do |
139 | 103 | e = Environment.default; e.disable('wysiwyg_editor_for_environment_home'); e.save! |
140 | 104 | get :site_info | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -487,34 +487,6 @@ class EnvironmentTest < Test::Unit::TestCase |
487 | 487 | assert_equal template, e.enterprise_template |
488 | 488 | end |
489 | 489 | |
490 | - should 'add templates when it is empty' do | |
491 | - e = Environment.create!(:name => 'test_env') | |
492 | - ent_template_a = Enterprise.create!(:name => 'Enterprise template A', :identifier => e.name.to_slug + 'enterprise_template_a', :environment => e, :public_profile => false) | |
493 | - ent_template_b = Enterprise.create!(:name => 'Enterprise template B', :identifier => e.name.to_slug + 'enterprise_template_b', :environment => e, :public_profile => false) | |
494 | - | |
495 | - e.add_templates = [ent_template_a, ent_template_b] | |
496 | - assert_equal [ent_template_a, ent_template_b], e.templates | |
497 | - end | |
498 | - | |
499 | - should 'add templates when it is not empty' do | |
500 | - e = Environment.create!(:name => 'test_env') | |
501 | - | |
502 | - ent_template_example = Enterprise.create!(:name => 'Enterprise template example', :identifier => e.name.to_slug + 'enterprise_template_example', :environment => e, :public_profile => false) | |
503 | - | |
504 | - e.settings[:templates_ids] = [ent_template_example.id] | |
505 | - e.save | |
506 | - | |
507 | - ent_template_a = Enterprise.create!(:name => 'Enterprise template A', :identifier => e.name.to_slug + 'enterprise_template_a', :environment => e, :public_profile => false) | |
508 | - | |
509 | - e.add_templates = [ent_template_a] | |
510 | - | |
511 | - assert_equal [ent_template_example, ent_template_a], e.templates | |
512 | - end | |
513 | - | |
514 | - should 'have an empty array of templates by default' do | |
515 | - assert_equal [], Environment.new.templates | |
516 | - end | |
517 | - | |
518 | 490 | should 'not disable ssl by default' do |
519 | 491 | e = Environment.new |
520 | 492 | assert !e.disable_ssl | ... | ... |