Commit f1bd38259732ab15df63128196dbe05e695e4bef
1 parent
a83e415d
Exists in
master
and in
28 other branches
Confirm if env templates are set as template
Adds "if <profile>.is_template" to <profile>_template methods.
Showing
1 changed file
with
8 additions
and
4 deletions
Show diff stats
app/models/environment.rb
| @@ -681,7 +681,8 @@ class Environment < ActiveRecord::Base | @@ -681,7 +681,8 @@ class Environment < ActiveRecord::Base | ||
| 681 | end | 681 | end |
| 682 | 682 | ||
| 683 | def community_template | 683 | def community_template |
| 684 | - Community.find_by_id settings[:community_template_id] | 684 | + template = Community.find_by_id settings[:community_template_id] |
| 685 | + template if template && template.is_template | ||
| 685 | end | 686 | end |
| 686 | 687 | ||
| 687 | def community_template=(value) | 688 | def community_template=(value) |
| @@ -689,7 +690,8 @@ class Environment < ActiveRecord::Base | @@ -689,7 +690,8 @@ class Environment < ActiveRecord::Base | ||
| 689 | end | 690 | end |
| 690 | 691 | ||
| 691 | def person_template | 692 | def person_template |
| 692 | - Person.find_by_id settings[:person_template_id] | 693 | + template = Person.find_by_id settings[:person_template_id] |
| 694 | + template if template && template.is_template | ||
| 693 | end | 695 | end |
| 694 | 696 | ||
| 695 | def person_template=(value) | 697 | def person_template=(value) |
| @@ -697,7 +699,8 @@ class Environment < ActiveRecord::Base | @@ -697,7 +699,8 @@ class Environment < ActiveRecord::Base | ||
| 697 | end | 699 | end |
| 698 | 700 | ||
| 699 | def enterprise_template | 701 | def enterprise_template |
| 700 | - Enterprise.find_by_id settings[:enterprise_template_id] | 702 | + template = Enterprise.find_by_id settings[:enterprise_template_id] |
| 703 | + template if template && template.is_template | ||
| 701 | end | 704 | end |
| 702 | 705 | ||
| 703 | def enterprise_template=(value) | 706 | def enterprise_template=(value) |
| @@ -705,7 +708,8 @@ class Environment < ActiveRecord::Base | @@ -705,7 +708,8 @@ class Environment < ActiveRecord::Base | ||
| 705 | end | 708 | end |
| 706 | 709 | ||
| 707 | def inactive_enterprise_template | 710 | def inactive_enterprise_template |
| 708 | - Enterprise.find_by_id settings[:inactive_enterprise_template_id] | 711 | + template = Enterprise.find_by_id settings[:inactive_enterprise_template_id] |
| 712 | + template if template && template.is_template | ||
| 709 | end | 713 | end |
| 710 | 714 | ||
| 711 | def inactive_enterprise_template=(value) | 715 | def inactive_enterprise_template=(value) |