Commit f1bd38259732ab15df63128196dbe05e695e4bef

Authored by Aurélio A. Heckert
1 parent a83e415d

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 &lt; ActiveRecord::Base
681 681 end
682 682  
683 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 686 end
686 687  
687 688 def community_template=(value)
... ... @@ -689,7 +690,8 @@ class Environment &lt; ActiveRecord::Base
689 690 end
690 691  
691 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 695 end
694 696  
695 697 def person_template=(value)
... ... @@ -697,7 +699,8 @@ class Environment &lt; ActiveRecord::Base
697 699 end
698 700  
699 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 704 end
702 705  
703 706 def enterprise_template=(value)
... ... @@ -705,7 +708,8 @@ class Environment &lt; ActiveRecord::Base
705 708 end
706 709  
707 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 713 end
710 714  
711 715 def inactive_enterprise_template=(value)
... ...