diff --git a/plugins/sniffer/lib/sniffer_plugin/interests_block.rb b/plugins/sniffer/lib/sniffer_plugin/interests_block.rb
index 5fdeee4..26775af 100644
--- a/plugins/sniffer/lib/sniffer_plugin/interests_block.rb
+++ b/plugins/sniffer/lib/sniffer_plugin/interests_block.rb
@@ -16,22 +16,20 @@ class SnifferPlugin::InterestsBlock < Block
_("This block show interests of your profile or environment")
end
- def content(args = {})
- block = self
+ def interests
+ results = nil
profile = block.owner
- proc do
- if block.owner.is_a?(Profile)
- interests = profile.snnifer_opportunities
- interests |= profile.inputs if sniffer.profile.enterprise?
- else # Environment
- interests = SnifferPlugin::Opportunity.product_categories.limit(5).order('created_at DESC').all
- interests += Input.limit(5).order('created_at DESC').all
- interests.sort{ |a, b| -1 * a.created_at.to_i <=> b.created_at.to_i }
- end
-
- render :file => 'blocks/sniffer_plugin/interests_block',
- :locals => {:block => block, :interests => interests}
+
+ if profile.is_a?(Profile)
+ results = profile.snnifer_opportunities
+ results |= profile.inputs if sniffer.profile.enterprise?
+ else # Environment
+ results = SnifferPlugin::Opportunity.product_categories.limit(5).order('created_at DESC').all
+ results += Input.limit(5).order('created_at DESC').all
+ results.sort{ |a, b| -1 * a.created_at.to_i <=> b.created_at.to_i }
end
+
+ return results
end
end
diff --git a/plugins/sniffer/views/blocks/interests.html.erb b/plugins/sniffer/views/blocks/interests.html.erb
new file mode 100644
index 0000000..81268d3
--- /dev/null
+++ b/plugins/sniffer/views/blocks/interests.html.erb
@@ -0,0 +1,31 @@
+<%= block_title block.title, block.subtitle %>
+
+<% if block.owner.is_a?(Profile) %>
+
+ <% block.interests.each do |interest| %>
+ - <%= interest.product_category.name %>
+ <% end %>
+
+
+
+ <% if logged_in? and (current_user.person.is_admin?(environment) or profile.admins.include?(current_user.person)) %>
+ <%= _('Edit %{inputs} and %{block.interests}') % {
+ :inputs => link_to(_("products' inputs"), :controller => :manage_products, :action => :index),
+ :interests => link_to(_('declared interests'), :controller => :sniffer_plugin_myprofile, :action => :edit),
+ } %>
+ <% end %>
+
+<% else %>
+
+ <% block.interests.each do |interest| %>
+ -
+ <% profile = interest.is_a?(SnifferPlugin::Opportunity) ? interest.profile : interest.product.enterprise %>
+ <%= _('%{interest} from %{profile}') % {
+ :interest => interest.product_category.name,
+ :profile => link_to_profile(profile.name, profile),
+ } %>
+
+ <% end %>
+
+<% end %>
+
diff --git a/plugins/sniffer/views/blocks/sniffer_plugin/interests_block.html.erb b/plugins/sniffer/views/blocks/sniffer_plugin/interests_block.html.erb
deleted file mode 100644
index fd520b2..0000000
--- a/plugins/sniffer/views/blocks/sniffer_plugin/interests_block.html.erb
+++ /dev/null
@@ -1,31 +0,0 @@
-<%= block_title block.title, block.subtitle %>
-
-<% if block.owner.is_a?(Profile) %>
-
- <% interests.each do |interest| %>
- - <%= interest.product_category.name %>
- <% end %>
-
-
-
- <% if logged_in? and (current_user.person.is_admin?(environment) or profile.admins.include?(current_user.person)) %>
- <%= _('Edit %{inputs} and %{interests}') % {
- :inputs => link_to(_("products' inputs"), :controller => :manage_products, :action => :index),
- :interests => link_to(_('declared interests'), :controller => :sniffer_plugin_myprofile, :action => :edit),
- } %>
- <% end %>
-
-<% else %>
-
- <% interests.each do |interest| %>
- -
- <% profile = interest.is_a?(SnifferPlugin::Opportunity) ? interest.profile : interest.product.enterprise %>
- <%= _('%{interest} from %{profile}') % {
- :interest => interest.product_category.name,
- :profile => link_to_profile(profile.name, profile),
- } %>
-
- <% end %>
-
-<% end %>
-
--
libgit2 0.21.2