Commit 0c93a29d3e443362286c9e127424649f6a187943

Authored by Ábner Silva de Oliveira
2 parents f092d7d1 0a6daa95

merge with master - changed to keep tasks filter after tasks close action

app/controllers/my_profile/tasks_controller.rb
@@ -84,7 +84,8 @@ class TasksController < MyProfileController @@ -84,7 +84,8 @@ class TasksController < MyProfileController
84 end 84 end
85 end 85 end
86 86
87 - url = { :action => 'index' } 87 + url = task_action(:index)
  88 +
88 if failed.blank? 89 if failed.blank?
89 session[:notice] = _("All decisions were applied successfully.") 90 session[:notice] = _("All decisions were applied successfully.")
90 else 91 else
app/helpers/task_helper.rb
@@ -10,4 +10,15 @@ module TaskHelper @@ -10,4 +10,15 @@ module TaskHelper
10 ) 10 )
11 end 11 end
12 12
  13 + def task_action action
  14 + require 'debugger'; debugger
  15 + base_url = { action: action }
  16 + url_for(base_url.merge(filter_params))
  17 + end
  18 +
  19 + def filter_params
  20 + filter_fields = ['filter_type', 'filter_text', 'filter_responsible', 'filter_tags']
  21 + params.select {|filter| filter if filter_fields.include? filter }
  22 + end
  23 +
13 end 24 end
app/models/highlights_block.rb
@@ -12,6 +12,7 @@ class HighlightsBlock < Block @@ -12,6 +12,7 @@ class HighlightsBlock < Block
12 block.images.each do |i| 12 block.images.each do |i|
13 i[:image_id] = i[:image_id].to_i 13 i[:image_id] = i[:image_id].to_i
14 i[:position] = i[:position].to_i 14 i[:position] = i[:position].to_i
  15 + i[:address] = Noosfero.root + i[:address] unless Noosfero.root.nil?
15 begin 16 begin
16 file = UploadedFile.find(i[:image_id]) 17 file = UploadedFile.find(i[:image_id])
17 i[:image_src] = file.public_filename 18 i[:image_src] = file.public_filename
app/views/tasks/index.html.erb
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 <em><%= _('No pending tasks for %s') % profile.name %></em> 50 <em><%= _('No pending tasks for %s') % profile.name %></em>
51 </p> 51 </p>
52 <% else %> 52 <% else %>
53 - <%= form_tag :action => 'close' do%> 53 + <%= form_tag task_action('close') do%>
54 <% button_bar(:class => 'task-actions') do %> 54 <% button_bar(:class => 'task-actions') do %>
55 <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> 55 <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %>
56 <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> 56 <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %>
plugins/people_block/lib/friends_block.rb
@@ -17,7 +17,7 @@ class FriendsBlock &lt; PeopleBlockBase @@ -17,7 +17,7 @@ class FriendsBlock &lt; PeopleBlockBase
17 end 17 end
18 18
19 def suggestions 19 def suggestions
20 - owner.profile_suggestions.of_person.enabled.limit(3).includes(:suggestion) 20 + owner.suggested_profiles.of_person.enabled.limit(3).includes(:suggestion)
21 end 21 end
22 22
23 def footer 23 def footer
plugins/people_block/test/functional/profile_controller_test.rb
@@ -17,8 +17,8 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -17,8 +17,8 @@ class ProfileControllerTest &lt; ActionController::TestCase
17 login_as(user.login) 17 login_as(user.login)
18 owner = user.person 18 owner = user.person
19 19
20 - suggestion1 = owner.profile_suggestions.create(:suggestion => fast_create(Person))  
21 - suggestion2 = owner.profile_suggestions.create(:suggestion => fast_create(Person)) 20 + suggestion1 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
  21 + suggestion2 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
22 22
23 FriendsBlock.delete_all 23 FriendsBlock.delete_all
24 block = FriendsBlock.new 24 block = FriendsBlock.new
plugins/people_block/test/unit/friends_block_test.rb
@@ -138,8 +138,8 @@ class FriendsBlockTest &lt; ActionView::TestCase @@ -138,8 +138,8 @@ class FriendsBlockTest &lt; ActionView::TestCase
138 138
139 should 'list owner\'s friends suggestions' do 139 should 'list owner\'s friends suggestions' do
140 owner = fast_create(Person) 140 owner = fast_create(Person)
141 - suggestion1 = owner.profile_suggestions.create(:suggestion => fast_create(Person))  
142 - suggestion2 = owner.profile_suggestions.create(:suggestion => fast_create(Person)) 141 + suggestion1 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
  142 + suggestion2 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
143 143
144 block = FriendsBlock.new 144 block = FriendsBlock.new
145 block.stubs(:owner).returns(owner) 145 block.stubs(:owner).returns(owner)
plugins/statistics/lib/statistics_block.rb
@@ -61,7 +61,7 @@ class StatisticsBlock &lt; Block @@ -61,7 +61,7 @@ class StatisticsBlock &lt; Block
61 end 61 end
62 62
63 def templates 63 def templates
64 - Community.templates(environment) 64 + self.environment.community_templates
65 end 65 end
66 66
67 def is_template_counter_active? template_id 67 def is_template_counter_active? template_id
public/javascripts/manage-categories.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 fetch_sub_items = function(sub_items, category){ 2 fetch_sub_items = function(sub_items, category){
3 loading_for_button($("#category-loading-"+category)[0]); 3 loading_for_button($("#category-loading-"+category)[0]);
4 $.ajax({ 4 $.ajax({
5 - url: "/admin/categories/get_children", 5 + url: noosfero_root() + "/admin/categories/get_children",
6 dataType: "html", 6 dataType: "html",
7 data: {id: category}, 7 data: {id: category},
8 success: function(data, st, ajax){ 8 success: function(data, st, ajax){
test/unit/highlights_block_test.rb
@@ -119,6 +119,19 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase @@ -119,6 +119,19 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase
119 block.featured_images 119 block.featured_images
120 end 120 end
121 121
  122 + should 'return correct sub-dir address' do
  123 + Noosfero.stubs(:root).returns("/social")
  124 + f1 = mock()
  125 + f1.expects(:public_filename).returns('address')
  126 + UploadedFile.expects(:find).with(1).returns(f1)
  127 + block = HighlightsBlock.new
  128 + i1 = {:image_id => 1, :address => '/address', :position => 3, :title => 'address'}
  129 + block.images = [i1]
  130 + block.save!
  131 + block.reload
  132 + assert_equal block.images.first[:address], "/social/address"
  133 + end
  134 +
122 [Environment, Profile].each do |klass| 135 [Environment, Profile].each do |klass|
123 should "choose between owner galleries when owner is #{klass.name}" do 136 should "choose between owner galleries when owner is #{klass.name}" do
124 owner = fast_create(klass) 137 owner = fast_create(klass)