diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c71ee1a..da3f83a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1330,11 +1330,12 @@ module ApplicationHelper end def template_options(klass, field_name) - return '' if klass.templates.count == 0 - return hidden_field_tag("#{field_name}[template_id]", klass.templates.first.id) if klass.templates.count == 1 + templates = klass.templates(environment.id) + return '' if templates.count == 0 + return hidden_field_tag("#{field_name}[template_id]", templates.first.id) if templates.count == 1 counter = 0 - radios = klass.templates.map do |template| + radios = templates.map do |template| counter += 1 content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, counter==1)) end.join("\n") diff --git a/app/models/profile.rb b/app/models/profile.rb index 4a11192..5f4b393 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -68,7 +68,7 @@ class Profile < ActiveRecord::Base #FIXME: these will work only if the subclass is already loaded named_scope :enterprises, lambda { {:conditions => (Enterprise.send(:subclasses).map(&:name) << 'Enterprise').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } named_scope :communities, lambda { {:conditions => (Community.send(:subclasses).map(&:name) << 'Community').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } - named_scope :templates, :conditions => {:is_template => true} + named_scope :templates, lambda { |environment_id| { :conditions => {:is_template => true, :environment_id => environment_id} } } def members scopes = plugins.dispatch_scopes(:organization_members, self) diff --git a/app/views/templates/index.html.erb b/app/views/templates/index.html.erb index afe0f7c..48f165a 100644 --- a/app/views/templates/index.html.erb +++ b/app/views/templates/index.html.erb @@ -2,9 +2,9 @@ <%= _('Manage the templates used on creation of profiles') %> -<% list_of_templates = [[_('Person') , Person.templates , 'person' ], - [_('Community') , Community.templates , 'community' ], - [_('Enterprise'), Enterprise.templates, 'enterprise']] %> +<% list_of_templates = [[_('Person') , Person.templates(environment.id) , 'person' ], + [_('Community') , Community.templates(environment.id) , 'community' ], + [_('Enterprise'), Enterprise.templates(environment.id), 'enterprise']] %> <% list_of_templates.each do |title, templates, kind|%>